1#!/bin/sh
2
3# Extra warnings, used e.g. for gcc.
4warn="-Wall -ansi   -W -Wextra -Wdeclaration-after-statement -Wendif-labels -Wc++-compat"
5# Extra standardness.
6stdflags=" -std=c89"
7# Extra extra.
8extra=""
9
10# TODO - remove this Cross-config-xxx stuff
11
12case $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	;;
24esac
25
26: syntax: cflags [optimize=XXX] [file[.suffix]]
27: displays the compiler command line for file
28
29case "X$1" in
30Xoptimize=*|X"optimize=*")
31	eval "$1"
32	shift
33	;;
34esac
35
36also=': '
37case $# in
381) also='echo 1>&2 "	  CCCMD = "'
39esac
40
41case $# in
420) set *.c; echo "The current C flags are:" ;;
43esac
44
45set `echo "$* " | sed -e 's/\.[oc] / /g' -e "s/\.${CROSS_NAME}o / /g" -e 's/\.obj / /g' -e "s/\\$obj_ext / /g"`
46
47for 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    dquote) ;;
77    dump) ;;
78    globals) ;;
79    gv) ;;
80    hv) ;;
81    locale) ;;
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    time64) ;;
107    toke) ;;
108    universal) ;;
109    usersub) ;;
110    utf8) ;;
111    util) ;;
112    *) ;;
113    esac
114
115case "$cc" in
116*g++*)
117  # Extra paranoia in case people have bad canned ccflags:
118  # bad in the sense that the flags are accepted by g++,
119  # but then whined about.
120  for f in -Wdeclaration-after-statement -std=c89
121  do
122    ccflags=`echo $ccflags|sed 's/$f/ /'`
123  done
124  ;;
125esac
126
127case "$cc" in
128*g++*)
129  # Without -Wno-unused-variable g++ 4.x compiles are rather unwatchable
130  # because of all the warnings about Perl___notused, and g++ doesn't do
131  # __attribute__((unused)) (and even if at some stage it may, people do
132  # have older gcc installations), and ((void)x) isn't enough to silence
133  # the noises about XS functions not using their cv parameter, so we need
134  # the -Wno-unused-parameter too.
135  # Yes, we lose some valid warnings, but hopefully other compilers
136  # (like gcc) will still pick up those warnings.
137  for o in -Wno-unused-variable -Wno-unused-parameter
138  do
139    case "$warn" in
140    *$o*) ;;
141    *) warn="$warn $o" ;;
142    esac
143  done
144  ;;
145esac
146
147if test -f .patch; then
148  ccflags="-DPERL_PATCHNUM=`cat .patch` $ccflags"
149fi
150
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
156done
157