Jacob Appelbaum | eb1bcf6 | 2013-01-18 15:23:19 +0100 | [diff] [blame] | 1 | AC_INIT([tlsdate],[0.0.5],[jacob at appelbaum.net]) |
Brian Aker | 95d9fd5 | 2012-10-15 22:44:03 -0400 | [diff] [blame] | 2 | AC_CONFIG_AUX_DIR([config]) |
| 3 | AC_CONFIG_MACRO_DIR([m4]) |
David Goulet | 0809df1 | 2012-07-31 23:27:34 -0400 | [diff] [blame] | 4 | |
Brian Aker | 95d9fd5 | 2012-10-15 22:44:03 -0400 | [diff] [blame] | 5 | AC_CANONICAL_TARGET |
| 6 | AC_ARG_PROGRAM |
| 7 | AC_USE_SYSTEM_EXTENSIONS |
| 8 | |
| 9 | AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability subdir-objects foreign tar-ustar]) |
| 10 | |
| 11 | AC_PREREQ([2.63]) |
| 12 | |
Brian Aker | b12abad | 2012-10-16 01:25:00 -0400 | [diff] [blame] | 13 | AC_CONFIG_HEADERS([config.h:config.in])dnl Keep filename to 8.3 for MS-DOS. |
Brian Aker | 95d9fd5 | 2012-10-15 22:44:03 -0400 | [diff] [blame] | 14 | |
Elly Fong-Jones | a5e7fbb | 2013-01-08 14:08:33 -0500 | [diff] [blame] | 15 | PKG_PROG_PKG_CONFIG |
Brian Aker | 95d9fd5 | 2012-10-15 22:44:03 -0400 | [diff] [blame] | 16 | LT_PREREQ([2.2]) |
David Goulet | 0809df1 | 2012-07-31 23:27:34 -0400 | [diff] [blame] | 17 | LT_INIT |
Brian Aker | 95d9fd5 | 2012-10-15 22:44:03 -0400 | [diff] [blame] | 18 | LT_LANG([C]) |
| 19 | gl_VISIBILITY |
| 20 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) |
Jacob Appelbaum | 5de8b0a | 2012-02-02 01:43:22 +0100 | [diff] [blame] | 21 | |
Brian Aker | b12abad | 2012-10-16 01:25:00 -0400 | [diff] [blame] | 22 | CONFIG_EXTRA |
Jacob Appelbaum | 5de8b0a | 2012-02-02 01:43:22 +0100 | [diff] [blame] | 23 | |
Jacob Appelbaum | 9639003 | 2012-07-15 15:53:13 -0400 | [diff] [blame] | 24 | dnl Here we should build a small program to fetch the build system time in a portable |
| 25 | dnl manner. We have no Win32 users, we can fix this if we ever find one that |
| 26 | dnl cares. |
| 27 | COMPILE_DATE=`date +%s` |
Brian Aker | 95d9fd5 | 2012-10-15 22:44:03 -0400 | [diff] [blame] | 28 | AC_SUBST([COMPILE_DATE]) |
Jacob Appelbaum | 9639003 | 2012-07-15 15:53:13 -0400 | [diff] [blame] | 29 | AC_DEFINE_UNQUOTED([RECENT_COMPILE_DATE], |
Will Drewry | c45952f | 2013-09-03 13:51:24 -0500 | [diff] [blame] | 30 | [${COMPILE_DATE}L], |
Jacob Appelbaum | 9639003 | 2012-07-15 15:53:13 -0400 | [diff] [blame] | 31 | [Time in seconds since the Disco epoch at build time]) |
| 32 | |
Mike Frysinger | 0c0b4b8 | 2012-12-18 15:10:55 -0500 | [diff] [blame] | 33 | dnl Build up the directory we will use to install certs |
Brian Aker | 870a314 | 2012-10-17 02:10:49 -0400 | [diff] [blame] | 34 | TLSDATE_CA_ROOTS="${sysconfdir}/$PACKAGE_NAME/ca-roots" |
| 35 | AC_SUBST([TLSDATE_CA_ROOTS]) |
| 36 | |
elly | 677a136 | 2013-01-15 10:58:50 -0500 | [diff] [blame] | 37 | dnl Place we install our config file |
| 38 | TLSDATE_CONF_DIR="${sysconfdir}/$PACKAGE_NAME/" |
| 39 | AC_SUBST([TLSDATE_CONF_DIR]) |
| 40 | |
Mike Frysinger | 0c0b4b8 | 2012-12-18 15:10:55 -0500 | [diff] [blame] | 41 | dnl Required headers |
| 42 | dnl First check to see if openssl is installed |
Brian Aker | e601a4d | 2012-10-17 01:24:51 -0400 | [diff] [blame] | 43 | AC_CHECK_HEADERS([openssl/ssl.h], ,[AC_MSG_ERROR([OpenSSL is not installed, openssl/sslh is missing])]) |
Brian Aker | 33fe4bf | 2012-10-17 00:30:18 -0400 | [diff] [blame] | 44 | |
Brian Aker | 6fa3a08 | 2012-10-17 00:16:32 -0400 | [diff] [blame] | 45 | AC_CHECK_HEADERS([arpa/inet.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 46 | AC_CHECK_HEADERS([getopt.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 47 | AC_CHECK_HEADERS([grp.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 48 | AC_CHECK_HEADERS([openssl/bio.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 49 | AC_CHECK_HEADERS([openssl/err.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 50 | AC_CHECK_HEADERS([openssl/evp.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
Brian Aker | 6fa3a08 | 2012-10-17 00:16:32 -0400 | [diff] [blame] | 51 | AC_CHECK_HEADERS([pwd.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 52 | AC_CHECK_HEADERS([stdint.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 53 | AC_CHECK_HEADERS([stdio.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 54 | AC_CHECK_HEADERS([stdlib.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 55 | AC_CHECK_HEADERS([sys/mman.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 56 | AC_CHECK_HEADERS([sys/time.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 57 | AC_CHECK_HEADERS([sys/types.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 58 | AC_CHECK_HEADERS([sys/wait.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 59 | AC_CHECK_HEADERS([time.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
| 60 | AC_CHECK_HEADERS([unistd.h], ,[AC_MSG_ERROR([Required headers missing; compilation will not succeed])]) |
Jacob Appelbaum | 5de8b0a | 2012-02-02 01:43:22 +0100 | [diff] [blame] | 61 | |
Will Drewry | c45952f | 2013-09-03 13:51:24 -0500 | [diff] [blame] | 62 | AC_CHECK_FUNCS_ONCE(m4_flatten([ |
| 63 | gettimeofday |
| 64 | prctl |
| 65 | preadv |
| 66 | pwritev |
| 67 | setresuid |
| 68 | ])) |
Christian Grothoff | bd15a22 | 2012-02-14 00:40:57 +0100 | [diff] [blame] | 69 | |
Mike Frysinger | e6edd1f | 2012-12-19 15:48:22 -0500 | [diff] [blame] | 70 | AC_MSG_CHECKING([user/group to drop privs to]) |
| 71 | |
| 72 | AC_ARG_WITH([unpriv-user], |
| 73 | [AS_HELP_STRING([--with-unpriv-user=<user>], |
| 74 | [User to drop privs to @<:@default: nobody@:>@])]) |
| 75 | AS_CASE([$with_unpriv_user], |
| 76 | [""|yes|no], [UNPRIV_USER="nobody"], |
| 77 | [*], [UNPRIV_USER=$with_unpriv_user]) |
| 78 | AC_DEFINE_UNQUOTED([UNPRIV_USER], ["${UNPRIV_USER}"], [Unprivileged user]) |
Will Drewry | c45952f | 2013-09-03 13:51:24 -0500 | [diff] [blame] | 79 | AC_SUBST([UNPRIV_USER]) |
Mike Frysinger | e6edd1f | 2012-12-19 15:48:22 -0500 | [diff] [blame] | 80 | |
| 81 | AC_ARG_WITH([unpriv-group], |
| 82 | [AS_HELP_STRING([--with-unpriv-group=<group>], |
| 83 | [Group to drop privs to @<:@default: nogroup@:>@])]) |
| 84 | AS_CASE([$with_unpriv_group], |
| 85 | [""|yes|no], [UNPRIV_GROUP="nogroup"], |
| 86 | [*], [UNPRIV_GROUP=$with_unpriv_group]) |
| 87 | AC_DEFINE_UNQUOTED([UNPRIV_GROUP], ["${UNPRIV_GROUP}"], [Unprivileged group]) |
| 88 | |
| 89 | AC_MSG_RESULT(${UNPRIV_USER}:${UNPRIV_GROUP}) |
| 90 | |
Will Drewry | c45952f | 2013-09-03 13:51:24 -0500 | [diff] [blame] | 91 | AC_MSG_CHECKING([group to allow DBus calls from]) |
| 92 | AC_ARG_WITH([dbus-client-group], |
| 93 | [AS_HELP_STRING([--with-dbus-client-group=<group>], |
| 94 | [Allow dbus method calls from group @<:@default: root@:>@])]) |
| 95 | AS_CASE([$with_dbus_client_group], |
| 96 | [""|yes|no], [DBUS_CLIENT_GROUP="root"], |
| 97 | [*], [DBUS_CLIENT_GROUP=$with_dbus_client_group]) |
| 98 | AC_DEFINE_UNQUOTED([DBUS_CLIENT_GROUP], ["${DBUS_CLIENT_GROUP}"], [DBus client group]) |
| 99 | AC_MSG_RESULT(${DBUS_CLIENT_GROUP}) |
| 100 | AC_SUBST([DBUS_CLIENT_GROUP]) |
| 101 | |
Mike Frysinger | e270e4b | 2012-12-18 15:25:25 -0500 | [diff] [blame] | 102 | dnl Check for clock_gettime. Some systems put it into -lc, while |
| 103 | dnl others use -lrt. Try the first and fallback to the latter. |
| 104 | RT_LIB= |
| 105 | AC_CHECK_FUNC([clock_gettime], [:], |
| 106 | [AC_CHECK_LIB([rt], [clock_gettime], [RT_LIB="-lrt"], |
| 107 | [AC_MSG_ERROR([Your system lacks clock_gettime])])]) |
| 108 | AC_SUBST(RT_LIB) |
Brian Aker | d4ad519 | 2012-10-16 03:55:56 -0400 | [diff] [blame] | 109 | |
Will Drewry | c45952f | 2013-09-03 13:51:24 -0500 | [diff] [blame] | 110 | PKG_CHECK_MODULES([LIBEVENT], [libevent >= 2.0]) |
| 111 | |
| 112 | have_dbus=false |
Elly Fong-Jones | a5e7fbb | 2013-01-08 14:08:33 -0500 | [diff] [blame] | 113 | AC_ARG_ENABLE([dbus], |
| 114 | [AS_HELP_STRING([--disable-dbus], |
| 115 | [Disable automatically dbus support])]) |
| 116 | AS_IF([test "x$enable_dbus" = xyes], [ |
| 117 | PKG_CHECK_MODULES([DBUS], [dbus-1], [ |
Will Drewry | c45952f | 2013-09-03 13:51:24 -0500 | [diff] [blame] | 118 | have_dbus=true |
| 119 | AC_DEFINE([HAVE_DBUS], [1], [dbus enabled]) |
Elly Fong-Jones | a5e7fbb | 2013-01-08 14:08:33 -0500 | [diff] [blame] | 120 | ], [ |
| 121 | AS_IF([test "x$enable_dbus" = xyes], |
| 122 | [AC_MSG_ERROR([dbus requested but not found])]) |
| 123 | ]) |
| 124 | ]) |
Will Drewry | c45952f | 2013-09-03 13:51:24 -0500 | [diff] [blame] | 125 | AM_CONDITIONAL([HAVE_DBUS], ${have_dbus}) |
Elly Fong-Jones | a5e7fbb | 2013-01-08 14:08:33 -0500 | [diff] [blame] | 126 | |
| 127 | AC_SUBST(DBUS_CFLAGS) |
| 128 | AC_SUBST(DBUS_LIBS) |
Will Drewry | c45952f | 2013-09-03 13:51:24 -0500 | [diff] [blame] | 129 | AC_SUBST(LIBEVENT_CFLAGS) |
| 130 | AC_SUBST(LIBEVENT_LIBS) |
| 131 | |
| 132 | have_seccomp_filter=false |
| 133 | AC_ARG_ENABLE([seccomp_filter], |
| 134 | [AS_HELP_STRING([--enable-seccomp-filter], |
| 135 | [Require seccomp filter])]) |
| 136 | |
| 137 | AC_MSG_CHECKING([kernel for seccomp_filter support]) |
| 138 | AS_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 Shah | 29e6fc3 | 2014-04-10 18:42:44 -0700 | [diff] [blame] | 143 | AS_IF([test "x$enable_seccomp_filter" = xno], [ |
| 144 | have_seccomp_filter=no |
| 145 | AC_MSG_RESULT([disabled]) |
| 146 | ], [ |
Will Drewry | c45952f | 2013-09-03 13:51:24 -0500 | [diff] [blame] | 147 | 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 Shah | 29e6fc3 | 2014-04-10 18:42:44 -0700 | [diff] [blame] | 170 | ])]) |
Will Drewry | c45952f | 2013-09-03 13:51:24 -0500 | [diff] [blame] | 171 | |
| 172 | AS_IF([${have_seccomp_filter}], [ |
| 173 | AC_DEFINE([HAVE_SECCOMP_FILTER], [1], [Enable seccomp filter]) |
| 174 | ]) |
| 175 | AM_CONDITIONAL([HAVE_SECCOMP_FILTER], ${have_seccomp_filter}) |
| 176 | |
| 177 | |
| 178 | |
| 179 | have_seccomp_debug=false |
| 180 | AC_ARG_ENABLE([seccomp_debugging], |
| 181 | [AS_HELP_STRING([--enable-seccomp-debugging], |
| 182 | [Enable seccomp filter debugging])]) |
| 183 | AS_IF([test "x$enable_seccomp_debugging" = xyes], [ |
| 184 | AC_DEFINE([SECCOMP_FILTER_DEBUG], [1], [Enable seccomp filter debugging]) |
| 185 | have_seccomp_debug=true |
| 186 | ]) |
| 187 | AM_CONDITIONAL([SECCOMP_FILTER_DEBUG], ${have_seccomp_debug}) |
| 188 | |
| 189 | |
| 190 | AC_MSG_CHECKING([for CrOS-specific platform wake event support]) |
| 191 | AC_ARG_ENABLE([cros], |
| 192 | [AS_HELP_STRING([--disable-cros], |
| 193 | [Disable CrOS platform support])]) |
| 194 | |
| 195 | AS_IF([test "x$enable_cros" = xyes -a "x$enable_dbus" != xyes ], [ |
| 196 | AC_MSG_ERROR([--enable-dbus is required for --enable-cros]) |
| 197 | ]) |
| 198 | |
| 199 | have_cros=false |
| 200 | AS_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 | ]) |
| 207 | AM_CONDITIONAL([HAVE_CROS], ${have_cros}) |
Elly Fong-Jones | a5e7fbb | 2013-01-08 14:08:33 -0500 | [diff] [blame] | 208 | |
Mike Frysinger | 0c0b4b8 | 2012-12-18 15:10:55 -0500 | [diff] [blame] | 209 | dnl Debug and hardening flags all in one shot |
| 210 | dnl Always do this at the end, otherwise you end up filtering system/other libraries |
Mike Frysinger | 8b94e11 | 2012-12-18 15:38:51 -0500 | [diff] [blame] | 211 | AC_ARG_ENABLE([hardened-checks], |
| 212 | [AS_HELP_STRING([--disable-hardened-checks], |
| 213 | [Disable automatically enabling hardened toolchain options])]) |
Brian Aker | b12abad | 2012-10-16 01:25:00 -0400 | [diff] [blame] | 214 | AC_DEFUN([LOCAL_CHECK_FLAGS],[ |
| 215 | AC_REQUIRE([AX_CHECK_LINK_FLAG]) |
| 216 | AC_REQUIRE([AX_APPEND_COMPILE_FLAGS]) |
| 217 | AC_LANG_PUSH([C]) |
Mike Frysinger | 8b94e11 | 2012-12-18 15:38:51 -0500 | [diff] [blame] | 218 | 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 Aker | b12abad | 2012-10-16 01:25:00 -0400 | [diff] [blame] | 233 | AC_LANG_POP |
| 234 | ]) |
| 235 | LOCAL_CHECK_FLAGS |
| 236 | |
Jacob Appelbaum | 13ec4ee | 2013-01-10 11:36:38 -0800 | [diff] [blame] | 237 | AC_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 Drewry | c45952f | 2013-09-03 13:51:24 -0500 | [diff] [blame] | 242 | AC_CONFIG_FILES([dbus/org.torproject.tlsdate.conf]) |
Brian Aker | 95d9fd5 | 2012-10-15 22:44:03 -0400 | [diff] [blame] | 243 | AC_CONFIG_FILES([Makefile]) |
| 244 | AC_OUTPUT |