forked from tpm2-software/tpm2-abrmd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
162 lines (148 loc) · 6.08 KB
/
configure.ac
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
153
154
155
156
157
158
159
160
161
162
# SPDX-License-Identifier: BSD-2
AC_INIT([tpm2-abrmd],
[m4_esyscmd_s([cat ./VERSION])],
[https://github.com/tpm2-software/tpm2-abrmd/issues],
[],
[https://github.com/tpm2-software/tpm2-abrmd])
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_CC
AC_PROG_LN_S
LT_INIT()
AM_INIT_AUTOMAKE([foreign subdir-objects])
# enable "silent-rules" option by default
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CONFIG_FILES([Makefile])
# propagate configure arguments to distcheck
AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],[$ac_configure_args])
AX_PTHREAD([], [AC_MSG_ERROR([requires pthread])])
AC_ARG_ENABLE([unit],
[AS_HELP_STRING([--enable-unit],
[build cmocka unit tests])],,
[enable_unit=no])
AS_IF([test "x$enable_unit" != xno],
[PKG_CHECK_MODULES([CMOCKA],
[cmocka >= 1.0],
[AC_DEFINE([HAVE_CMOCKA],
[1],
[cmocka is available])])])
AM_CONDITIONAL([UNIT], [test "x$enable_unit" != xno])
# -dl or -dld
AC_SEARCH_LIBS([dlopen], [dl dld], [], [
AC_MSG_ERROR([unable to find the dlopen() function])
])
PKG_CHECK_MODULES([DBUS], [dbus-1])
PKG_CHECK_MODULES([GIO], [gio-unix-2.0])
PKG_CHECK_MODULES([GLIB], [glib-2.0])
PKG_CHECK_MODULES([GOBJECT], [gobject-2.0])
PKG_CHECK_MODULES([TSS2_SYS],[tss2-sys >= 2.0.0])
AC_ARG_VAR([GDBUS_CODEGEN],[The gdbus-codegen executable.])
AC_CHECK_PROG([GDBUS_CODEGEN], [gdbus-codegen], [gdbus-codegen])
AS_IF([test ! -x "$(which $GDBUS_CODEGEN)"],
[AC_MSG_ERROR([*** gdbus-codegen is required to build tpm2-abrmd])])
AX_CODE_COVERAGE
m4_ifdef([_AX_CODE_COVERAGE_RULES],
[AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
[AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
AX_ADD_AM_MACRO_STATIC([])
# disable helgrind and drd, they hate GAsyncQueue
AX_VALGRIND_DFLT([sgcheck], [off])
AX_VALGRIND_DFLT([helgrind], [off])
AX_VALGRIND_DFLT([drd], [off])
AX_VALGRIND_CHECK
# allow
AC_ARG_ENABLE([dlclose],
[AS_HELP_STRING([--disable-dlclose],
[Some versions of libc cause a sigsegv on exit, this disables the dlclose and works around that bug])],
[AC_DEFINE([DISABLE_DLCLOSE], [1])]
)
# function from the gnu.org docs
AC_DEFUN([MY_ARG_WITH],
[AC_ARG_WITH(m4_translit([[$1]], [_], [-]),
[AS_HELP_STRING([--with-m4_translit([$1], [_], [-])],
[use $1 (default is $2)])],
[use_[]$1=$withval],
[use_[]$1=$2])
])
#
# systemd
#
AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
[Directory for systemd service files]),,
[with_systemdsystemunitdir=${libdir}/systemd/system])
AS_IF([test "x$with_systemdsystemunitdir" != xno],
[AC_SUBST([systemdsystemunitdir],
[$with_systemdsystemunitdir])])
AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
# systemd preset directory
AC_ARG_WITH([systemdpresetdir],
AS_HELP_STRING([--with-systemdpresetdir=DIR],
[Directory for systemd preset files]),,
[with_systemdpresetdir=${libdir}/systemd/system-preset])
AC_SUBST([systemdpresetdir], [$with_systemdpresetdir])
# systemd preset default (enable / disable)
AC_ARG_WITH([systemdpresetdisable],
AS_HELP_STRING([--with-systemdpresetdisable],
[Configure systemd preset to 'disable', default is 'enable']),
[AC_SUBST([SYSTEMD_PRESET_DEFAULT],[disable])],
[AC_SUBST([SYSTEMD_PRESET_DEFAULT],[enable])])
#
# dbus
#
AC_ARG_WITH([dbuspolicydir],
[AS_HELP_STRING([--with-dbuspolicydir=DIR],[D-Bus policy directory])],,
[with_dbuspolicydir=${sysconfdir}/dbus-1/system.d])
AX_NORMALIZE_PATH([with_dbuspolicydir])
AC_SUBST([dbuspolicydir], [$with_dbuspolicydir])
#
# Real TPM hardware
#
AC_ARG_ENABLE([test-hwtpm],
[AS_HELP_STRING([--enable-test-hwtpm],
[enable the integration test on a real tpm hardware])],
[enable_integration=$enableval],
[enable_test_hwtpm=no])
AM_CONDITIONAL([HWTPM], [test "x$enable_test_hwtpm" != xno])
#
# enable integration tests and check for simulator binary
#
AC_ARG_ENABLE([integration],
[AS_HELP_STRING([--enable-integration],
[build and execute integration tests])],,
[enable_integration=no])
AS_IF([test \( "x$enable_integration" = "xyes" \) -a \( "x$enable_test_hwtpm" = "xno" \)],
[AC_CHECK_PROG([tpm_server], [tpm_server], [yes], [no])
AS_IF([test "x$tpm_server" != "xyes"],
[AC_MSG_ERROR([Integration tests enabled but tpm_server not found, try setting PATH])])
AC_SUBST([ENABLE_INTEGRATION],[$enable_integration])
AC_MSG_NOTICE([Integration tests will be executed against the TPM2 simulator.])],
[AC_MSG_NOTICE([Integration tests will be executed against the TPM device.])])
AM_CONDITIONAL([ENABLE_INTEGRATION],[test "x$enable_integration" = "xyes"])
# preprocessor / compiler / linker flags
# these macros are defined in m4/flags.m4
AX_ADD_COMPILER_FLAG([-Wall])
AX_ADD_COMPILER_FLAG([-Wextra])
AX_ADD_COMPILER_FLAG([-Werror])
AX_ADD_COMPILER_FLAG([-std=gnu99])
AX_ADD_COMPILER_FLAG([-Wformat])
AX_ADD_COMPILER_FLAG([-Wformat-security])
AX_ADD_COMPILER_FLAG([-Wno-missing-braces])
# work around for Glib usage of function pointers type casting
# https://bugzilla.gnome.org/show_bug.cgi?id=793272
AX_ADD_COMPILER_FLAG([-Wno-cast-function-type])
AX_ADD_COMPILER_FLAG([-fdata-sections])
AX_ADD_COMPILER_FLAG([-ffunction-sections])
AX_ADD_TOOLCHAIN_FLAG([-fstack-protector-all])
AX_ADD_COMPILER_FLAG([-fpic])
AX_ADD_COMPILER_FLAG([-fPIC])
AX_ADD_COMPILER_FLAG([-Wstrict-overflow=5])
AX_ADD_PREPROC_FLAG([-D_GNU_SOURCE])
AX_ADD_PREPROC_FLAG([-U_FORTIFY_SOURCE])
AX_ADD_PREPROC_FLAG([-D_FORTIFY_SOURCE=2])
AX_ADD_LINK_FLAG([-Wl,--gc-sections])
AX_ADD_LINK_FLAG([-Wl,--no-undefined])
AX_ADD_LINK_FLAG([-Wl,-z,noexecstack])
AX_ADD_LINK_FLAG([-Wl,-z,now])
AX_ADD_LINK_FLAG([-Wl,-z,relro])
AC_SUBST([PATH])
AC_OUTPUT