Commit | Line | Data |
---|---|---|
959f3c4c JH |
1 | ?RCS: $Id: Compile.U,v $ |
2 | ?RCS: | |
3 | ?RCS: Copyright (c) 1998 Andy Dougherty | |
4 | ?RCS: | |
5 | ?RCS: You may distribute under the terms of either the GNU General Public | |
6 | ?RCS: License or the Artistic License, as specified in the README file. | |
7 | ?RCS: | |
8 | ?RCS: | |
9 | ?X: | |
10 | ?X: This unit is just a quick shorthand for the compile command | |
11 | ?X: to be used in all the other metaconfig units. | |
12 | ?X: | |
13 | ?MAKE:Compile: +cc +optimize +ccflags +ldflags +libs | |
14 | ?MAKE: -pick add $@ %< | |
15 | ?LINT:define compile compile_ok | |
16 | ?V:compile compile_ok mc_file | |
17 | ?S:compile: | |
18 | ?S: This shell variable is used internally by Configure to provide | |
19 | ?S: a convenient shorthand for the typical compile command, namely | |
20 | ?S: $cc $optimize $ccflags $ldflags -o $1 $1.c $libs > /dev/null 2>&1 | |
21 | ?S: Note that the output filename does _not_ include the _exe | |
22 | ?S: extension. Instead we assume that the linker will be | |
23 | ?S: "helpful" and automatically appending the correct suffix. | |
24 | ?S: OS/2 users will apparently need to supply the -Zexe flag to | |
25 | ?S: get this behavior. | |
26 | ?S: | |
27 | ?S: To use this variable, say something like: | |
28 | ?S: echo 'int main() { exit(0); }' > try.c | |
29 | ?S: set try | |
30 | ?S: if eval $compile; then | |
31 | ?S: echo "success" # and do whatever . . . | |
32 | ?S: else | |
33 | ?S: echo "failure" # and do whatever . . . | |
34 | ?S: fi | |
35 | ?S: To add extra flags cc flags (e.g. -DWHATEVER) just put them | |
36 | ?S: in $*, e.g. | |
37 | ?S: set try -DTRY_THIS_FLAG | |
38 | ?S:. | |
39 | ?S:compile_ok: | |
40 | ?S: This shell variable is used internally by Configure to provide | |
41 | ?S: a convenient shorthand for the typical compile command that you | |
42 | ?S: expect to work ok. It is the same as $compile, except we | |
43 | ?S: deliberately let the user see any error messages. | |
44 | ?S:. | |
45 | : define a shorthand compile call | |
46 | compile=' | |
47 | mc_file=$1; | |
48 | shift; | |
49 | $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs > /dev/null 2>&1;' | |
50 | : define a shorthand compile call for compilations that should be ok. | |
51 | compile_ok=' | |
52 | mc_file=$1; | |
53 | shift; | |
54 | $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs;' | |
55 |