/ circle3.1 / cnf / configure.in
configure.in
  1  dnl Process this file with autoconf to produce a configure script.
  2  AC_INIT(src/act.comm.c)
  3  AC_SUBST(MYFLAGS)
  4  AC_SUBST(NETLIB)
  5  AC_SUBST(CRYPTLIB)
  6  
  7  AC_CONFIG_HEADER(src/conf.h)
  8  AC_DEFINE(CIRCLE_UNIX)
  9  
 10  dnl Find the 'more' program
 11  AC_CHECK_PROGS(MORE, less most more cat)
 12  
 13  dnl Checks for programs.
 14  AC_PROG_CC
 15  
 16  dnl If we're using gcc, use gcc options.
 17  dnl If not, test for various common switches to make a 'cc' compiler
 18  dnl compile ANSI C code.
 19  if test $ac_cv_prog_gcc = yes; then
 20  
 21    dnl Determine if gcc -Wall causes warnings on isascii(), etc.
 22    AC_CACHE_CHECK(whether ${CC-cc} -Wall also needs -Wno-char-subscripts,
 23  	ac_cv_char_warn,
 24    [
 25      OLDCFLAGS=$CFLAGS
 26      CFLAGS="$CFLAGS -Wall -Werror"
 27      AC_TRY_COMPILE([#include <ctype.h>],
 28         [ int i; char c = '0';
 29           i = isascii(c);
 30           i = isdigit(c);
 31           i = isprint(c);
 32         ], ac_cv_char_warn=no, ac_cv_char_warn=yes)
 33      CFLAGS=$OLDCFLAGS
 34    ])
 35  
 36    dnl If Determine if gcc can accept -Wno-char-subscripts
 37    AC_CACHE_CHECK(whether ${CC-cc} accepts -Wno-char-subscripts, ac_cv_gcc_ncs,
 38    [
 39      OLDCFLAGS=$CFLAGS
 40      CFLAGS="$CFLAGS -Wno-char-subscripts"
 41      AC_TRY_COMPILE(, , ac_cv_gcc_ncs=yes, ac_cv_gcc_ncs=no)
 42      CFLAGS=$OLDCFLAGS
 43    ])
 44  
 45    dnl If Determine if gcc can accept -fno-builtin
 46    AC_CACHE_CHECK(whether ${CC-cc} accepts -fno-builtin, ac_cv_gcc_fnb,
 47    [
 48      OLDCFLAGS=$CFLAGS
 49      CFLAGS="$CFLAGS -fno-builtin"
 50      AC_TRY_COMPILE(, , ac_cv_gcc_fnb=yes, ac_cv_gcc_fnb=no)
 51      CFLAGS=$OLDCFLAGS
 52    ])
 53  
 54    dnl If gcc -Wall gives no warnings with isascii(), use "-Wall";
 55    dnl Otherwise, if gcc -Wall gives isascii warnings:
 56    dnl    If we can use -Wno-char-subscripts, use "-Wall -Wno-char-subscripts"
 57    dnl    If can't use -Wno-char-subscripts, use no flags at all.
 58  
 59    if test ${ac_cv_char_warn:-ERROR} = no; then
 60      MYFLAGS="-Wall"
 61    else
 62      if test ${ac_cv_gcc_ncs:-ERROR} = yes; then
 63        MYFLAGS="-Wall -Wno-char-subscripts"
 64      else
 65        MYFLAGS=""
 66      fi
 67    fi
 68  
 69  else
 70    dnl We aren't using gcc so we can't assume any special flags.
 71    MYFLAGS=""
 72  
 73  fi
 74  
 75  dnl Checks for libraries.  We check for the library only if the function is
 76  dnl not available without the library.
 77  AC_CHECK_FUNC(gethostbyaddr, ,
 78      [AC_CHECK_LIB(nsl, gethostbyaddr, NETLIB="-lnsl $NETLIB")])
 79  
 80  AC_CHECK_FUNC(socket, ,
 81      [AC_CHECK_LIB(socket, socket, NETLIB="-lsocket $NETLIB")])
 82  
 83  AC_CHECK_FUNC(malloc, ,
 84      [AC_CHECK_LIB(malloc, malloc)])
 85  
 86  AC_CHECK_FUNC(crypt, AC_DEFINE(CIRCLE_CRYPT),
 87      [AC_CHECK_LIB(crypt, crypt, AC_DEFINE(CIRCLE_CRYPT) CRYPTLIB="-lcrypt")]
 88      )
 89  
 90  dnl Checks for header files.
 91  AC_HEADER_STDC
 92  AC_HEADER_SYS_WAIT
 93  AC_CHECK_HEADERS(fcntl.h sys/fcntl.h errno.h net/errno.h string.h strings.h)
 94  AC_CHECK_HEADERS(limits.h sys/time.h sys/select.h sys/types.h unistd.h)
 95  AC_CHECK_HEADERS(memory.h crypt.h assert.h arpa/telnet.h arpa/inet.h)
 96  AC_CHECK_HEADERS(sys/stat.h sys/socket.h sys/resource.h netinet/in.h netdb.h)
 97  AC_CHECK_HEADERS(signal.h sys/uio.h mcheck.h)
 98  
 99  AC_UNSAFE_CRYPT
100  
101  dnl Checks for typedefs, structures, and compiler characteristics.
102  AC_C_CONST
103  AC_TYPE_PID_T
104  AC_TYPE_SIZE_T
105  AC_CHECK_TYPE(ssize_t, int)
106  AC_HEADER_TIME
107  
108  dnl Check for the 'struct in_addr' definition. Ugly, yes.
109  if test $ac_cv_header_netinet_in_h = no; then
110    ac_cv_struct_in_addr = no
111  else
112    if test $ac_cv_header_sys_types_h = yes; then
113      headers=`cat << EOF
114  #include <sys/types.h>
115  #include <netinet/in.h>
116  EOF
117  `
118    else
119      headers="#include <netinet/in.h>"
120    fi
121  
122    AC_CACHE_CHECK([for struct in_addr], ac_cv_struct_in_addr,
123      [ AC_TRY_COMPILE([$headers],[struct in_addr tp; tp.s_addr;], ac_cv_struct_in_addr=yes, ac_cv_struct_in_addr=no)])
124  
125    if test $ac_cv_struct_in_addr = yes; then
126      AC_DEFINE(HAVE_STRUCT_IN_ADDR)
127    fi
128  fi
129  
130  
131  dnl Check for the 'typedef socklen_t' definition. Even uglier, yes.
132  if test $ac_cv_header_sys_socket_h = no; then
133    ac_cv_socklen_t = no;
134  else
135    AC_CACHE_CHECK([for typedef socklen_t], ac_cv_socklen_t,
136      [ AC_TRY_COMPILE([#include <sys/socket.h>],[socklen_t sl; sl=0;], ac_cv_socklen_t=yes, ac_cv_socklen_t=no)])
137  fi
138  
139  if test $ac_cv_socklen_t = no; then
140    AC_DEFINE(socklen_t, int)
141  fi
142  
143  
144  dnl Checks for library functions.
145  AC_TYPE_SIGNAL
146  AC_FUNC_VPRINTF
147  AC_CHECK_FUNCS(gettimeofday select snprintf strcasecmp strdup strerror stricmp strlcpy strncasecmp strnicmp strstr vsnprintf)
148  
149  dnl Check for functions that parse IP addresses
150  ORIGLIBS=$LIBS
151  LIBS="$LIBS $NETLIB"
152  AC_CHECK_FUNCS(inet_addr inet_aton)
153  LIBS=$ORIGLIBS
154  
155  dnl Check for prototypes
156  AC_CHECK_PROTO(accept)
157  AC_CHECK_PROTO(atoi)
158  AC_CHECK_PROTO(atol)
159  AC_CHECK_PROTO(bind)
160  AC_CHECK_PROTO(bzero)
161  AC_CHECK_PROTO(chdir)
162  AC_CHECK_PROTO(close)
163  AC_CHECK_PROTO(crypt)
164  AC_CHECK_PROTO(fclose)
165  AC_CHECK_PROTO(fcntl)
166  AC_CHECK_PROTO(fflush)
167  AC_CHECK_PROTO(fprintf)
168  AC_CHECK_PROTO(fputc)
169  AC_CHECK_PROTO(fputs)
170  AC_CHECK_PROTO(fread)
171  AC_CHECK_PROTO(fscanf)
172  AC_CHECK_PROTO(fseek)
173  AC_CHECK_PROTO(fwrite)
174  AC_CHECK_PROTO(getpeername)
175  AC_CHECK_PROTO(getpid)
176  AC_CHECK_PROTO(getrlimit)
177  AC_CHECK_PROTO(getsockname)
178  AC_CHECK_PROTO(gettimeofday)
179  AC_CHECK_PROTO(htonl)
180  AC_CHECK_PROTO(htons)
181  AC_CHECK_PROTO(inet_addr)
182  AC_CHECK_PROTO(inet_aton)
183  AC_CHECK_PROTO(inet_ntoa)
184  AC_CHECK_PROTO(listen)
185  AC_CHECK_PROTO(ntohl)
186  AC_CHECK_PROTO(perror)
187  AC_CHECK_PROTO(printf)
188  AC_CHECK_PROTO(qsort)
189  AC_CHECK_PROTO(read)
190  AC_CHECK_PROTO(remove)
191  AC_CHECK_PROTO(rewind)
192  AC_CHECK_PROTO(select)
193  AC_CHECK_PROTO(setitimer)
194  AC_CHECK_PROTO(setrlimit)
195  AC_CHECK_PROTO(setsockopt)
196  AC_CHECK_PROTO(snprintf)
197  AC_CHECK_PROTO(socket)
198  AC_CHECK_PROTO(sprintf)
199  AC_CHECK_PROTO(sscanf)
200  AC_CHECK_PROTO(strcasecmp)
201  AC_CHECK_PROTO(strdup)
202  AC_CHECK_PROTO(strerror)
203  AC_CHECK_PROTO(stricmp)
204  AC_CHECK_PROTO(strlcpy)
205  AC_CHECK_PROTO(strncasecmp)
206  AC_CHECK_PROTO(strnicmp)
207  AC_CHECK_PROTO(system)
208  AC_CHECK_PROTO(time)
209  AC_CHECK_PROTO(unlink)
210  AC_CHECK_PROTO(vsnprintf)
211  AC_CHECK_PROTO(write)
212  
213  AC_OUTPUT(src/Makefile src/util/Makefile)
214  #
215  echo "Configuration completed.  To compile, type:  cd src; make"