This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
More cleanups. (What's PERL_DECL_PROT?)
[perl5.git] / cflags.SH
1 case $PERL_CONFIG_SH 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 !GROK!THIS!
28
29 : In the following dollars and backticks do not need the extra backslash.
30 $spitshell >>cflags <<'!NO!SUBS!'
31 case $PERL_CONFIG_SH in
32 '')
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         ;;
43 esac
44
45 case "X$1" in
46 Xoptimize=*|X"optimize=*")
47         eval "$1"
48         shift
49         ;;
50 esac
51
52 perltype=''
53 optdebug=''     # ensure -g used if building a -DDEBUGGING libperl
54 case $# in
55 2) 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 ;;
64 esac
65
66 also=': '
67 case $# in
68 1) also='echo 1>&2 "      CCCMD = "'
69 esac
70
71 case $# in
72 0) set *.c; echo "The current C flags are:" ;;
73 esac
74
75 set `echo "$* " | sed -e 's/\.[oc] / /g' -e 's/\.obj / /g' -e "s/\\$obj_ext / /g"`
76
77 for file do
78
79     case "$#" in
80     1) ;;
81     *) echo $n "    $file.c     $c" ;;
82     esac
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     locale) ;;
110     main) ;;
111     malloc) ;;
112     mg) ;;
113     miniperlmain) ;;
114     numeric) ;;
115     op) ;;
116     perl) ;;
117     perlapi) ;;
118     perlmain) ;;
119     perly) ;;
120     pp) ;;
121     pp_ctl) ;;
122     pp_hot) ;;
123     pp_pack) ;;
124     pp_sys) ;;
125     regcomp) ;;
126     regexec) ;;
127     run) ;;
128     scope) ;;
129     sv) ;;
130     taint) ;;
131     toke) ;;
132     usersub) ;;
133     util) ;;
134     *) ;;
135     esac
136
137         if test "X$optdebug" != "X"; then
138                 optimize="$optdebug"
139         fi
140
141 # Add -Wall for the core and core modules iff gcc and not already -Wall
142 warn=''
143 case "$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     ;;
155 esac
156
157     : Can we perhaps use $ansi2knr here
158     echo "$cc -c -DPERL_CORE $ccflags $optimize $warn $perltype"
159     eval "$also "'"$cc -DPERL_CORE -c $ccflags $optimize $warn $perltype"'
160
161     . $TOP/config.sh
162
163 done
164 !NO!SUBS!
165 chmod 755 cflags
166 $eunicefix cflags