Upgrade to Archive-Tar-1.30. Since change #27571 is not included,
[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
bc730b18 19
20warn=''
21
22# Add -Wall for the core modules iff gcc and not already -Wall
23case "$gccversion" in
24'') ;;
25Intel*) ;; # The Intel C++ plays gcc on TV but is not really it.
26*) case "$ccflags" in
27 *-Wall*) ;;
28 *) warn="$warn -Wall" ;;
29 esac
30 ;;
31esac
32
33# The gcc -ansi -pedantic require their own dance, too.
34case "$gccversion" in
35'') ;;
11fcce85 36Intel*) ;; # Is that you, Intel C++?
bc730b18 37*) case "$gccansipedantic" in
38 define)
39 case "$gccversion" in
40 [12]*) ;; # gcc versions 1 (gasp!) and 2 are not good for this.
41 *) case "$osname" in
42 # Add -ansi -pedantic only for known platforms.
43 aix|dec_osf|freebsd|hpux|irix|linux)
44 ansipedantic="-ansi -pedantic" ;;
45 solaris)
46# Can't add -ansi for Solaris.
47# Off_t/off_t is a struct in Solaris with largefiles, and with -ansi
48# that struct cannot be compared with a flat integer, such as a STRLEN.
49# The -ansi will also cause a lot of noise in Solaris because of:
50# /usr/include/sys/resource.h:148: warning: `struct rlimit64' declared inside parameter list
51 ansipedantic="-pedantic" ;;
52 esac
53 for i in $ansipedantic
54 do
55 case "$ccflags" in
56 *$i*) ;;
57 *) warn="$warn $i" ;;
58 esac
59 done
60 case "$warn$ccflags" in
61 *-pedantic*) warn="$warn -DPERL_GCC_PEDANTIC" ;;
62 esac
63 ;;
64 esac
65 ;;
66 esac
67 ;;
68esac
69
70# Further gcc warning options.
71case "$gccversion" in
72'') ;;
9ab92c42 73[12]*) ;;
11fcce85 74Intel*) ;; # Haven't we been through this already?
bc730b18 75*) for opt in '' extra declaration-after-statement endif-labels
76 do
77 case " $ccflags " in
78 *"-W$opt "*) ;;
79 *) case "`echo >_cflags.c | $cc -W$opt -c _cflags.c -o _cflags.o 2>&1`" in
80 *"unrecognized"*) ;;
81 *"Invalid"*) ;;
82 *) warn="$warn -W$opt" ;;
83 esac
84 ;;
85 esac
86 rm -f _cflags.c cflags.o
87 done
88 ;;
89esac
90
b1e55cab 91# If we have g++, we cannot have the -Wdeclaration-after-statement.
92# Some g++s accept it but then whine about it with every file.
93case "$cc" in
94*g++*) warn="`echo $warn|sed 's/-Wdeclaration-after-statement/ /'`" ;;
95esac
96
97extra=''
98
99# C and C++ have different rules for const strings;
100# without the -fno-const-strings g++ cannot handle our habit
101# of mixing char literals and char pointers.
102case "$cc" in
103*g++*) extra="$extra -fno-const-strings" ;;
104esac
11fcce85 105
106stdflags=''
107
2b317908 108echo "Extracting cflags (with variable substitutions)"
109: This section of the file will have variable substitutions done on it.
110: Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!.
111: Protect any dollar signs and backticks that you do not want interpreted
112: by putting a backslash in front. You may delete these comments.
165b7424 113rm -f cflags
2b317908 114$spitshell >cflags <<!GROK!THIS!
ecfc5424 115$startsh
bc730b18 116
11fcce85 117# Extra warnings, used e.g. for gcc.
bc730b18 118warn="$warn"
11fcce85 119# Extra standardness.
120stdflags="$stdflags"
b1e55cab 121# Extra extra.
122extra="$extra"
bc730b18 123
2b317908 124!GROK!THIS!
125
126: In the following dollars and backticks do not need the extra backslash.
127$spitshell >>cflags <<'!NO!SUBS!'
a02608de 128case $PERL_CONFIG_SH in
2b317908 129'')
a0d0e21e 130 if test -f config.sh; then TOP=.;
131 elif test -f ../config.sh; then TOP=..;
132 elif test -f ../../config.sh; then TOP=../..;
133 elif test -f ../../../config.sh; then TOP=../../..;
134 elif test -f ../../../../config.sh; then TOP=../../../..;
135 else
136 echo "Can't find config.sh."; exit 1
137 fi
138 . $TOP/config.sh
139 ;;
140esac
141
75550b4e 142: syntax: cflags [optimize=XXX] [file[.suffix]]
143: displays the compiler command line for file
144
1167a30e 145case "X$1" in
26102cc7 146Xoptimize=*|X"optimize=*")
1167a30e 147 eval "$1"
148 shift
149 ;;
150esac
151
1c3d792e 152also=': '
153case $# in
2b317908 1541) also='echo 1>&2 " CCCMD = "'
1c3d792e 155esac
156
157case $# in
1580) set *.c; echo "The current C flags are:" ;;
1c3d792e 159esac
2b317908 160
578789a7 161set `echo "$* " | sed -e 's/\.[oc] / /g' -e 's/\.obj / /g' -e "s/\\$obj_ext / /g"`
2b317908 162
1c3d792e 163for file do
164
165 case "$#" in
166 1) ;;
2b317908 167 *) echo $n " $file.c $c" ;;
1c3d792e 168 esac
169
2b317908 170 : allow variables like toke_cflags to be evaluated
171
8736538c 172 if echo $file | grep -v / >/dev/null
173 then
174 eval 'eval ${'"${file}_cflags"'-""}'
175 fi
2b317908 176
177 : or customize here
178
1c3d792e 179 case "$file" in
a0d0e21e 180 DB_File) ;;
181 GDBM_File) ;;
2304df62 182 NDBM_File) ;;
183 ODBM_File) ;;
184 POSIX) ;;
185 SDBM_File) ;;
186 av) ;;
4b6be2dd 187 byterun) ;;
2304df62 188 deb) ;;
189 dl) ;;
2b317908 190 doio) ;;
2304df62 191 doop) ;;
2b317908 192 dump) ;;
59bea8cf 193 globals) ;;
2304df62 194 gv) ;;
195 hv) ;;
a6ec74c1 196 locale) ;;
59bea8cf 197 madly) ;;
2304df62 198 main) ;;
2b317908 199 malloc) ;;
2304df62 200 mg) ;;
201 miniperlmain) ;;
a6ec74c1 202 numeric) ;;
2304df62 203 op) ;;
59bea8cf 204 opmini) ;;
205 pad) ;;
2b317908 206 perl) ;;
6f4183fe 207 perlapi) ;;
2304df62 208 perlmain) ;;
2b317908 209 perly) ;;
2304df62 210 pp) ;;
a0d0e21e 211 pp_ctl) ;;
212 pp_hot) ;;
a6ec74c1 213 pp_pack) ;;
59bea8cf 214 pp_sort) ;;
a0d0e21e 215 pp_sys) ;;
2b317908 216 regcomp) ;;
217 regexec) ;;
2304df62 218 run) ;;
219 scope) ;;
220 sv) ;;
221 taint) ;;
2b317908 222 toke) ;;
59bea8cf 223 universal) ;;
2b317908 224 usersub) ;;
59bea8cf 225 utf8) ;;
2b317908 226 util) ;;
59bea8cf 227 xsutils) ;;
1c3d792e 228 *) ;;
229 esac
230
69c7f294 231if test -f .patch; then
232 ccflags="-DPERL_PATCHNUM=`cat .patch` $ccflags"
233fi
234
c4f23d77 235 : Can we perhaps use $ansi2knr here
b1e55cab 236 echo "$cc -c -DPERL_CORE $ccflags $stdflags $optimize $warn $extra"
237 eval "$also "'"$cc -DPERL_CORE -c $ccflags $stdflags $optimize $warn $extra"'
2b317908 238
a0d0e21e 239 . $TOP/config.sh
2b317908 240
1c3d792e 241done
2b317908 242!NO!SUBS!
a0d0e21e 243chmod 755 cflags
2b317908 244$eunicefix cflags