aboutsummaryrefslogtreecommitdiff
path: root/sntp/m4/ntp_harden.m4
blob: 06aebc08e5ee92afa0a761158bd7d4ee153a858d (plain) (blame)
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
dnl ######################################################################
dnl @synopsis NTP_HARDEN([SCRIPTSDIRPATH])
dnl Build (compile/link) hardening information:
dnl - NTP_HARD_CFLAGS
dnl - NTP_HARD_CPPFLAGS
dnl - NTP_HARD_LDFLAGS

AC_DEFUN([NTP_HARDEN], [

AC_MSG_CHECKING([for compile/link hardening flags])

AC_ARG_WITH(
    [hardenfile],
    [AS_HELP_STRING(
	[--with-hardenfile=XXX],
	[os-specific or "/dev/null"]
    )],
    [],
    [with_hardenfile=no]
)

(									\
    SENTINEL_DIR="$PWD" &&						\
    cd $srcdir/$1 &&							\
    case "$with_hardenfile" in						\
     yes|no|'')								\
	scripts/genHardFlags -d "$SENTINEL_DIR"				\
	;;								\
     *)									\
	scripts/genHardFlags -d "$SENTINEL_DIR" -f "$with_hardenfile"	\
	;;								\
    esac								\
) > genHardFlags.i 2> genHardFlags.err
. ./genHardFlags.i

case "$GENHARDFLAG" in
 OK)
    AC_MSG_RESULT([in file $GENHARDFLAGFILE])
    rm genHardFlags.err genHardFlags.i
    ;;
 *)
    AC_MSG_RESULT([failed.])
    AC_MSG_ERROR([Problem with genHardFlags!])
    ;;
esac

AC_SUBST([NTP_HARD_CFLAGS])
AC_SUBST([NTP_HARD_CPPFLAGS])
AC_SUBST([NTP_HARD_LDFLAGS])

])dnl
dnl ======================================================================