chiark / gitweb /
Upgrade licence to GPLv3+.
[userv.git] / configure.in
1 #  userv - configure.in
2 #
3 #  userv is
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>
7 #  
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.
12 #  
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.
17 #  
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/>.
20
21 AC_INIT(language.i4)
22 AC_CONFIG_HEADER(config.h)
23
24 AC_PREFIX_DEFAULT(/usr/local)
25
26 crdir="`pwd`"
27 AC_SUBST(DEBUGDEFS)
28 AC_SUBST(DEBUGLIBS)
29 DEBUGDEFS=''
30 DEBUGLIBS=''
31 AC_ARG_ENABLE(debug,
32 [  --enable-debug          build debugging version],
33 [
34  if test "x$enable_debug" = xyes; then
35   DEBUGDEFS="-DDEBUG -DVARDIR='\"$crdir/vd\"' -DSYSTEMCONFIGDIR='\"$crdir/slash-etc\"' -DSERVICEUSERDIR='\"$crdir/tilde\"'"
36   DEBUGLIBS=-lefence
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')
40  fi
41 ])
42
43 AC_PROG_CC
44 AC_PROG_CPP
45 AC_PROG_INSTALL
46 AC_CHECK_PROGS(MD5SUM_SIMPLE, md5sum md5 gmd5sum)
47
48 CFLAGS="$CFLAGS -D_GNU_SOURCE"
49
50 AC_CHECK_LIB(socket,socket)
51 AC_CHECK_FUNCS(setenv strsignal vsnprintf)
52
53 AC_CACHE_CHECK(for EPROTO,userv_cv_hdr_eproto,
54  AC_EGREP_CPP(yes,
55 [
56 #include <errno.h>
57 #ifdef EPROTO
58  yes
59 #endif
60 ],userv_cv_hdr_eproto=yes,userv_cv_hdr_eproto=no))
61 if test $userv_cv_hdr_eproto = yes
62 then
63         AC_DEFINE(HAVE_EPROTO)
64 fi
65
66 AC_CACHE_CHECK(for LOG_AUTHPRIV,userv_cv_hdr_logauthpriv,
67  AC_EGREP_CPP(yes,
68 [
69 #include <syslog.h>
70 #ifdef LOG_AUTHPRIV
71  yes
72 #endif
73 ],userv_cv_hdr_logauthpriv=yes,userv_cv_hdr_logauthpriv=no))
74 if test $userv_cv_hdr_logauthpriv = yes
75 then
76         AC_DEFINE(HAVE_LOG_AUTHPRIV)
77 fi
78
79 AC_CACHE_CHECK(for WCOREDUMP,userv_cv_hdr_wcoredump,
80  AC_EGREP_CPP(yes,
81 [
82 #include <sys/types.h>
83 #include <sys/wait.h>
84 #ifdef WCOREDUMP
85  yes
86 #endif
87 ],userv_cv_hdr_wcoredump=yes,userv_cv_hdr_wcoredump=no))
88 if test $userv_cv_hdr_wcoredump = yes
89 then
90         AC_DEFINE(HAVE_WCOREDUMP)
91 fi
92
93 AC_SUBST(OPTIMISE)
94 if test "${GCC-no}" = yes; then
95  OPTIMISE=-O2
96 else
97  OPTIMISE=-O
98 fi
99
100 dnl DPKG_CACHED_TRY_COMPILE(<description>,<cachevar>,<include>,<program>,<ifyes>,<ifno>)
101 define(DPKG_CACHED_TRY_COMPILE,[
102  AC_MSG_CHECKING($1)
103  AC_CACHE_VAL($2,[
104   AC_TRY_COMPILE([$3],[$4],[$2=yes],[$2=no])
105  ])
106  if test "x$$2" = xyes; then
107   true
108   $5
109  else
110   true
111   $6
112  fi
113 ])
114
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))
120
121 DPKG_CACHED_TRY_COMPILE(__attribute__((,,)),dpkg_cv_c_attribute_supported,,
122  [extern int testfunction(int x) __attribute__((,,))],
123  AC_MSG_RESULT(yes)
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))],
127    AC_MSG_RESULT(yes)
128    AC_DEFINE(HAVE_GNUC25_NORETURN),
129    AC_MSG_RESULT(no))
130   DPKG_CACHED_TRY_COMPILE(__attribute__((unused)),dpkg_cv_c_attribute_unused,,
131    [extern int testfunction(int x) __attribute__((unused))],
132    AC_MSG_RESULT(yes)
133    AC_DEFINE(HAVE_GNUC25_UNUSED),
134    AC_MSG_RESULT(no))
135   DPKG_CACHED_TRY_COMPILE(__attribute__((format...)),dpkg_cv_attribute_format,,
136    [extern int testfunction(char *y, ...) __attribute__((format(printf,1,2)))],
137    AC_MSG_RESULT(yes)
138    AC_DEFINE(HAVE_GNUC25_PRINTFFORMAT),
139    AC_MSG_RESULT(no)),
140  AC_MSG_RESULT(no))
141
142 AC_SUBST(CWARNS)
143 CWARNS=""
144
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
149  then
150   AC_CACHE_VAL($2,[
151    oldcflags="${CFLAGS-}"
152    CFLAGS="${CFLAGS-} ${CWARNS} $1 -Werror"
153    AC_TRY_COMPILE([
154 #include <string.h>
155 #include <stdio.h>
156 ],[
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"
162    AC_MSG_RESULT(ok)
163   else
164    $2=''
165    AC_MSG_RESULT(no)
166   fi
167  else
168   AC_MSG_RESULT(no, not using GCC)
169  fi
170 ])
171
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)
176
177 if test "${GCC-no}" = yes; then
178  CWARNS="${CWARNS} -Wmissing-prototypes -Wstrict-prototypes"
179 fi
180 [CFLAGS="`echo $CFLAGS $CWARNS | sed -e 's/-O[0-9]*/$(OPTIMISE)/'`"]
181
182 AC_SUBST(VERSION)
183 VERSION="`sed -n '/^userv (.*)/!d; s/^userv (//; s/).*//; p; q' debian/changelog`"
184 echo will build version $VERSION
185
186 AC_OUTPUT(Makefile)