4 # Copyright 1996-2017 Ian Jackson <ian@davenant.greenend.org.uk>.
5 # Copyright 2000 Ben Harris <bjh21@cam.ac.uk>
6 # Copyright 2016-2017 Peter Benie <pjb1008@cam.ac.uk>
8 # This is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 AC_CONFIG_HEADER(config.h)
24 AC_PREFIX_DEFAULT(/usr/local)
32 [ --enable-debug build debugging version],
34 if test "x$enable_debug" = xyes; then
35 DEBUGDEFS="-DDEBUG -DVARDIR='\"$crdir/vd\"' -DSYSTEMCONFIGDIR='\"$crdir/slash-etc\"' -DSERVICEUSERDIR='\"$crdir/tilde\"'"
37 echo will build debugging version
38 elif test "x$enable_debug" != xno; then
39 AC_MSG_ERROR(--enable-debug does not allow any arguments except 'yes' and 'no')
46 AC_CHECK_PROGS(MD5SUM_SIMPLE, md5sum md5 gmd5sum)
48 CFLAGS="$CFLAGS -D_GNU_SOURCE"
50 AC_CHECK_LIB(socket,socket)
51 AC_CHECK_FUNCS(setenv strsignal vsnprintf)
53 AC_CACHE_CHECK(for EPROTO,userv_cv_hdr_eproto,
60 ],userv_cv_hdr_eproto=yes,userv_cv_hdr_eproto=no))
61 if test $userv_cv_hdr_eproto = yes
63 AC_DEFINE(HAVE_EPROTO)
66 AC_CACHE_CHECK(for LOG_AUTHPRIV,userv_cv_hdr_logauthpriv,
73 ],userv_cv_hdr_logauthpriv=yes,userv_cv_hdr_logauthpriv=no))
74 if test $userv_cv_hdr_logauthpriv = yes
76 AC_DEFINE(HAVE_LOG_AUTHPRIV)
79 AC_CACHE_CHECK(for WCOREDUMP,userv_cv_hdr_wcoredump,
82 #include <sys/types.h>
87 ],userv_cv_hdr_wcoredump=yes,userv_cv_hdr_wcoredump=no))
88 if test $userv_cv_hdr_wcoredump = yes
90 AC_DEFINE(HAVE_WCOREDUMP)
94 if test "${GCC-no}" = yes; then
100 dnl DPKG_CACHED_TRY_COMPILE(<description>,<cachevar>,<include>,<program>,<ifyes>,<ifno>)
101 define(DPKG_CACHED_TRY_COMPILE,[
104 AC_TRY_COMPILE([$3],[$4],[$2=yes],[$2=no])
106 if test "x$$2" = xyes; then
115 DPKG_CACHED_TRY_COMPILE(your C compiler,dpkg_cv_c_works,
116 [#include <string.h>], [strcmp("a","b")],
117 AC_MSG_RESULT(works),
118 AC_MSG_RESULT(broken)
119 AC_MSG_ERROR(C compiler is broken))
121 DPKG_CACHED_TRY_COMPILE(__attribute__((,,)),dpkg_cv_c_attribute_supported,,
122 [extern int testfunction(int x) __attribute__((,,))],
124 AC_DEFINE(HAVE_GNUC25_ATTRIB)
125 DPKG_CACHED_TRY_COMPILE(__attribute__((noreturn)),dpkg_cv_c_attribute_noreturn,,
126 [extern int testfunction(int x) __attribute__((noreturn))],
128 AC_DEFINE(HAVE_GNUC25_NORETURN),
130 DPKG_CACHED_TRY_COMPILE(__attribute__((unused)),dpkg_cv_c_attribute_unused,,
131 [extern int testfunction(int x) __attribute__((unused))],
133 AC_DEFINE(HAVE_GNUC25_UNUSED),
135 DPKG_CACHED_TRY_COMPILE(__attribute__((format...)),dpkg_cv_attribute_format,,
136 [extern int testfunction(char *y, ...) __attribute__((format(printf,1,2)))],
138 AC_DEFINE(HAVE_GNUC25_PRINTFFORMAT),
145 dnl DPKG_C_GCC_TRY_WARNS(<warnings>,<cachevar>)
146 define(DPKG_C_GCC_TRY_WARNS,[
147 AC_MSG_CHECKING([GCC warning flag(s) $1])
148 if test "${GCC-no}" = yes
151 oldcflags="${CFLAGS-}"
152 CFLAGS="${CFLAGS-} ${CWARNS} $1 -Werror"
157 strcmp("a","b"); fprintf(stdout,"test ok\n");
158 ], [$2=yes], [$2=no])
159 CFLAGS="${oldcflags}"])
160 if test "x$$2" = xyes; then
161 CWARNS="${CWARNS} $1"
168 AC_MSG_RESULT(no, not using GCC)
172 DPKG_C_GCC_TRY_WARNS(-Wall -Wno-implicit, dpkg_cv_c_gcc_warn_all)
173 DPKG_C_GCC_TRY_WARNS(-Wwrite-strings, dpkg_cv_c_gcc_warn_writestrings)
174 DPKG_C_GCC_TRY_WARNS(-Wpointer-arith, dpkg_cv_c_gcc_warn_pointerarith)
175 DPKG_C_GCC_TRY_WARNS(-Wimplicit -Wnested-externs, dpkg_cv_c_gcc_warn_implicit)
177 if test "${GCC-no}" = yes; then
178 CWARNS="${CWARNS} -Wmissing-prototypes -Wstrict-prototypes"
180 [CFLAGS="`echo $CFLAGS $CWARNS | sed -e 's/-O[0-9]*/$(OPTIMISE)/'`"]
183 VERSION="`sed -n '/^userv (.*)/!d; s/^userv (//; s/).*//; p; q' debian/changelog`"
184 echo will build version $VERSION