File: gnu-flags

package info (click to toggle)
libhdf4 4.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 30,384 kB
  • sloc: ansic: 128,700; sh: 15,015; fortran: 12,444; java: 5,863; xml: 1,205; makefile: 794; yacc: 678; pascal: 418; perl: 360; javascript: 203; lex: 163; csh: 41
file content (137 lines) | stat: -rw-r--r-- 4,404 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#                                                   -*- shell-script -*-
#
# This file is part of the HDF4 build script. It is processed shortly
# after configure starts and defines, among other things, flags for
# the various compilation modes.

#
# Prepend `$srcdir/config/gnu-warnings/` to the filename suffix(es) given as
# subroutine argument(s), remove comments starting with # and ending
# at EOL, replace spans of whitespace (including newlines) with spaces,
# and re-emit the file(s) thus filtered on the standard output stream.
#
load_gnu_arguments()
{
    set -- $(for arg; do
        sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg}
    done)
    IFS=' ' echo "$*"
}

# Get the compiler version in a way that works for gcc
# unless a compiler version is already known
#
#   cc_vendor:    The compiler name: gcc
#   cc_version:   Version number: 2.91.60, 2.7.2.1
#
if test "X-" = "X-$cc_flags_set"; then
    # PathScale compiler spits out gcc version string too. Need to
    # filter it out.
    # icc beginning with version 12 includes a "gcc version compatibility"
    # string, causing the gcc CFLAGS to be erroneously added.  The line
    # "grep -v 'icc version'" causes the discarding of any output
    # containing 'icc version'.  The cc_version for icc is correctly determined
    # and flags added in the intel-flags script.
    cc_version="`$CC $CFLAGS -v 2>&1 | grep -v 'PathScale' |\
        grep -v '^icc.*version' |\
        grep 'gcc version' | sed 's/.*gcc version \([-a-z0-9\.]*\).*/\1/'`"
    cc_vendor=`echo $cc_version |sed 's/\([a-z]*\).*/\1/'`
    cc_version=`echo $cc_version |sed 's/[-a-z]//g'`
    if test X = "X$cc_vendor" -a X != "X$cc_version"; then
        cc_vendor=gcc
    fi
    if test "-" != "$cc_vendor-$cc_version"; then
        echo "compiler '$CC' is GNU $cc_vendor-$cc_version"
    fi

    # Get the compiler version numbers
    cc_vers_major=`echo $cc_version | cut -f1 -d.`
    cc_vers_minor=`echo $cc_version | cut -f2 -d.`
    cc_vers_patch=`echo $cc_version | cut -f3 -d.`
    test -n "$cc_vers_major" || cc_vers_major=0
    test -n "$cc_vers_minor" || cc_vers_minor=0
    test -n "$cc_vers_patch" || cc_vers_patch=0
fi

if test "X-gcc" = "X-$cc_vendor"; then

    CFLAGS="$CFLAGS -std=c99"
    if test $cc_vers_major -ge 10; then
        CFLAGS="$CFLAGS -Wno-error=implicit-function-declaration"
    else
        CFLAGS="$CFLAGS"
    fi
    DEBUG_CFLAGS="-g -fverbose-asm"
    DEBUG_CPPFLAGS=
    PROD_CFLAGS="-O3 -fomit-frame-pointer"
    PROD_CPPFLAGS=
    PROFILE_CFLAGS="-pg"
    PROFILE_CPPFLAGS=

    ####################
    # General warnings #
    ####################

    # Add various general warning flags in gnu-warnings for gcc versions 4.8 and later.
    if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 8 -o $cc_vers_major -gt 4; then
        CFLAGS="$CFLAGS $(load_gnu_arguments general)"
        CFLAGS="$CFLAGS $(load_gnu_arguments no-developer-general)"
    fi

    #############################
    # Version-specific warnings #
    #############################

    # gcc >= 4.8
    if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 8; then
        CFLAGS="$CFLAGS $(load_gnu_arguments 4.8)"
        CFLAGS="$CFLAGS $(load_gnu_arguments no-developer-4.8)"
    fi

    # gcc >= 4.9
    if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 9; then
        CFLAGS="$CFLAGS $(load_gnu_arguments 4.9)"
    fi

    # gcc >= 5
    if test $cc_vers_major -ge 5; then
        CFLAGS="$CFLAGS $(load_gnu_arguments 5)"
    fi

    # gcc >= 6
    if test $cc_vers_major -ge 6; then
        CFLAGS="$CFLAGS $(load_gnu_arguments 6)"
    fi

    # gcc >= 7
    if test $cc_vers_major -ge 7; then
        CFLAGS="$CFLAGS $(load_gnu_arguments 7)"
    fi

    # gcc 8
    if test $cc_vers_major -ge 8; then
        CFLAGS="$CFLAGS $(load_gnu_arguments 8)"
        CFLAGS="$CFLAGS $(load_gnu_arguments no-developer-8)"
    fi

    # gcc 9
    if test $cc_vers_major -ge 9; then
        CFLAGS="$CFLAGS $(load_gnu_arguments 9)"
    fi

    # gcc >= 9.3
    if test $cc_vers_major -ge 10 -o $cc_vers_major -eq 9 -a $cc_vers_minor -ge 3; then
        CFLAGS="$CFLAGS $(load_gnu_arguments 9.3)"
    fi

    #################
    # Flags are set #
    #################
    cc_flags_set=yes
fi

# Clear cc info if no flags set
if test "X$cc_flags_set" = "X"; then
    cc_vendor=
    cc_version=
fi