blob: 70763574929f02c12515c3fe048d09231d947132 [file] [log] [blame]
Jacob Appelbaumb10b0f72012-11-07 20:35:00 -08001AC_INIT([tlsdate],[0.0.4],[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],
30 [(uint32_t) ${COMPILE_DATE}],
31 [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
Brian Aker6fa3a082012-10-17 00:16:32 -040062AC_CHECK_FUNCS([setresuid])
63AC_CHECK_FUNCS([gettimeofday])
Christian Grothoffbd15a222012-02-14 00:40:57 +010064
Mike Frysingere6edd1f2012-12-19 15:48:22 -050065AC_MSG_CHECKING([user/group to drop privs to])
66
67AC_ARG_WITH([unpriv-user],
68 [AS_HELP_STRING([--with-unpriv-user=<user>],
69 [User to drop privs to @<:@default: nobody@:>@])])
70AS_CASE([$with_unpriv_user],
71 [""|yes|no], [UNPRIV_USER="nobody"],
72 [*], [UNPRIV_USER=$with_unpriv_user])
73AC_DEFINE_UNQUOTED([UNPRIV_USER], ["${UNPRIV_USER}"], [Unprivileged user])
74
75AC_ARG_WITH([unpriv-group],
76 [AS_HELP_STRING([--with-unpriv-group=<group>],
77 [Group to drop privs to @<:@default: nogroup@:>@])])
78AS_CASE([$with_unpriv_group],
79 [""|yes|no], [UNPRIV_GROUP="nogroup"],
80 [*], [UNPRIV_GROUP=$with_unpriv_group])
81AC_DEFINE_UNQUOTED([UNPRIV_GROUP], ["${UNPRIV_GROUP}"], [Unprivileged group])
82
83AC_MSG_RESULT(${UNPRIV_USER}:${UNPRIV_GROUP})
84
Mike Frysingere270e4b2012-12-18 15:25:25 -050085dnl Check for clock_gettime. Some systems put it into -lc, while
86dnl others use -lrt. Try the first and fallback to the latter.
87RT_LIB=
88AC_CHECK_FUNC([clock_gettime], [:],
89 [AC_CHECK_LIB([rt], [clock_gettime], [RT_LIB="-lrt"],
90 [AC_MSG_ERROR([Your system lacks clock_gettime])])])
91AC_SUBST(RT_LIB)
Brian Akerd4ad5192012-10-16 03:55:56 -040092
Elly Fong-Jonesa5e7fbb2013-01-08 14:08:33 -050093AC_ARG_ENABLE([dbus],
94 [AS_HELP_STRING([--disable-dbus],
95 [Disable automatically dbus support])])
96AS_IF([test "x$enable_dbus" = xyes], [
97 PKG_CHECK_MODULES([DBUS], [dbus-1], [
98 AC_DEFINE([HAVE_DBUS], [1], [Enable dbus support])
99 AC_MSG_CHECKING([user/group to use for dbus])
100 AC_ARG_WITH([dbus-user],
101 [AS_HELP_STRING([--with-dbus-user=<user>],
102 [User to send dbus signals from @<:@default: nobody@:>@])])
103 AS_CASE([$with_dbus_user],
104 [""|yes|no], [DBUS_USER="nobody"],
105 [*], [DBUS_USER=$with_dbus_user])
106 AC_ARG_WITH([dbus-group],
107 [AS_HELP_STRING([--with-dbus-group=<group>],
108 [Group to send dbus signals from @<:@default: nogroup@:>@])])
109 AS_CASE([$with_dbus_group],
110 [""|yes|no], [DBUS_GROUP="nogroup"],
111 [*], [DBUS_GROUP=$with_dbus_group])
112 AC_MSG_RESULT(${DBUS_USER}:${DBUS_GROUP})
113 AC_DEFINE_UNQUOTED([DBUS_USER], ["${DBUS_USER}"], [DBus user])
114 AC_DEFINE_UNQUOTED([DBUS_GROUP], ["${DBUS_GROUP}"], [DBus group])
115 ], [
116 AS_IF([test "x$enable_dbus" = xyes],
117 [AC_MSG_ERROR([dbus requested but not found])])
118 ])
119 ])
120
121AC_SUBST(DBUS_CFLAGS)
122AC_SUBST(DBUS_LIBS)
123
Mike Frysinger0c0b4b82012-12-18 15:10:55 -0500124dnl Debug and hardening flags all in one shot
125dnl Always do this at the end, otherwise you end up filtering system/other libraries
Mike Frysinger8b94e112012-12-18 15:38:51 -0500126AC_ARG_ENABLE([hardened-checks],
127 [AS_HELP_STRING([--disable-hardened-checks],
128 [Disable automatically enabling hardened toolchain options])])
Brian Akerb12abad2012-10-16 01:25:00 -0400129AC_DEFUN([LOCAL_CHECK_FLAGS],[
130 AC_REQUIRE([AX_CHECK_LINK_FLAG])
131 AC_REQUIRE([AX_APPEND_COMPILE_FLAGS])
132 AC_LANG_PUSH([C])
Mike Frysinger8b94e112012-12-18 15:38:51 -0500133 AS_IF([test "x$enable_hardened_checks" != xno], [
134 CFLAGS=
135 LIBS=
136 AX_APPEND_COMPILE_FLAGS([-g -O1])
137 ], [
138 AC_MSG_WARN([using hardened flags is HIGHLY RECOMMENDED and disabling them is a BAD IDEA])
139 ])
140 AX_APPEND_COMPILE_FLAGS([-Wall -fno-strict-aliasing])
141 AS_IF([test "x$enable_hardened_checks" != xno], [
142 AX_APPEND_COMPILE_FLAGS([-D_FORTIFY_SOURCE=2 -fstack-protector-all])
143 AX_APPEND_COMPILE_FLAGS([-fwrapv -fPIE -Wstack-protector])
144 AX_APPEND_COMPILE_FLAGS([--param=ssp-buffer-size=1])
145 AX_CHECK_LINK_FLAG([-z relro -z now])
146 AX_CHECK_LINK_FLAG([-pie])
147 ])
Brian Akerb12abad2012-10-16 01:25:00 -0400148 AC_LANG_POP
149 ])
150LOCAL_CHECK_FLAGS
151
Jacob Appelbaum13ec4ee2013-01-10 11:36:38 -0800152AC_ARG_ENABLE([code-coverage-checks],
153 [AS_HELP_STRING([--enable-code-coverage-checks],
154 [Enable gcov/lcov compile time options])],
155 [AX_APPEND_COMPILE_FLAGS([-ftest-coverage -fprofile-arcs])])
156
Brian Aker95d9fd52012-10-15 22:44:03 -0400157AC_CONFIG_FILES([Makefile])
158AC_OUTPUT