Debian Codegraph @

config/gnu-flags

raw
1 # -*- shell-script -*-
2 #
3 # This file is part of the HDF4 build script. It is processed shortly
4 # after configure starts and defines, among other things, flags for
5 # the various compilation modes.
6
7 #
8 # Prepend `$srcdir/config/gnu-warnings/` to the filename suffix(es) given as
9 # subroutine argument(s), remove comments starting with # and ending
10 # at EOL, replace spans of whitespace (including newlines) with spaces,
11 # and re-emit the file(s) thus filtered on the standard output stream.
12 #
13 load_gnu_arguments()
14 {
15 set -- $(for arg; do
16 sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg}
17 done)
18 IFS=' ' echo "$*"
19 }
20
21 # Get the compiler version in a way that works for gcc
22 # unless a compiler version is already known
23 #
24 # cc_vendor: The compiler name: gcc
25 # cc_version: Version number: 2.91.60, 2.7.2.1
26 #
27 if test "X-" = "X-$cc_flags_set"; then
28 # PathScale compiler spits out gcc version string too. Need to
29 # filter it out.
30 # icc beginning with version 12 includes a "gcc version compatibility"
31 # string, causing the gcc CFLAGS to be erroneously added. The line
32 # "grep -v 'icc version'" causes the discarding of any output
33 # containing 'icc version'. The cc_version for icc is correctly determined
34 # and flags added in the intel-flags script.
35 cc_version="`$CC $CFLAGS -v 2>&1 | grep -v 'PathScale' |\
36 grep -v '^icc.*version' |\
37 grep 'gcc version' | sed 's/.*gcc version \([-a-z0-9\.]*\).*/\1/'`"
38 cc_vendor=`echo $cc_version |sed 's/\([a-z]*\).*/\1/'`
39 cc_version=`echo $cc_version |sed 's/[-a-z]//g'`
40 if test X = "X$cc_vendor" -a X != "X$cc_version"; then
41 cc_vendor=gcc
42 fi
43 if test "-" != "$cc_vendor-$cc_version"; then
44 echo "compiler '$CC' is GNU $cc_vendor-$cc_version"
45 fi
46
47 # Get the compiler version numbers
48 cc_vers_major=`echo $cc_version | cut -f1 -d.`
49 cc_vers_minor=`echo $cc_version | cut -f2 -d.`
50 cc_vers_patch=`echo $cc_version | cut -f3 -d.`
51 test -n "$cc_vers_major" || cc_vers_major=0
52 test -n "$cc_vers_minor" || cc_vers_minor=0
53 test -n "$cc_vers_patch" || cc_vers_patch=0
54 fi
55
56 if test "X-gcc" = "X-$cc_vendor"; then
57
58 CFLAGS="$CFLAGS -std=c99"
59 if test $cc_vers_major -ge 10; then
60 CFLAGS="$CFLAGS -Wno-error=implicit-function-declaration"
61 else
62 CFLAGS="$CFLAGS"
63 fi
64 DEBUG_CFLAGS="-g -fverbose-asm"
65 DEBUG_CPPFLAGS=
66 PROD_CFLAGS="-O3 -fomit-frame-pointer"
67 PROD_CPPFLAGS=
68 PROFILE_CFLAGS="-pg"
69 PROFILE_CPPFLAGS=
70
71 ####################
72 # General warnings #
73 ####################
74
75 # Add various general warning flags in gnu-warnings for gcc versions 4.8 and later.
76 if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 8 -o $cc_vers_major -gt 4; then
77 CFLAGS="$CFLAGS $(load_gnu_arguments general)"
78 CFLAGS="$CFLAGS $(load_gnu_arguments no-developer-general)"
79 fi
80
81 #############################
82 # Version-specific warnings #
83 #############################
84
85 # gcc >= 4.8
86 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 8; then
87 CFLAGS="$CFLAGS $(load_gnu_arguments 4.8)"
88 CFLAGS="$CFLAGS $(load_gnu_arguments no-developer-4.8)"
89 fi
90
91 # gcc >= 4.9
92 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 9; then
93 CFLAGS="$CFLAGS $(load_gnu_arguments 4.9)"
94 fi
95
96 # gcc >= 5
97 if test $cc_vers_major -ge 5; then
98 CFLAGS="$CFLAGS $(load_gnu_arguments 5)"
99 fi
100
101 # gcc >= 6
102 if test $cc_vers_major -ge 6; then
103 CFLAGS="$CFLAGS $(load_gnu_arguments 6)"
104 fi
105
106 # gcc >= 7
107 if test $cc_vers_major -ge 7; then
108 CFLAGS="$CFLAGS $(load_gnu_arguments 7)"
109 fi
110
111 # gcc 8
112 if test $cc_vers_major -ge 8; then
113 CFLAGS="$CFLAGS $(load_gnu_arguments 8)"
114 CFLAGS="$CFLAGS $(load_gnu_arguments no-developer-8)"
115 fi
116
117 # gcc 9
118 if test $cc_vers_major -ge 9; then
119 CFLAGS="$CFLAGS $(load_gnu_arguments 9)"
120 fi
121
122 # gcc >= 9.3
123 if test $cc_vers_major -ge 10 -o $cc_vers_major -eq 9 -a $cc_vers_minor -ge 3; then
124 CFLAGS="$CFLAGS $(load_gnu_arguments 9.3)"
125 fi
126
127 #################
128 # Flags are set #
129 #################
130 cc_flags_set=yes
131 fi
132
133 # Clear cc info if no flags set
134 if test "X$cc_flags_set" = "X"; then
135 cc_vendor=
136 cc_version=
137 fi