chiark / gitweb /
Merge recent changelog entries.
[userv.git] / configure.in
1 #  userv - configure.in
2
3 #  Copyright (C)1996-1997 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
45 CFLAGS="$CFLAGS -D_GNU_SOURCE"
46
47 AC_CACHE_CHECK(for EPROTO,userv_cv_hdr_eproto,
48  AC_EGREP_CPP(yes,
49 [
50 #include <errno.h>
51 #ifdef EPROTO
52  yes
53 #endif
54 ],userv_cv_hdr_eproto=yes,userv_cv_hdr_eproto=no))
55 if test $userv_cv_hdr_eproto = yes
56 then
57         AC_DEFINE(HAVE_EPROTO)
58 fi
59
60 AC_SUBST(OPTIMISE)
61 if test "${GCC-no}" = yes; then
62  OPTIMISE=-O2
63 else
64  OPTIMISE=-O
65 fi
66
67 dnl DPKG_CACHED_TRY_COMPILE(<description>,<cachevar>,<include>,<program>,<ifyes>,<ifno>)
68 define(DPKG_CACHED_TRY_COMPILE,[
69  AC_MSG_CHECKING($1)
70  AC_CACHE_VAL($2,[
71   AC_TRY_COMPILE([$3],[$4],[$2=yes],[$2=no])
72  ])
73  if test "x$$2" = xyes; then
74   true
75   $5
76  else
77   true
78   $6
79  fi
80 ])
81
82 DPKG_CACHED_TRY_COMPILE(your C compiler,dpkg_cv_c_works,
83  [#include <string.h>], [strcmp("a","b")],
84  AC_MSG_RESULT(works),
85  AC_MSG_RESULT(broken)
86  AC_MSG_ERROR(C compiler is broken))
87
88 DPKG_CACHED_TRY_COMPILE(__attribute__((,,)),dpkg_cv_c_attribute_supported,,
89  [extern int testfunction(int x) __attribute__((,,))],
90  AC_MSG_RESULT(yes)
91  AC_DEFINE(HAVE_GNUC25_ATTRIB)
92   DPKG_CACHED_TRY_COMPILE(__attribute__((noreturn)),dpkg_cv_c_attribute_noreturn,,
93    [extern int testfunction(int x) __attribute__((noreturn))],
94    AC_MSG_RESULT(yes)
95    AC_DEFINE(HAVE_GNUC25_NORETURN),
96    AC_MSG_RESULT(no))
97   DPKG_CACHED_TRY_COMPILE(__attribute__((unused)),dpkg_cv_c_attribute_unused,,
98    [extern int testfunction(int x) __attribute__((unused))],
99    AC_MSG_RESULT(yes)
100    AC_DEFINE(HAVE_GNUC25_UNUSED),
101    AC_MSG_RESULT(no))
102   DPKG_CACHED_TRY_COMPILE(__attribute__((format...)),dpkg_cv_attribute_format,,
103    [extern int testfunction(char *y, ...) __attribute__((format(printf,1,2)))],
104    AC_MSG_RESULT(yes)
105    AC_DEFINE(HAVE_GNUC25_PRINTFFORMAT),
106    AC_MSG_RESULT(no)),
107  AC_MSG_RESULT(no))
108
109 AC_SUBST(CWARNS)
110 CWARNS=""
111
112 dnl DPKG_C_GCC_TRY_WARNS(<warnings>,<cachevar>)
113 define(DPKG_C_GCC_TRY_WARNS,[
114  AC_MSG_CHECKING([GCC warning flag(s) $1])
115  if test "${GCC-no}" = yes
116  then
117   AC_CACHE_VAL($2,[
118    oldcflags="${CFLAGS-}"
119    CFLAGS="${CFLAGS-} ${CWARNS} $1 -Werror"
120    AC_TRY_COMPILE([
121 #include <string.h>
122 #include <stdio.h>
123 ],[
124     strcmp("a","b"); fprintf(stdout,"test ok\n");
125 ], [$2=yes], [$2=no])
126    CFLAGS="${oldcflags}"])
127   if test "x$$2" = xyes; then
128    CWARNS="${CWARNS} $1"
129    AC_MSG_RESULT(ok)
130   else
131    $2=''
132    AC_MSG_RESULT(no)
133   fi
134  else
135   AC_MSG_RESULT(no, not using GCC)
136  fi
137 ])
138
139 DPKG_C_GCC_TRY_WARNS(-Wall -Wno-implicit, dpkg_cv_c_gcc_warn_all)
140 DPKG_C_GCC_TRY_WARNS(-Wwrite-strings, dpkg_cv_c_gcc_warn_writestrings)
141 DPKG_C_GCC_TRY_WARNS(-Wpointer-arith, dpkg_cv_c_gcc_warn_pointerarith)
142 DPKG_C_GCC_TRY_WARNS(-Wimplicit -Wnested-externs, dpkg_cv_c_gcc_warn_implicit)
143
144 if test "${GCC-no}" = yes; then
145  CWARNS="${CWARNS} -Wmissing-prototypes -Wstrict-prototypes -Werror"
146 fi
147 [CFLAGS="`echo $CFLAGS $CWARNS | sed -e 's/-O[0-9]*/$(OPTIMISE)/'`"]
148
149 AC_SUBST(VERSION)
150 VERSION="`sed -n '/^userv (.*)/!d; s/^userv (//; s/).*//; p; q' debian/changelog`"
151 echo will build version $VERSION
152
153 AC_OUTPUT(Makefile)