$VERSION "a5" doesn't quite work.
[p5sagit/p5-mst-13.2.git] / cflags.SH
CommitLineData
a02608de 1case $PERL_CONFIG_SH in
1c3d792e 2'')
a0d0e21e 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 ;;
1c3d792e 13esac
2b317908 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.
1c3d792e 16case "$0" in
17*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
18esac
2b317908 19echo "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.
165b7424 24rm -f cflags
2b317908 25$spitshell >cflags <<!GROK!THIS!
ecfc5424 26$startsh
2b317908 27!GROK!THIS!
28
29: In the following dollars and backticks do not need the extra backslash.
30$spitshell >>cflags <<'!NO!SUBS!'
a02608de 31case $PERL_CONFIG_SH in
2b317908 32'')
a0d0e21e 33 if test -f config.sh; then TOP=.;
34 elif 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 else
39 echo "Can't find config.sh."; exit 1
40 fi
41 . $TOP/config.sh
42 ;;
43esac
44
1167a30e 45case "X$1" in
26102cc7 46Xoptimize=*|X"optimize=*")
1167a30e 47 eval "$1"
48 shift
49 ;;
50esac
51
a0d0e21e 52perltype=''
53optdebug='' # ensure -g used if building a -DDEBUGGING libperl
54case $# in
552) case $1 in
56 *perl.*) perltype='';;
57 *perld.*) perltype='-DDEBUGGING'; optdebug='-g' ;;
58 *perle.*) perltype='-DEMBED';;
59 *perlde.*) perltype='-DDEBUGGING -DEMBED'; optdebug='-g' ;;
60 *perlm.*) perltype='-DEMBED -DMULTIPLICITY';;
61 *perldm.*) perltype='-DDEBUGGING -DEMBED -DMULTIPLICITY'; optdebug='-g' ;;
62 esac
63 shift ;;
2b317908 64esac
1c3d792e 65
66also=': '
67case $# in
2b317908 681) also='echo 1>&2 " CCCMD = "'
1c3d792e 69esac
70
71case $# in
720) set *.c; echo "The current C flags are:" ;;
1c3d792e 73esac
2b317908 74
578789a7 75set `echo "$* " | sed -e 's/\.[oc] / /g' -e 's/\.obj / /g' -e "s/\\$obj_ext / /g"`
2b317908 76
1c3d792e 77for file do
78
79 case "$#" in
80 1) ;;
2b317908 81 *) echo $n " $file.c $c" ;;
1c3d792e 82 esac
83
2b317908 84 : allow variables like toke_cflags to be evaluated
85
8736538c 86 if echo $file | grep -v / >/dev/null
87 then
88 eval 'eval ${'"${file}_cflags"'-""}'
89 fi
2b317908 90
91 : or customize here
92
1c3d792e 93 case "$file" in
a0d0e21e 94 DB_File) ;;
95 GDBM_File) ;;
2304df62 96 NDBM_File) ;;
97 ODBM_File) ;;
98 POSIX) ;;
99 SDBM_File) ;;
100 av) ;;
4b6be2dd 101 byterun) ;;
2304df62 102 deb) ;;
103 dl) ;;
2b317908 104 doio) ;;
2304df62 105 doop) ;;
2b317908 106 dump) ;;
2304df62 107 gv) ;;
108 hv) ;;
a6ec74c1 109 locale) ;;
2304df62 110 main) ;;
2b317908 111 malloc) ;;
2304df62 112 mg) ;;
113 miniperlmain) ;;
a6ec74c1 114 numeric) ;;
2304df62 115 op) ;;
2b317908 116 perl) ;;
6f4183fe 117 perlapi) ;;
2304df62 118 perlmain) ;;
2b317908 119 perly) ;;
2304df62 120 pp) ;;
a0d0e21e 121 pp_ctl) ;;
122 pp_hot) ;;
a6ec74c1 123 pp_pack) ;;
a0d0e21e 124 pp_sys) ;;
2b317908 125 regcomp) ;;
126 regexec) ;;
2304df62 127 run) ;;
128 scope) ;;
129 sv) ;;
130 taint) ;;
2b317908 131 toke) ;;
132 usersub) ;;
133 util) ;;
1c3d792e 134 *) ;;
135 esac
136
a0d0e21e 137 if test "X$optdebug" != "X"; then
138 optimize="$optdebug"
139 fi
140
6a21b602 141# Add -Wall for the core and core modules iff gcc and not already -Wall
142warn=''
143case "$gccversion" in
144'') ;;
145*) case "$ccflags" in
146 *-Wall*) ;;
147# Can't add -ansi here because it will fail e.g. in Solaris.
148# Off_t/off_t is a struct in Solaris with largefiles, and with -ansi
149# that struct cannot be compared with a flat integer, such as a STRLEN.
150# The -ansi will also cause a lot of noise in Solaris because of:
151# /usr/include/sys/resource.h:148: warning: `struct rlimit64' declared inside parameter list
152 *) warn='-Wall' ;;
153 esac
154 ;;
155esac
156
c4f23d77 157 : Can we perhaps use $ansi2knr here
6a21b602 158 echo "$cc -c -DPERL_CORE $ccflags $optimize $warn $perltype"
159 eval "$also "'"$cc -DPERL_CORE -c $ccflags $optimize $warn $perltype"'
2b317908 160
a0d0e21e 161 . $TOP/config.sh
2b317908 162
1c3d792e 163done
2b317908 164!NO!SUBS!
a0d0e21e 165chmod 755 cflags
2b317908 166$eunicefix cflags