This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Lose the loose. Fix documentation typo.
[perl5.git] / x2p / cflags.SH
1 #!/bin/sh
2
3 case $PERL_CONFIG_SH in
4 '')
5         if test -f config.sh; then TOP=.;
6         elif test -f ../config.sh; then TOP=..;
7         elif test -f ../../config.sh; then TOP=../..;
8         elif test -f ../../../config.sh; then TOP=../../..;
9         elif test -f ../../../../config.sh; then TOP=../../../..;
10         else
11                 echo "Can't find config.sh."; exit 1
12         fi
13         . $TOP/config.sh
14         ;;
15 esac
16 : This forces SH files to create target in same directory as SH file.
17 : This is so that make depend always knows where to find SH derivatives.
18 case "$0" in
19 */cflags.SH) cd `expr X$0 : 'X\(.*\)/'` ;;
20 cflags.SH) ;;
21 *) case `pwd` in
22    */x2p) ;;
23    *) if test -d x2p; then cd x2p
24       else echo "Can't figure out where to write output."; exit 1
25           fi;;
26    esac;;
27 esac
28 echo "Extracting x2p/cflags (with variable substitutions)"
29 : This section of the file will have variable substitutions done on it.
30 : Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!.
31 : Protect any dollar signs and backticks that you do not want interpreted
32 : by putting a backslash in front.  You may delete these comments.
33 rm -f cflags
34 $spitshell >cflags <<!GROK!THIS!
35 !GROK!THIS!
36
37 : In the following dollars and backticks do not need the extra backslash.
38 $spitshell >>cflags <<'!NO!SUBS!'
39 case $PERL_CONFIG_SH in
40 '')
41         if test -f config.sh; then TOP=.;
42         elif test -f ../config.sh; then TOP=..;
43         elif test -f ../../config.sh; then TOP=../..;
44         elif test -f ../../../config.sh; then TOP=../../..;
45         elif test -f ../../../../config.sh; then TOP=../../../..;
46         else
47                 echo "Can't find config.sh."; exit 1
48         fi
49         . $TOP/config.sh
50         ;;
51 esac
52
53 case "X$1" in
54 Xoptimize=*|X"optimize=*")
55         eval "$1"
56         shift
57         ;;
58 esac
59
60 also=': '
61 case $# in
62 1) also='echo 1>&2 "      CCCMD = "'
63 esac
64
65 case $# in
66 0) set *.c; echo "The current C flags are:" ;;
67 esac
68
69 set `echo "$* " | sed -e 's/\.[oc] / /g' -e 's/\.obj / /g' -e "s/\\$obj_ext / /g"`
70
71 for file do
72
73     case "$#" in
74     1) ;;
75     *) echo $n "    $file.c     $c" ;;
76     esac
77
78     : allow variables like str_cflags to be evaluated
79
80     eval 'eval ${'"${file}_cflags"'-""}'
81
82     : or customize here
83
84     case "$file" in
85     a2p) ;;
86     a2py) ;;
87     hash) ;;
88     str) ;;
89     util) ;;
90     walk) ;;
91     *) ;;
92     esac
93
94     ccflags="`echo $ccflags | sed -e 's/-DMULTIPLICITY//'`"
95
96     echo "$cc -c $ccflags $optimize"
97     eval "$also "'"$cc -c $ccflags $optimize"'
98
99     . $TOP/config.sh
100
101 done
102 !NO!SUBS!
103 chmod 755 cflags
104 $eunicefix cflags