This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Extract a constructor.
[perl5.git] / Cross / cflags-cross-arm
1 #!/bin/sh
2
3 # Extra warnings, used e.g. for gcc.
4 warn="-Wall -ansi   -W -Wextra -Wdeclaration-after-statement -Wendif-labels -Wc++-compat"
5 # Extra standardness.
6 stdflags=" -std=c89"
7 # Extra extra.
8 extra=""
9
10 # TODO - remove this Cross-config-xxx stuff
11
12 case $PERL_CONFIG_SH in
13 '')
14         if test -f Cross/config-arm.sh; then TOP=.;
15         elif test -f ../Cross/config-arm.sh; then TOP=..;
16         elif test -f ../../Cross/config-arm.sh; then TOP=../..;
17         elif test -f ../../../Cross/config-arm.sh; then TOP=../../..;
18         elif test -f ../../../../Cross/config-arm.sh; then TOP=../../../..;
19         else
20                 echo "Can't find config-arm.sh."; exit 1
21         fi
22         . $TOP/Cross/config-arm.sh
23         ;;
24 esac
25
26 : syntax: cflags [optimize=XXX] [file[.suffix]]
27 : displays the compiler command line for file
28
29 case "X$1" in
30 Xoptimize=*|X"optimize=*")
31         eval "$1"
32         shift
33         ;;
34 esac
35
36 also=': '
37 case $# in
38 1) also='echo 1>&2 "      CCCMD = "'
39 esac
40
41 case $# in
42 0) set *.c; echo "The current C flags are:" ;;
43 esac
44
45 set `echo "$* " | sed -e 's/\.[oc] / /g' -e "s/\.${CROSS_NAME}o / /g" -e 's/\.obj / /g' -e "s/\\$obj_ext / /g"`
46
47 for file do
48
49     case "$#" in
50     1) extra="-o $file.${CROSS_NAME}o $extra";;
51     *) echo $n "    $file.c     $c" ;;
52     esac
53
54     : allow variables like toke_cflags to be evaluated
55
56     if echo $file | grep -v / >/dev/null
57     then
58       eval 'eval ${'"${file}_cflags"'-""}'
59     fi
60
61     : or customize here
62
63     case "$file" in
64     DB_File) ;;
65     GDBM_File) ;;
66     NDBM_File) ;;
67     ODBM_File) ;;
68     POSIX) ;;
69     SDBM_File) ;;
70     av) ;;
71     byterun) ;;
72     deb) ;;
73     dl) ;;
74     doio) ;;
75     doop) ;;
76     dump) ;;
77     globals) ;;
78     gv) ;;
79     hv) ;;
80     locale) ;;
81     madly) ;;
82     main) ;;
83     malloc) ;;
84     mg) ;;
85     miniperlmain) ;;
86     numeric) ;;
87     op) ;;
88     opmini) ;;
89     pad) ;;
90     perl) ;;
91     perlapi) ;;
92     perlmain) ;;
93     perly) ;;
94     pp) ;;
95     pp_ctl) ;;
96     pp_hot) ;;
97     pp_pack) ;;
98     pp_sort) ;;
99     pp_sys) ;;
100     regcomp) ;;
101     regexec) ;;
102     run) ;;
103     scope) ;;
104     sv) ;;
105     taint) ;;
106     toke) ;;
107     universal) ;;
108     usersub) ;;
109     utf8) ;;
110     util) ;;
111     *) ;;
112     esac
113
114 case "$cc" in
115 *g++*)
116   # Extra paranoia in case people have bad canned ccflags:
117   # bad in the sense that the flags are accepted by g++,
118   # but then whined about.
119   for f in -Wdeclaration-after-statement -std=c89
120   do
121     ccflags=`echo $ccflags|sed 's/$f/ /'`
122   done
123   ;;
124 esac
125
126 case "$cc" in
127 *g++*)
128   # Without -Wno-unused-variable g++ 4.x compiles are rather unwatchable
129   # because of all the warnings about Perl___notused, and g++ doesn't do
130   # __attribute__((unused)) (and even if at some stage it may, people do
131   # have older gcc installations), and ((void)x) isn't enough to silence
132   # the noises about XS functions not using their cv parameter, so we need
133   # the -Wno-unused-parameter too.
134   # Yes, we lose some valid warnings, but hopefully other compilers
135   # (like gcc) will still pick up those warnings.
136   for o in -Wno-unused-variable -Wno-unused-parameter
137   do
138     case "$warn" in
139     *$o*) ;;
140     *) warn="$warn $o" ;;
141     esac
142   done
143   ;;
144 esac
145
146 if test -f .patch; then
147   ccflags="-DPERL_PATCHNUM=`cat .patch` $ccflags"
148 fi
149
150     : Can we perhaps use $ansi2knr here
151     echo "$CROSSCC -c -DUSE_CROSS_COMPILE -DPERL_CORE $ccflags $stdflags $optimize $warn $extra"
152     eval "$also "'"$CROSSCC -DUSE_CROSS_COMPILE -DPERL_CORE -c $ccflags $stdflags $optimize $warn $extra"'
153
154     . $TOP/Cross/config-arm.sh
155
156 done