source: branches/ithildin-1.1/autoconf/configure.ac @ 819

Revision 819, 17.2 KB checked in by wd, 4 years ago (diff)

Disable custom libc code by default.

  • Property svn:keywords set to Id Rev
Line 
1dnl ------------------------------------------------------------------------
2dnl configure.in: GNU autoconf script generator.
3dnl
4dnl Copyright 2002-2005 the Ithildin Project.
5dnl See the COPYING file for more information on licensing and use.
6AC_REVISION($Id$)
7dnl ------------------------------------------------------------------------
8AC_INIT(ithildin, 1.1, wd@ithildin.org, ithildin)
9
10AC_CONFIG_AUX_DIR(autoconf)
11AC_CONFIG_HEADER(include/config.h)
12AC_PREFIX_DEFAULT(/usr/local)
13
14dnl ------------------------------------------------------------------------
15dnl Get the version number/name/etc
16dnl ------------------------------------------------------------------------
17PACKAGE=ithildin
18
19VERSION=`grep -E '^#define BASENAME_VER' include/ithildin/stand.h | sed s/'.define BASENAME_VER '// | sed s/'\"'//g | xargs echo -n`
20VERSION="$VERSION-`grep -E '^#define MAJOR_VER' include/ithildin/stand.h | sed s/'.define MAJOR_VER '// | xargs echo -n`"
21VERSION="$VERSION.`grep -E '^#define MINOR_VER' include/ithildin/stand.h | sed s/'.define MINOR_VER '// | xargs echo -n`"
22VERSION="$VERSION.`grep -E '^#define PATCH_VER' include/ithildin/stand.h | sed s/'.define PATCH_VER '// | xargs echo -n`"
23
24AC_SUBST(PACKAGE)
25AC_SUBST(VERSION)
26
27dnl ------------------------------------------------------------------------
28dnl Check for machine/vendor/operating system type
29dnl ------------------------------------------------------------------------
30AC_CANONICAL_HOST
31
32dnl ------------------------------------------------------------------------
33dnl Checks for programs.
34dnl ------------------------------------------------------------------------
35AC_PROG_CC
36ICC=no
37AC_MSG_CHECKING([whether we are using the Intel C Compiler])
38case `$CC -V 2>&1` in
39    *Intel*)
40        AC_MSG_RESULT([yes])
41        ICC=yes
42    ;;
43    *)
44        AC_MSG_RESULT([no])
45    ;;
46esac
47AC_PROG_INSTALL
48AC_PROG_LN_S
49AC_PROG_MAKE_SET
50AC_CHECK_PROG(RM, rm, rm)
51
52dnl ------------------------------------------------------------------------
53dnl Checks for libraries.
54dnl ------------------------------------------------------------------------
55found_dlopen="yes"
56AC_CHECK_LIB(dl, dlopen,, found_dlopen="no")
57AC_CHECK_LIB(nsl, gethostbyname)
58AC_CHECK_LIB(socket, socket)
59
60dnl ------------------------------------------------------------------------
61dnl Checks for header files.
62dnl ------------------------------------------------------------------------
63AC_HEADER_STDC
64AC_CHECK_HEADERS(assert.h dl.h dlfcn.h errno.h fcntl.h features.h grp.h)
65AC_CHECK_HEADERS(limits.h math.h netdb.h pwd.h unistd.h stdbool.h)
66AC_CHECK_HEADERS(arpa/inet.h)
67AC_CHECK_HEADERS(machine/endian.h)
68AC_CHECK_HEADERS(netinet/in.h)
69AC_CHECK_HEADERS(sys/mman.h sys/resource.h sys/socket.h sys/stat.h sys/time.h)
70AC_HEADER_TIME
71
72dnl ------------------------------------------------------------------------
73dnl Checks for typedefs, structures, and compiler characteristics.
74dnl ------------------------------------------------------------------------
75AC_C_CONST
76if test "$ac_cv_header_machine_endian_h" = "no" ; then
77    AC_C_BIGENDIAN
78fi
79AC_TYPE_PID_T
80AC_TYPE_SIZE_T
81AC_CHECK_SIZEOF(short)
82AC_CHECK_SIZEOF(int)
83AC_CHECK_SIZEOF(long)
84AC_CHECK_SIZEOF(long long)
85if test "$ac_cv_sizeof_short" = "2" ; then
86    AC_CHECK_TYPE(int16_t, short)
87    AC_CHECK_TYPE(uint16_t, unsigned short)
88else
89    if test "$ac_cv_sizeof_int" = "2" ; then
90        AC_CHECK_TYPE(int16_t, int)
91        AC_CHECK_TYPE(uint16_t, unsigned int)
92    else
93        AC_MSG_ERROR([I can't seem to find a 2 byte integer on your system!])
94    fi
95fi
96if test "$ac_cv_sizeof_int" = "4" ; then
97    AC_CHECK_TYPE(int32_t, int)
98    AC_CHECK_TYPE(uint32_t, unsigned int)
99else
100    if test "$ac_cv_sizeof_long" = "4" ; then
101        AC_CHECK_TYPE(int32_t, long)
102        AC_CHECK_TYPE(uint32_t, unsigned long)
103    else
104        AC_MSG_ERROR([I can't seem to find a 4 byte integer on your system!])
105    fi
106fi
107if test "$ac_cv_sizeof_long_long" = "8" ; then
108    AC_CHECK_TYPE(int64_t, long long)
109    AC_CHECK_TYPE(uint64_t, unsigned long long)
110else
111    if test "$ac_cv_sizeof_long" = "8" ; then
112        AC_CHECK_TYPE(int64_t, long long)
113        AC_CHECK_TYPE(uint64_t, unsigned long)
114    else
115        AC_MSG_ERROR([I can't seem to find an 8 byte integer on your system!])
116    fi
117fi
118AC_C_LONG_DOUBLE
119AC_C_INLINE
120
121if test "$ac_cv_c_inline" = "no" ; then
122    AC_MSG_ERROR([Your compiler has no inline support.])
123fi
124
125dnl ------------------------------------------------------------------------
126dnl Checks for library functions.
127dnl ------------------------------------------------------------------------
128AC_FUNC_VPRINTF
129AC_CHECK_FUNCS(strdup strerror strtod strtol strsep vsnprintf)
130AC_CHECK_FUNCS(getcwd gettimeofday usleep)
131if test "$found_dlopen" = "no" ; then
132    AC_CHECK_FUNCS(dlopen)
133fi
134
135if test "$ac_cv_func_dlopen" = "no" ; then
136    AC_MSG_ERROR([your system does not have dynamic library functions, you will be unable to use this software, sorry.])
137fi
138
139dnl -----
140dnl look for 'fmtcheck' (on FreeBSD and NetBSD at least).  If it's not there
141dnl use the contrib/ bits.  Also look for 'strlcpy' (a similar BSD call)
142dnl -----
143AC_CHECK_FUNCS(fmtcheck strlcat strlcpy)
144
145dnl ----
146dnl socket functions
147dnl ----
148AC_CHECK_FUNCS(kqueue poll select socket)
149AC_CHECK_FUNCS(recv send setsockopt)
150
151dnl ----
152dnl stuff for malloc
153dnl ----
154AC_CHECK_FUNCS(mmap munmap madvise brk sbrk)
155AC_CHECK_FUNCS(readlink getenv)
156
157dnl ----
158dnl some stuff for changing user ids
159dnl ----
160AC_CHECK_FUNCS(setuid seteuid setreuid setgid setegid setgroups)
161AC_CHECK_FUNCS(geteuid getuid getgid getpwnam getgrnam)
162
163dnl ----
164dnl stuff to change coredump sizes
165dnl ----
166AC_CHECK_FUNCS(getrlimit setrlimit)
167
168dnl ------------------------------------------------------------------------
169dnl try to figure out the 'page shift' of the system by executing a test
170dnl program which returns that count.  in our case a non-zero return
171dnl actually means success
172dnl ------------------------------------------------------------------------
173AC_MSG_CHECKING([the system's memory page size])
174pagesize="no"
175AC_TRY_RUN([
176#include <stdio.h>
177#if HAVE_UNISTD_H
178# include <unistd.h>
179#endif
180
181int main(void) {
182    FILE *fp = fopen("conftest.malloc", "w");
183
184    if (fp != NULL) {
185        fprintf(fp, "%d\n", getpagesize());
186        fclose(fp);
187    } else
188        exit(1);
189    exit(0);
190}],[
191if test -f "conftest.malloc" ; then
192    pagesize=`cat conftest.malloc`
193fi
194])
195if test "$pagesize" != "no" ; then
196    AC_MSG_RESULT($pagesize)
197else
198    if test "$ac_cv_sizeof_int" = "4" ; then
199        pagesize=4096
200    else
201        pagesize=8192
202    fi
203    AC_MSG_RESULT([$pagesize (guessing)])
204fi
205AC_DEFINE_UNQUOTED(MALLOC_PAGESIZE, $pagesize,
206    [the system's memory page size])
207
208dnl ------------------------------------------------------------------------
209dnl various malloc tests:
210dnl - see if we can override the system malloc
211dnl - see if we can use mmap and sbrk/brk
212dnl ------------------------------------------------------------------------
213AC_MSG_CHECKING([whether erobbins will hate me (override system malloc?)])
214malloc_alternatives="no"
215AC_TRY_RUN([
216int okay = 0;
217#define malloc test_malloc
218char *test_malloc(int size) {
219    okay = size;
220    return (char *)0;
221}
222int main(void) {
223    malloc(42);
224    if (okay)
225        exit(0);
226    exit(1);
227}],[malloc_override="yes"])
228if test "$ac_cv_func_sbrk" = "yes" -a "$ac_cv_func_brk" = "yes" -a \
229    "$ac_cv_func_mmap" = "yes" -a "$ac_cv_func_munmap" = yes ; then
230    AC_DEFINE(MALLOC_LOWLEVEL, 1, [Really do low level malloc management])
231    malloc_alternatives="yes"
232fi
233
234if test "$malloc_override" = "yes" -a "$malloc_alternatives" = "yes" ; then
235    AC_DEFINE(MALLOC_OVERRIDE, 1, [Go ahead and override the system malloc])
236    AC_MSG_RESULT([yes])
237else
238    AC_MSG_RESULT([no])
239fi
240
241dnl ------------------------------------------------------------------------
242dnl Below are checks to determine how to do shared object support
243dnl for making shared libraries and stuff like that.  This has been borrowed
244dnl or based on various projects I've seen floating around.
245dnl ------------------------------------------------------------------------
246CCDLL="${CC}"
247tldf=$LDFLAGS
248AC_MSG_CHECKING(for the -export-dynamic ld flag)
249LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
250AC_TRY_LINK(, [int i;], found=yes, found=no)
251AC_MSG_RESULT($found)
252if test "$found" = "no" ; then
253    LDFLAGS=$tldf
254fi
255
256if test -n "$GCC" ; then
257    CFLAGSDLL="${CFLAGSDLL} -fPIC -DPIC -shared"
258    else if test -n "$ICC" ; then
259        CFLAGSDLL="${CFLAGSDLL} -KPIC -DPIC -shared"
260    fi
261fi
262
263LDFLAGSDLL="-shared"
264
265tldf=$LDFLAGS
266AC_MSG_CHECKING(for the -nostdlib compiler flag)
267LDFLAGS="${LDFLAGS} -nostdlib"
268AC_TRY_LINK(, [int i;], found=yes, found=no)
269AC_MSG_RESULT($found)
270if test "$found" = "yes" ; then
271    LDFLAGSDLL="$LDFLAGSDLL -nostdlib"
272fi
273LDFLAGS=$tldf
274
275AC_SUBST(CCDLL)
276AC_SUBST(CFLAGSDLL)
277AC_SUBST(LDFLAGSDLL)
278 
279dnl -------------------------------------------------------------------
280dnl Choose our type of socket handling.  the default is to use select()
281dnl we add the --with argument first so the user can manually select,
282dnl if desired.  in this case no checks as to the validity of their
283dnl selection are made.
284dnl -------------------------------------------------------------------
285POLLER=""
286AC_ARG_WITH(poller,
287    AC_HELP_STRING([--with-poller=x],
288        [set the poller to x (one of select, poll, kqueue, devpoll)]),
289    POLLER="$with_poller"
290    ithildin_cv_poller="$POLLER"
291)
292
293AC_CACHE_CHECK([for which polling function to use], ithildin_cv_poller,
294[
295
296if test "x$POLLER" = "x" ; then
297    case "$host_os" in
298        freebsd*|netbsd*|openbsd*)
299            if test "$ac_cv_func_kqueue" = "yes" ; then
300                POLLER=kqueue
301            fi
302        ;;
303        solaris*|sunos*|linux*)
304            if test -e /dev/poll ; then
305                POLLER=/dev/poll
306            fi
307        ;;
308    esac
309
310    if test -z "$POLLER" ; then
311        if test "$ac_cv_func_select" = "yes" ; then
312            POLLER=select
313        else
314            if test "$ac_cv_func_poll" = "yes" ; then
315                POLLER=poll
316            else
317                AC_MSG_ERROR(
318        [your system doesn't seem to have select or poll, or any other
319        method by which to check socket activity.  this daemon will not
320        function, sorry.])
321            fi
322        fi
323    fi
324fi
325ithildin_cv_poller="$POLLER"
326])
327
328POLLER="$ithildin_cv_poller"
329case "$POLLER" in
330    select)
331        AC_DEFINE(POLLER_SELECT, 1, [The select() system call])
332    ;;
333    poll)
334        AC_DEFINE(POLLER_POLL, 1, [The poll() system call])
335    ;;
336    kqueue)
337        AC_DEFINE(POLLER_KQUEUE, 1, [The kqueue() system call])
338    ;;
339    devpoll)
340        AC_DEFINE(POLLER_DEVPOLL, 1, [The /dev/poll device])
341    ;;
342    *)
343        AC_MSG_ERROR([The poller "$POLLER" is not supported by this system,
344try again?])
345    ;;
346esac
347AC_SUBST(POLLER)
348
349dnl ------------------------------------------------------------------------
350dnl this function is used for pretty output generation.
351dnl ------------------------------------------------------------------------
352ith_feature_append () {
353    if test -z "$extra_features" ; then
354        extra_features="$*"
355    else
356        extra_features="${extra_features}, $*"
357    fi
358}
359   
360dnl ------------------------------------------------------------------------
361dnl IPv6 checks
362dnl ------------------------------------------------------------------------
363
364dnl look for getaddrinfo and company.
365AC_CHECK_FUNCS(getaddrinfo getnameinfo)
366AC_CHECK_FUNCS(inet_ntoa getservbyport)
367AC_CHECK_FUNCS(inet_ntop inet_pton)
368
369AC_ARG_WITH(ipv6,
370    AC_HELP_STRING([--with-ipv6],
371        [enable IPv6 support]),
372    [if test -z "$withval" ; then
373        with_ipv6="yes"
374    fi]
375)
376
377if test "x$with_ipv6" != "xno" ; then
378    AC_MSG_CHECKING([whether to support IPv6])
379    if test "$ac_cv_func_getaddrinfo" = "no" ; then
380        AC_MSG_RESULT([no])
381    else
382        AC_DEFINE(INET6, 1, [IPv6 network protocol support])
383        AC_MSG_RESULT([yes])
384        ith_feature_append IPv6 support
385    fi
386else
387    AC_MSG_RESULT([no])
388fi
389
390dnl ------------------------------------------------------------------------
391dnl OpenSSL checks (code based on borrows from various places)
392dnl ------------------------------------------------------------------------
393AC_ARG_WITH(openssl,
394    AC_HELP_STRING([--with-openssl=PATH],
395        [use the OpenSSL library (PATH is OpenSSL's install prefix)]),
396    [if test -z "$withval" ; then
397        with_openssl="yes"
398    fi]
399)
400
401if test "x$with_openssl" != "xno" ; then
402    if test "x$with_openssl" = "xyes" -o -z "$with_openssl" ; then
403        AC_MSG_CHECKING([for an OpenSSL installation])
404    else
405        openssl_dirs="$with_openssl"
406        AC_MSG_CHECKING([for an OpenSSL installation in $with_openssl])
407    fi
408
409    old_LIBS="$LIBS"
410    old_CFLAGS="$CFLAGS"
411    LIBS="$LIBS -lssl -lcrypto"
412    AC_TRY_LINK([#include <openssl/ssl.h>],[SSL_accept(NULL);],
413        have_openssl="yes")
414
415    if test -z "$have_openssl" ; then
416        for dir in "$openssl_dirs" /usr/local /usr/ssl /usr/openssl \
417                /usr/local/ssl /usr/local/openssl ; do
418            if test -n "$have_openssl" -o -z "$dir"; then
419                break;
420            fi
421
422            if test -f "$dir/include/openssl/ssl.h" -a -f \
423                    "$ssldir/lib/libssl.a" ; then
424                CFLAGS="$CFLAGS -I$dir/include"
425                LIBS="$old_LIBS -L$dir/lib -lssl -lcrypto"
426                AC_TRY_LINK([#include <openssl/ssl.h>],[SSL_accept(NULL);],
427                    have_openssl="yes")
428            fi
429        done
430    fi
431
432    if test -n "$have_openssl" ; then
433        AC_DEFINE(HAVE_OPENSSL, 1, [OpenSSL Library Support])
434        AC_MSG_RESULT(found)
435        ith_feature_append SSL support
436    else
437        CLFAGS="$old_CFLAGS"
438        LIBS="$old_LIBS"
439        AC_MSG_RESULT(not found)
440    fi
441fi
442
443dnl ------------------------------------------------------------------------
444dnl Local configuration stuff below
445dnl ------------------------------------------------------------------------
446MODULES="*"
447AC_ARG_WITH(modules,
448    AC_HELP_STRING([--with-modules="list"],
449        [list of modules to build and install (defaults to * in modules/)]),
450    if test -n "$withval " ; then
451        if test "$withval" != "yes" -a "$withval" != "no" ; then
452            MODULES="$withval"
453        fi
454    fi
455)
456AC_SUBST(MODULES)
457AC_ARG_WITH(dmalloc,
458    AC_HELP_STRING([--with-dmalloc=PATH],
459        [use the debug malloc library (PATH is dmalloc's install prefix)]),
460    if test "x$withval" != "no" ; then
461        if test -z "$withval" -o "x$withval" = "xyes" ; then
462            dmallocdir="/usr/local"
463        else
464            dmallocdir="$withval"
465        fi
466        LDFLAGS="$LDFLAGS -L$dmallocdir/lib"
467        CFLAGS="$CFLAGS -I$dmallocdir/include"
468        AC_CHECK_LIB(dmalloc, dmalloc_verify,,
469            AC_MSG_ERROR([I cannot find the dmalloc library on your system]))
470        AC_DEFINE(USE_DMALLOC, 1, [dmalloc library support])
471    fi
472)
473AC_ARG_ENABLE(debug,
474    AC_HELP_STRING([--enable-debug],
475        [enable debugging in code (changes CFLAGS, adds code)]),
476    if test -n "$GCC" ; then
477        CFLAGS="$CFLAGS -O0 -g3 -Wall -Wshadow -Wmissing-declarations -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Winline -Wbad-function-cast"
478    fi
479    AC_DEFINE(DEBUG_CODE, 1, [Extra debugging instructions])
480)
481AC_ARG_ENABLE(custom-libc,
482    AC_HELP_STRING([--enable-custom-libc],
483        [enable custom libc functions (may not work on all systems)]),
484    ith_feature_append internal libc functions,
485    AC_DEFINE(NO_INTERNAL_LIBC, 1, [No internal libc functions]),
486)
487AC_ARG_ENABLE(fd-setsize,
488    AC_HELP_STRING([--enable-fd-setsize],
489        [set FD_SETSIZE to the specified value (useful only if your system is
490using select() and you you want more file descriptors to work)]),
491    AC_DEFINE_UNQUOTED(FD_SETSIZE, $enable_fd_setsize,
492        [the size of FD_SETSIZE]),
493)
494
495DIRSUFFIX="/$PACKAGE"
496AC_ARG_ENABLE(dir-suffix,
497    AC_HELP_STRING([--disable-dir-suffix],
498        [keep 'make install' from appending the package name to target
499installation directories]),
500    DIRSUFFIX=""
501)
502AC_SUBST(DIRSUFFIX)
503
504AC_OUTPUT(Makefile source/Makefile modules/Makefile)
505
506dnl ------------------------------------------------------------------------
507dnl finally, output our configuration to the user.
508dnl ------------------------------------------------------------------------
509
510eval "realbin=${bindir}"
511eval "realbin=${realbin}"
512eval "reallib=${libdir}${DIRSUFFIX}"
513eval "reallib=${reallib}"
514eval "realconf=${sysconfdir}${DIRSUFFIX}"
515eval "realconf=${realconf}"
516eval "realdata=${datadir}${DIRSUFFIX}"
517eval "realdata=${realdata}"
518
519AC_MSG_RESULT([
520ithildin configuration
521-----------------------])
522    echo "ithildin version       : ${VERSION}"
523    echo "host system            : ${host_cpu}-${host_vendor}-${host_os}"
524    echo "compiler               : ${CC}"
525    echo "compiler flags         : ${CFLAGS}"
526    echo "module compiler flags  : ${CFLAGS} ${CFLAGSDLL}"
527    echo "linker flags           : ${LDFLAGS} ${EXTRA_LDFLAGS}"
528    echo "module linker          : ${CCDLL}"
529    echo "module linker flags    : ${LDFLAGS} ${LDFLAGSDLL}"
530    echo "extra features         : ${extra_features}"
531    echo "socket polling method  : ${POLLER}"
532    echo -n "building modules       : "
533if test "$MODULES" = "*" ; then
534    echo "(all modules available)"
535else
536    echo "$MODULES"
537fi
538    echo "binary install path    : ${realbin}"
539    echo "library install path   : ${reallib}"
540    echo "configuration data path: ${realconf}"
541    echo "static data path       : ${realdata}"
542
Note: See TracBrowser for help on using the repository browser.