chiark / gitweb /
@@ -19,6 +19,7 @@
[userv.git] / configure.in
1 #  userv - configure.in
2 #
3 #  Copyright (C)1996-1997,1999 Ian Jackson
4 #   
5 #  This is free software; you can redistribute it and/or modify it
6 #  under the terms of the GNU General Public License as published by
7 #  the Free Software Foundation; either version 2 of the License, or
8 #  (at your option) any later version.
9
10 #  This program is distributed in the hope that it will be useful, but
11 #  WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 #  General Public License for more details.
14
15 #  You should have received a copy of the GNU General Public License
16 #  along with userv; if not, write to the Free Software
17 #  Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 AC_INIT(language.i4)
20 AC_CONFIG_HEADER(config.h)
21
22 AC_PREFIX_DEFAULT(/usr/local)
23
24 crdir="`pwd`"
25 AC_SUBST(DEBUGDEFS)
26 AC_SUBST(DEBUGLIBS)
27 DEBUGDEFS=''
28 DEBUGLIBS=''
29 AC_ARG_ENABLE(debug,
30 [  --enable-debug          build debugging version],
31 [
32  if test "x$enable_debug" = xyes; then
33   DEBUGDEFS="-DDEBUG -DVARDIR='\"$crdir/vd\"' -DSYSTEMCONFIGDIR='\"$crdir/slash-etc\"' -DSERVICEUSERDIR='\"$crdir/tilde\"'"
34   DEBUGLIBS=-lefence
35   echo will build debugging version
36  elif test "x$enable_debug" != xno; then
37   AC_MSG_ERROR(--enable-debug does not allow any arguments except 'yes' and 'no')
38  fi
39 ])
40
41 AC_PROG_CC
42 AC_PROG_CPP
43 AC_PROG_INSTALL
44 AC_CHECK_PROGS(MD5SUM_SIMPLE, md5sum md5 gmd5sum)
45
46 CFLAGS="$CFLAGS -D_GNU_SOURCE"
47
48 AC_CHECK_LIB(socket,socket)
49 AC_CHECK_FUNCS(setenv)
50
51 AC_CACHE_CHECK(for EPROTO,userv_cv_hdr_eproto,
52  AC_EGREP_CPP(yes,
53 [
54 #include <errno.h>
55 #ifdef EPROTO
56  yes
57 #endif
58 ],userv_cv_hdr_eproto=yes,userv_cv_hdr_eproto=no))
59 if test $userv_cv_hdr_eproto = yes
60 then
61         AC_DEFINE(HAVE_EPROTO)
62 fi
63
64 AC_CACHE_CHECK(for LOG_AUTHPRIV,userv_cv_hdr_logauthpriv,
65  AC_EGREP_CPP(yes,
66 [
67 #include <syslog.h>
68 #ifdef LOG_AUTHPRIV
69  yes
70 #endif
71 ],userv_cv_hdr_logauthpriv=yes,userv_cv_hdr_logauthpriv=no))
72 if test $userv_cv_hdr_logauthpriv = yes
73 then
74         AC_DEFINE(HAVE_LOG_AUTHPRIV)
75 fi
76
77 AC_SUBST(OPTIMISE)
78 if test "${GCC-no}" = yes; then
79  OPTIMISE=-O2
80 else
81  OPTIMISE=-O
82 fi
83
84 dnl DPKG_CACHED_TRY_COMPILE(<description>,<cachevar>,<include>,<program>,<ifyes>,<ifno>)
85 define(DPKG_CACHED_TRY_COMPILE,[
86  AC_MSG_CHECKING($1)
87  AC_CACHE_VAL($2,[
88   AC_TRY_COMPILE([$3],[$4],[$2=yes],[$2=no])
89  ])
90  if test "x$$2" = xyes; then
91   true
92   $5
93  else
94   true
95   $6
96  fi
97 ])
98
99 DPKG_CACHED_TRY_COMPILE(your C compiler,dpkg_cv_c_works,
100  [#include <string.h>], [strcmp("a","b")],
101  AC_MSG_RESULT(works),
102  AC_MSG_RESULT(broken)
103  AC_MSG_ERROR(C compiler is broken))
104
105 DPKG_CACHED_TRY_COMPILE(__attribute__((,,)),dpkg_cv_c_attribute_supported,,
106  [extern int testfunction(int x) __attribute__((,,))],
107  AC_MSG_RESULT(yes)
108  AC_DEFINE(HAVE_GNUC25_ATTRIB)
109   DPKG_CACHED_TRY_COMPILE(__attribute__((noreturn)),dpkg_cv_c_attribute_noreturn,,
110    [extern int testfunction(int x) __attribute__((noreturn))],
111    AC_MSG_RESULT(yes)
112    AC_DEFINE(HAVE_GNUC25_NORETURN),
113    AC_MSG_RESULT(no))
114   DPKG_CACHED_TRY_COMPILE(__attribute__((unused)),dpkg_cv_c_attribute_unused,,
115    [extern int testfunction(int x) __attribute__((unused))],
116    AC_MSG_RESULT(yes)
117    AC_DEFINE(HAVE_GNUC25_UNUSED),
118    AC_MSG_RESULT(no))
119   DPKG_CACHED_TRY_COMPILE(__attribute__((format...)),dpkg_cv_attribute_format,,
120    [extern int testfunction(char *y, ...) __attribute__((format(printf,1,2)))],
121    AC_MSG_RESULT(yes)
122    AC_DEFINE(HAVE_GNUC25_PRINTFFORMAT),
123    AC_MSG_RESULT(no)),
124  AC_MSG_RESULT(no))
125
126 AC_SUBST(CWARNS)
127 CWARNS=""
128
129 dnl DPKG_C_GCC_TRY_WARNS(<warnings>,<cachevar>)
130 define(DPKG_C_GCC_TRY_WARNS,[
131  AC_MSG_CHECKING([GCC warning flag(s) $1])
132  if test "${GCC-no}" = yes
133  then
134   AC_CACHE_VAL($2,[
135    oldcflags="${CFLAGS-}"
136    CFLAGS="${CFLAGS-} ${CWARNS} $1 -Werror"
137    AC_TRY_COMPILE([
138 #include <string.h>
139 #include <stdio.h>
140 ],[
141     strcmp("a","b"); fprintf(stdout,"test ok\n");
142 ], [$2=yes], [$2=no])
143    CFLAGS="${oldcflags}"])
144   if test "x$$2" = xyes; then
145    CWARNS="${CWARNS} $1"
146    AC_MSG_RESULT(ok)
147   else
148    $2=''
149    AC_MSG_RESULT(no)
150   fi
151  else
152   AC_MSG_RESULT(no, not using GCC)
153  fi
154 ])
155
156 DPKG_C_GCC_TRY_WARNS(-Wall -Wno-implicit, dpkg_cv_c_gcc_warn_all)
157 DPKG_C_GCC_TRY_WARNS(-Wwrite-strings, dpkg_cv_c_gcc_warn_writestrings)
158 DPKG_C_GCC_TRY_WARNS(-Wpointer-arith, dpkg_cv_c_gcc_warn_pointerarith)
159 DPKG_C_GCC_TRY_WARNS(-Wimplicit -Wnested-externs, dpkg_cv_c_gcc_warn_implicit)
160
161 if test "${GCC-no}" = yes; then
162  CWARNS="${CWARNS} -Wmissing-prototypes -Wstrict-prototypes"
163 fi
164 [CFLAGS="`echo $CFLAGS $CWARNS | sed -e 's/-O[0-9]*/$(OPTIMISE)/'`"]
165
166 AC_SUBST(VERSION)
167 VERSION="`sed -n '/^userv (.*)/!d; s/^userv (//; s/).*//; p; q' debian/changelog`"
168 echo will build version $VERSION
169
170 AC_OUTPUT(Makefile)