2aed681697ec21483bf10eeda40d1de2897c9a3d
[p5sagit/p5-mst-13.2.git] / cflags.SH
1 case $CONFIGDOTSH in
2 '')
3         if test -f config.sh; then TOP=.;
4         elif test -f ../config.sh; then TOP=..;
5         elif test -f ../../config.sh; then TOP=../..;
6         elif test -f ../../../config.sh; then TOP=../../..;
7         elif test -f ../../../../config.sh; then TOP=../../../..;
8         else
9                 echo "Can't find config.sh."; exit 1
10         fi
11         . $TOP/config.sh
12         ;;
13 esac
14 : This forces SH files to create target in same directory as SH file.
15 : This is so that make depend always knows where to find SH derivatives.
16 case "$0" in
17 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
18 esac
19 echo "Extracting cflags (with variable substitutions)"
20 : This section of the file will have variable substitutions done on it.
21 : Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!.
22 : Protect any dollar signs and backticks that you do not want interpreted
23 : by putting a backslash in front.  You may delete these comments.
24 rm -f cflags
25 $spitshell >cflags <<!GROK!THIS!
26 $startsh
27 src=$src
28 !GROK!THIS!
29
30 : In the following dollars and backticks do not need the extra backslash.
31 $spitshell >>cflags <<'!NO!SUBS!'
32 case $CONFIGDOTSH in
33 '')
34         if test -f config.sh; then TOP=.;
35         elif test -f ../config.sh; then TOP=..;
36         elif test -f ../../config.sh; then TOP=../..;
37         elif test -f ../../../config.sh; then TOP=../../..;
38         elif test -f ../../../../config.sh; then TOP=../../../..;
39         else
40                 echo "Can't find config.sh."; exit 1
41         fi
42         . $TOP/config.sh
43         ;;
44 esac
45
46 perltype=''
47 optdebug=''     # ensure -g used if building a -DDEBUGGING libperl
48 case $# in
49 2) case $1 in
50     *perl.*)    perltype='';;
51     *perld.*)   perltype='-DDEBUGGING'; optdebug='-g' ;;
52     *perle.*)   perltype='-DEMBED';;
53     *perlde.*)  perltype='-DDEBUGGING -DEMBED'; optdebug='-g' ;;
54     *perlm.*)   perltype='-DEMBED -DMULTIPLICITY';;
55     *perldm.*)  perltype='-DDEBUGGING -DEMBED -DMULTIPLICITY'; optdebug='-g' ;;
56     esac
57     shift ;;
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 for out-of-source experience
79
80     if test "X$src" != X.; then
81         ccflags="$ccflags -I$src -I."
82     fi
83
84     : allow variables like toke_cflags to be evaluated
85
86     if echo $file | grep -v / >/dev/null
87     then
88       eval 'eval ${'"${file}_cflags"'-""}'
89     fi
90
91     : or customize here
92
93     case "$file" in
94     DB_File) ;;
95     GDBM_File) ;;
96     NDBM_File) ;;
97     ODBM_File) ;;
98     POSIX) ;;
99     SDBM_File) ;;
100     av) ;;
101     byterun) ;;
102     deb) ;;
103     dl) ;;
104     doio) ;;
105     doop) ;;
106     dump) ;;
107     gv) ;;
108     hv) ;;
109     main) ;;
110     malloc) ;;
111     mg) ;;
112     miniperlmain) ;;
113     op) ;;
114     perl) ;;
115     perlmain) ;;
116     perly) ;;
117     pp) ;;
118     pp_ctl) ;;
119     pp_hot) ;;
120     pp_sys) ;;
121     regcomp) ;;
122     regexec) ;;
123     run) ;;
124     scope) ;;
125     sv) ;;
126     taint) ;;
127     toke) ;;
128     usersub) ;;
129     util) ;;
130     *) ;;
131     esac
132
133         if test "X$optdebug" != "X"; then
134                 optimize="$optdebug"
135         fi
136
137     : Can we perhaps use $ansi2knr here
138     echo "$cc -c -DPERL_CORE $ccflags $optimize $perltype $large $split"
139     eval "$also "'"$cc -DPERL_CORE -c $ccflags $optimize $perltype $large $split"'
140
141     . $TOP/config.sh
142
143 done
144 !NO!SUBS!
145 chmod 755 cflags
146 $eunicefix cflags