summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/sntp/scripts/genHardFlags
blob: 5e41cba374ecb92e163b78cf4b9c367de701a665 (plain)
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#! /bin/sh

args=`getopt d:f:v $*`
set -- $args

HF=
V=": "

for i
do
    case "$i" in
     -d) sdir="$2" ; shift 2 ;;
     -f) hardenfile="$2" ; shift 2 ;;
     -v) V= ; shift ;;
     --) shift ; break ;;
    esac
done

case "$sdir" in
 '')
    sdir=.
esac

case "$hardenfile" in
 */*)
    HF=$hardenfile
    ;;
 '')
    ;;
 *)
    hf=harden/$hardenfile
    if test -f $hf
    then
	HF=$hf
    fi
    ;;
esac

# If we have a file to use (ie, HF is not empty) then look for one.
case "$HF" in
 '')
    PATH=$PATH:libevent/build-aux
    export PATH
    set `scripts/cvo.sh @osname@ @osver@` || exit 1

    CVO_OSNAME=$1
    CVO_OSVER=$2

    x=$CVO_OSVER

    while true
    do
	case "$x" in
	 '') break ;;
	esac
hf=harden/$CVO_OSNAME$x
${V}echo "Looking for <$hf>" >&2
	if test -f $hf
	then
	    HF=$hf
	    break
	fi
	case "$x" in
	 *.*) x=`echo $x | sed -e 's/\.[^.]*$//'` ;;
	 *) x= ;;
	esac
    done
    case "$HF" in
     '')
	hf=harden/$CVO_OSNAME
${V}echo "Looking for <$hf>" >&2
	if test -f $hf
	then
	    HF=$hf
	fi
	;;
    esac
    # Handle some "aliases"
    case "$HF" in
     '')
	case "$CVO_OSNAME" in
	 raspbian*)
	    hf=harden/debian
${V}echo "Looking for <$hf>" >&2
	    if test -f $hf
	    then
		HF=$hf
	    fi
	    ;;
	 redhat* | fedora*)
	    hf=harden/redhat
${V}echo "Looking for <$hf>" >&2
	    if test -f $hf
	    then
		HF=$hf
	    fi
	    ;;
	esac
	;;
    esac

    # This might be a good place to see if uname returns "Linux",
    # and if so, use a generic file for that.
    case "$HF" in
     '')
	case "`uname`" in
	 Linux)
	    hf=harden/linux
${V}echo "Looking for <$hf>" >&2
	    if test -f $hf
	    then
		HF=$hf
	    fi
	    ;;
	esac
	;;
    esac

    # Finally, 'default'
    case "$HF" in
     '')
	hf=harden/default
${V}echo "Looking for <$hf>" >&2
	if test -f $hf
	then
	    HF=$hf
	fi
	;;
    esac

    case "$HF" in
     '')
	echo "No harden/XXX file found!" >&2
	exit 1
	;;
    esac
    ;;
esac

${V}echo "Using <$HF>" >&2
echo "GENHARDFLAGFILE=$HF"

###

. $HF

echo "NTP_HARD_CFLAGS='$NTP_HARD_CFLAGS'"
echo "NTP_HARD_CPPFLAGS='$NTP_HARD_CPPFLAGS'"
echo "NTP_HARD_LDFLAGS='$NTP_HARD_LDFLAGS'"
echo GENHARDFLAG=OK

exit 0
OpenPOWER on IntegriCloud