blob: b9428f639a2b0dc835066cb945bbfde49222e38b [file] [log] [blame]
Jacob Appelbaumeb1bcf62013-01-18 15:23:19 +01001AC_INIT([tlsdate],[0.0.5],[jacob at appelbaum.net])
Brian Aker95d9fd52012-10-15 22:44:03 -04002AC_CONFIG_AUX_DIR([config])
3AC_CONFIG_MACRO_DIR([m4])
David Goulet0809df12012-07-31 23:27:34 -04004
Brian Aker95d9fd52012-10-15 22:44:03 -04005AC_CANONICAL_TARGET
6AC_ARG_PROGRAM
7AC_USE_SYSTEM_EXTENSIONS
8
9AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability subdir-objects foreign tar-ustar])
10
11AC_PREREQ([2.63])
12
Brian Akerb12abad2012-10-16 01:25:00 -040013AC_CONFIG_HEADERS([config.h:config.in])dnl Keep filename to 8.3 for MS-DOS.
Brian Aker95d9fd52012-10-15 22:44:03 -040014
Elly Fong-Jonesa5e7fbb2013-01-08 14:08:33 -050015PKG_PROG_PKG_CONFIG
Brian Aker95d9fd52012-10-15 22:44:03 -040016LT_PREREQ([2.2])
David Goulet0809df12012-07-31 23:27:34 -040017LT_INIT
Brian Aker95d9fd52012-10-15 22:44:03 -040018LT_LANG([C])
19gl_VISIBILITY
20m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
Jacob Appelbaum5de8b0a2012-02-02 01:43:22 +010021
Brian Akerb12abad2012-10-16 01:25:00 -040022CONFIG_EXTRA
Jacob Appelbaum5de8b0a2012-02-02 01:43:22 +010023
Jacob Appelbaum96390032012-07-15 15:53:13 -040024dnl Here we should build a small program to fetch the build system time in a portable
25dnl manner. We have no Win32 users, we can fix this if we ever find one that
26dnl cares.
27COMPILE_DATE=`date +%s`
Brian Aker95d9fd52012-10-15 22:44:03 -040028AC_SUBST([COMPILE_DATE])
Jacob Appelbaum96390032012-07-15 15:53:13 -040029AC_DEFINE_UNQUOTED([RECENT_COMPILE_DATE],
Will Drewryc45952f2013-09-03 13:51:24 -050030 [${COMPILE_DATE}L],
Jacob Appelbaum96390032012-07-15 15:53:13 -040031 [Time in seconds since the Disco epoch at build time])
32
Mike Frysinger0c0b4b82012-12-18 15:10:55 -050033dnl Build up the directory we will use to install certs
Brian Aker870a3142012-10-17 02:10:49 -040034TLSDATE_CA_ROOTS="${sysconfdir}/$PACKAGE_NAME/ca-roots"
35AC_SUBST([TLSDATE_CA_ROOTS])
36
elly677a1362013-01-15 10:58:50 -050037dnl Place we install our config file
38TLSDATE_CONF_DIR="${sysconfdir}/$PACKAGE_NAME/"
39AC_SUBST([TLSDATE_CONF_DIR])
40
Mike Frysinger0c0b4b82012-12-18 15:10:55 -050041dnl Required headers
42dnl First check to see if openssl is installed
Brian Akere601a4d2012-10-17 01:24:51 -040043AC_CHECK_HEADERS([openssl/ssl.h], ,[AC_MSG_ERROR([OpenSSL is not installed, openssl/sslh is missing])])
Brian Aker33fe4bf2012-10-17 00:30:18 -040044
Brian Aker6fa3a082012-10-17 00:16:32 -040045AC_CHECK_HEADERS([arpa/inet.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
46AC_CHECK_HEADERS([getopt.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
47AC_CHECK_HEADERS([grp.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
48AC_CHECK_HEADERS([openssl/bio.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
49AC_CHECK_HEADERS([openssl/err.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
50AC_CHECK_HEADERS([openssl/evp.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
Brian Aker6fa3a082012-10-17 00:16:32 -040051AC_CHECK_HEADERS([pwd.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
52AC_CHECK_HEADERS([stdint.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
53AC_CHECK_HEADERS([stdio.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
54AC_CHECK_HEADERS([stdlib.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
55AC_CHECK_HEADERS([sys/mman.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
56AC_CHECK_HEADERS([sys/time.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
57AC_CHECK_HEADERS([sys/types.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
58AC_CHECK_HEADERS([sys/wait.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
59AC_CHECK_HEADERS([time.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
60AC_CHECK_HEADERS([unistd.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])])
Jacob Appelbaum5de8b0a2012-02-02 01:43:22 +010061
Will Drewryc45952f2013-09-03 13:51:24 -050062AC_CHECK_FUNCS_ONCE(m4_flatten([
63 gettimeofday
64 prctl
65 preadv
66 pwritev
67 setresuid
68]))
Christian Grothoffbd15a222012-02-14 00:40:57 +010069
Mike Frysingere6edd1f2012-12-19 15:48:22 -050070AC_MSG_CHECKING([user/group to drop privs to])
71
72AC_ARG_WITH([unpriv-user],
73 [AS_HELP_STRING([--with-unpriv-user=<user>],
74 [User to drop privs to @<:@default: nobody@:>@])])
75AS_CASE([$with_unpriv_user],
76 [""|yes|no], [UNPRIV_USER="nobody"],
77 [*], [UNPRIV_USER=$with_unpriv_user])
78AC_DEFINE_UNQUOTED([UNPRIV_USER], ["${UNPRIV_USER}"], [Unprivileged user])
Will Drewryc45952f2013-09-03 13:51:24 -050079AC_SUBST([UNPRIV_USER])
Mike Frysingere6edd1f2012-12-19 15:48:22 -050080
81AC_ARG_WITH([unpriv-group],
82 [AS_HELP_STRING([--with-unpriv-group=<group>],
83 [Group to drop privs to @<:@default: nogroup@:>@])])
84AS_CASE([$with_unpriv_group],
85 [""|yes|no], [UNPRIV_GROUP="nogroup"],
86 [*], [UNPRIV_GROUP=$with_unpriv_group])
87AC_DEFINE_UNQUOTED([UNPRIV_GROUP], ["${UNPRIV_GROUP}"], [Unprivileged group])
88
89AC_MSG_RESULT(${UNPRIV_USER}:${UNPRIV_GROUP})
90
Will Drewryc45952f2013-09-03 13:51:24 -050091AC_MSG_CHECKING([group to allow DBus calls from])
92AC_ARG_WITH([dbus-client-group],
93 [AS_HELP_STRING([--with-dbus-client-group=<group>],
94 [Allow dbus method calls from group @<:@default: root@:>@])])
95AS_CASE([$with_dbus_client_group],
96 [""|yes|no], [DBUS_CLIENT_GROUP="root"],
97 [*], [DBUS_CLIENT_GROUP=$with_dbus_client_group])
98AC_DEFINE_UNQUOTED([DBUS_CLIENT_GROUP], ["${DBUS_CLIENT_GROUP}"], [DBus client group])
99AC_MSG_RESULT(${DBUS_CLIENT_GROUP})
100AC_SUBST([DBUS_CLIENT_GROUP])
101
Mike Frysingere270e4b2012-12-18 15:25:25 -0500102dnl Check for clock_gettime. Some systems put it into -lc, while
103dnl others use -lrt. Try the first and fallback to the latter.
104RT_LIB=
105AC_CHECK_FUNC([clock_gettime], [:],
106 [AC_CHECK_LIB([rt], [clock_gettime], [RT_LIB="-lrt"],
107 [AC_MSG_ERROR([Your system lacks clock_gettime])])])
108AC_SUBST(RT_LIB)
Brian Akerd4ad5192012-10-16 03:55:56 -0400109
Will Drewryc45952f2013-09-03 13:51:24 -0500110PKG_CHECK_MODULES([LIBEVENT], [libevent >= 2.0])
111
112have_dbus=false
Elly Fong-Jonesa5e7fbb2013-01-08 14:08:33 -0500113AC_ARG_ENABLE([dbus],
114 [AS_HELP_STRING([--disable-dbus],
115 [Disable automatically dbus support])])
116AS_IF([test "x$enable_dbus" = xyes], [
117 PKG_CHECK_MODULES([DBUS], [dbus-1], [
Will Drewryc45952f2013-09-03 13:51:24 -0500118 have_dbus=true
119 AC_DEFINE([HAVE_DBUS], [1], [dbus enabled])
Elly Fong-Jonesa5e7fbb2013-01-08 14:08:33 -0500120 ], [
121 AS_IF([test "x$enable_dbus" = xyes],
122 [AC_MSG_ERROR([dbus requested but not found])])
123 ])
124 ])
Will Drewryc45952f2013-09-03 13:51:24 -0500125AM_CONDITIONAL([HAVE_DBUS], ${have_dbus})
Elly Fong-Jonesa5e7fbb2013-01-08 14:08:33 -0500126
127AC_SUBST(DBUS_CFLAGS)
128AC_SUBST(DBUS_LIBS)
Will Drewryc45952f2013-09-03 13:51:24 -0500129AC_SUBST(LIBEVENT_CFLAGS)
130AC_SUBST(LIBEVENT_LIBS)
131
132have_seccomp_filter=false
133AC_ARG_ENABLE([seccomp_filter],
134 [AS_HELP_STRING([--enable-seccomp-filter],
135 [Require seccomp filter])])
136
137AC_MSG_CHECKING([kernel for seccomp_filter support])
138AS_IF([test "x$enable_seccomp_filter" = xyes], [
139 dnl Force seccomp filter use
140 have_seccomp_filter=true
141 AC_MSG_RESULT([forced])
142 ], [
Gaurav Shah29e6fc32014-04-10 18:42:44 -0700143 AS_IF([test "x$enable_seccomp_filter" = xno], [
144 have_seccomp_filter=no
145 AC_MSG_RESULT([disabled])
146 ], [
Will Drewryc45952f2013-09-03 13:51:24 -0500147 dnl Detect seccomp filter support.
148 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
149 #include <errno.h>
150 #include <linux/audit.h>
151 #include <linux/filter.h>
152 #include <stdlib.h>
153 #include <sys/prctl.h>
154 #include "src/seccomp-compat.h"
155 ]],
156 [[ errno = 0;
157 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0))
158 exit(1);
159 prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
160 exit(errno == EFAULT ? 0 : 1); ]])],
161 [ AC_MSG_RESULT([yes])
162 have_seccomp_filter=true
163 ], [
164 AC_MSG_RESULT([no])
165 ],
166 [ AC_MSG_RESULT([cross-compiling, assuming yes])
167 have_seccomp_filter=true
168 ]
169 )
Gaurav Shah29e6fc32014-04-10 18:42:44 -0700170])])
Will Drewryc45952f2013-09-03 13:51:24 -0500171
172AS_IF([${have_seccomp_filter}], [
173 AC_DEFINE([HAVE_SECCOMP_FILTER], [1], [Enable seccomp filter])
174 ])
175AM_CONDITIONAL([HAVE_SECCOMP_FILTER], ${have_seccomp_filter})
176
177
178
179have_seccomp_debug=false
180AC_ARG_ENABLE([seccomp_debugging],
181 [AS_HELP_STRING([--enable-seccomp-debugging],
182 [Enable seccomp filter debugging])])
183AS_IF([test "x$enable_seccomp_debugging" = xyes], [
184 AC_DEFINE([SECCOMP_FILTER_DEBUG], [1], [Enable seccomp filter debugging])
185 have_seccomp_debug=true
186 ])
187AM_CONDITIONAL([SECCOMP_FILTER_DEBUG], ${have_seccomp_debug})
188
189
190AC_MSG_CHECKING([for CrOS-specific platform wake event support])
191AC_ARG_ENABLE([cros],
192 [AS_HELP_STRING([--disable-cros],
193 [Disable CrOS platform support])])
194
195AS_IF([test "x$enable_cros" = xyes -a "x$enable_dbus" != xyes ], [
196 AC_MSG_ERROR([--enable-dbus is required for --enable-cros])
197 ])
198
199have_cros=false
200AS_IF([test "x$enable_cros" = xyes], [
201 have_cros=true
202 AC_DEFINE([HAVE_CROS], [1], [Enable CrOS support])
203 AC_MSG_RESULT([yes])
204 ], [
205 AC_MSG_RESULT([no])
206 ])
207AM_CONDITIONAL([HAVE_CROS], ${have_cros})
Elly Fong-Jonesa5e7fbb2013-01-08 14:08:33 -0500208
Mike Frysinger0c0b4b82012-12-18 15:10:55 -0500209dnl Debug and hardening flags all in one shot
210dnl Always do this at the end, otherwise you end up filtering system/other libraries
Mike Frysinger8b94e112012-12-18 15:38:51 -0500211AC_ARG_ENABLE([hardened-checks],
212 [AS_HELP_STRING([--disable-hardened-checks],
213 [Disable automatically enabling hardened toolchain options])])
Brian Akerb12abad2012-10-16 01:25:00 -0400214AC_DEFUN([LOCAL_CHECK_FLAGS],[
215 AC_REQUIRE([AX_CHECK_LINK_FLAG])
216 AC_REQUIRE([AX_APPEND_COMPILE_FLAGS])
217 AC_LANG_PUSH([C])
Mike Frysinger8b94e112012-12-18 15:38:51 -0500218 AS_IF([test "x$enable_hardened_checks" != xno], [
219 CFLAGS=
220 LIBS=
221 AX_APPEND_COMPILE_FLAGS([-g -O1])
222 ], [
223 AC_MSG_WARN([using hardened flags is HIGHLY RECOMMENDED and disabling them is a BAD IDEA])
224 ])
225 AX_APPEND_COMPILE_FLAGS([-Wall -fno-strict-aliasing])
226 AS_IF([test "x$enable_hardened_checks" != xno], [
227 AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2 -fstack-protector-all])
228 AX_APPEND_COMPILE_FLAGS([-fwrapv -fPIE -Wstack-protector])
229 AX_APPEND_COMPILE_FLAGS([--param=ssp-buffer-size=1])
230 AX_CHECK_LINK_FLAG([-z relro -z now])
231 AX_CHECK_LINK_FLAG([-pie])
232 ])
Brian Akerb12abad2012-10-16 01:25:00 -0400233 AC_LANG_POP
234 ])
235LOCAL_CHECK_FLAGS
236
Jacob Appelbaum13ec4ee2013-01-10 11:36:38 -0800237AC_ARG_ENABLE([code-coverage-checks],
238 [AS_HELP_STRING([--enable-code-coverage-checks],
239 [Enable gcov/lcov compile time options])],
240 [AX_APPEND_COMPILE_FLAGS([-ftest-coverage -fprofile-arcs])])
241
Will Drewryc45952f2013-09-03 13:51:24 -0500242AC_CONFIG_FILES([dbus/org.torproject.tlsdate.conf])
Brian Aker95d9fd52012-10-15 22:44:03 -0400243AC_CONFIG_FILES([Makefile])
244AC_OUTPUT