chiark / gitweb /
Initial CVS checkin.
[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  elif test "x$enable_debug" != xno; then
36   AC_MSG_ERROR(--enable-debug does not allow any arguments except 'yes' and 'no')
37  fi
38 ])
39
40 AC_PROG_CC
41 AC_SYS_LONG_FILE_NAMES
42
43 AC_SUBST(OPTIMISE)
44 if test "${GCC-no}" = yes; then
45  OPTIMISE=-O2
46 else
47  OPTIMISE=-O
48 fi
49
50 dnl DPKG_CACHED_TRY_COMPILE(<description>,<cachevar>,<include>,<program>,<ifyes>,<ifno>)
51 define(DPKG_CACHED_TRY_COMPILE,[
52  AC_MSG_CHECKING($1)
53  AC_CACHE_VAL($2,[
54   AC_TRY_COMPILE([$3],[$4],[$2=yes],[$2=no])
55  ])
56  if test "x$$2" = xyes; then
57   true
58   $5
59  else
60   true
61   $6
62  fi
63 ])
64
65 DPKG_CACHED_TRY_COMPILE(your C compiler,dpkg_cv_c_works,
66  [#include <string.h>], [strcmp("a","b")],
67  AC_MSG_RESULT(works),
68  AC_MSG_RESULT(broken)
69  AC_MSG_ERROR(C compiler is broken))
70
71 DPKG_CACHED_TRY_COMPILE(__attribute__((,,)),dpkg_cv_c_attribute_supported,,
72  [extern int testfunction(int x) __attribute__((,,))],
73  AC_MSG_RESULT(yes)
74  AC_DEFINE(HAVE_GNUC25_ATTRIB)
75   DPKG_CACHED_TRY_COMPILE(__attribute__((noreturn)),dpkg_cv_c_attribute_noreturn,,
76    [extern int testfunction(int x) __attribute__((noreturn))],
77    AC_MSG_RESULT(yes)
78    AC_DEFINE(HAVE_GNUC25_NORETURN),
79    AC_MSG_RESULT(no))
80   DPKG_CACHED_TRY_COMPILE(__attribute__((const)),dpkg_cv_c_attribute_const,,
81    [extern int testfunction(int x) __attribute__((const))],
82    AC_MSG_RESULT(yes)
83    AC_DEFINE(HAVE_GNUC25_CONST),
84    AC_MSG_RESULT(no))
85   DPKG_CACHED_TRY_COMPILE(__attribute__((format...)),dpkg_cv_attribute_format,,
86    [extern int testfunction(char *y, ...) __attribute__((format(printf,1,2)))],
87    AC_MSG_RESULT(yes)
88    AC_DEFINE(HAVE_GNUC25_PRINTFFORMAT),
89    AC_MSG_RESULT(no)),
90  AC_MSG_RESULT(no))
91
92 AC_SUBST(CWARNS)
93 CWARNS=""
94
95 dnl DPKG_C_GCC_TRY_WARNS(<warnings>,<cachevar>)
96 define(DPKG_C_GCC_TRY_WARNS,[
97  AC_MSG_CHECKING([GCC warning flag(s) $1])
98  if test "${GCC-no}" = yes
99  then
100   AC_CACHE_VAL($2,[
101    oldcflags="${CFLAGS-}"
102    CFLAGS="${CFLAGS-} ${CWARNS} $1 -Werror"
103    AC_TRY_COMPILE([
104 #include <string.h>
105 #include <stdio.h>
106 ],[
107     strcmp("a","b"); fprintf(stdout,"test ok\n");
108 ], [$2=yes], [$2=no])
109    CFLAGS="${oldcflags}"])
110   if test "x$$2" = xyes; then
111    CWARNS="${CWARNS} $1"
112    AC_MSG_RESULT(ok)
113   else
114    $2=''
115    AC_MSG_RESULT(no)
116   fi
117  else
118   AC_MSG_RESULT(no, not using GCC)
119  fi
120 ])
121
122 DPKG_C_GCC_TRY_WARNS(-Wall -Wno-implicit, dpkg_cv_c_gcc_warn_all)
123 DPKG_C_GCC_TRY_WARNS(-Wwrite-strings, dpkg_cv_c_gcc_warn_writestrings)
124 DPKG_C_GCC_TRY_WARNS(-Wpointer-arith, dpkg_cv_c_gcc_warn_pointerarith)
125 DPKG_C_GCC_TRY_WARNS(-Wimplicit -Wnested-externs, dpkg_cv_c_gcc_warn_implicit)
126
127 if test "${GCC-no}" = yes; then
128  CWARNS="${CWARNS} -Wmissing-prototypes -Wstrict-prototypes -Werror"
129 fi
130 [CFLAGS="`echo $CFLAGS $CWARNS | sed -e 's/-O[0-9]*/$(OPTIMISE)/'`"]
131
132 AC_OUTPUT(Makefile)