This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backport #33598 +
[metaconfig.git] / U / compline / Compile.U
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 test
14 ?MAKE:  -pick add $@ %<
15 ?LINT:extern usedevel
16 ?LINT:define compile compile_ok
17 ?V:compile compile_ok mc_file
18 ?S:compile:
19 ?S:     This shell variable is used internally by Configure to provide
20 ?S:     a convenient shorthand for the typical compile command, namely
21 ?S:     $cc $optimize $ccflags $ldflags -o $1 $1.c $libs > /dev/null 2>&1
22 ?S:     Note that the output filename does _not_ include the _exe
23 ?S:     extension.  Instead we assume that the linker will be
24 ?S:     "helpful" and automatically appending the correct suffix.
25 ?S:     OS/2 users will apparently need to supply the -Zexe flag to
26 ?S:     get this behavior.
27 ?S:
28 ?S:     To use this variable, say something like:
29 ?S:             echo 'int main() { exit(0); }' > try.c
30 ?S:             set try
31 ?S:             if eval $compile; then
32 ?S:                     echo "success"   # and do whatever . . . 
33 ?S:             else
34 ?S:                     echo "failure"   # and do whatever . . . 
35 ?S:             fi
36 ?S:     To add extra flags cc flags (e.g. -DWHATEVER) just put them
37 ?S:     in $*, e.g.
38 ?S:             set try -DTRY_THIS_FLAG
39 ?S:.
40 ?S:compile_ok:
41 ?S:     This shell variable is used internally by Configure to provide
42 ?S:     a convenient shorthand for the typical compile command that you
43 ?S:     expect to work ok.  It is the same as $compile, except we
44 ?S:     deliberately let the user see any error messages. 
45 ?S:.
46 : define a shorthand compile call
47 compile='
48 mc_file=$1;
49 shift;
50 case "$usedevel" in $define|true|[yY]*) if $test ! -f "${mc_file}.c"; then
51 echo "Internal Configure script bug - compiler test file ${mc_file}.c is missing. Please report this to perlbug@perl.org" >&4;
52 exit 1;
53 fi;
54 esac;
55 $cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs > /dev/null 2>&1;'
56 : define a shorthand compile call for compilations that should be ok.
57 compile_ok='
58 mc_file=$1;
59 shift;
60 $cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs;'
61