dnl Process this file with autoconf to produce a configure script. AC_INIT(src/gnut.c) AM_INIT_AUTOMAKE(gnut,0.4.21) AM_MAINTAINER_MODE AM_ACLOCAL_INCLUDE(macros) AC_CONFIG_SUBDIRS(readline) dnl Checks for programs. AC_PROG_AWK AC_PROG_CC # if we're using GCC, enable all warnings if test "$GCC" = yes; then CFLAGS="$CFLAGS -Wall"; fi AC_PROG_INSTALL AC_PROG_LN_S dnl args AC_ARG_ENABLE(dmalloc, [ --enable-dmalloc Compile with dmalloc support], [gnut_dmalloc=true],[gnut_dmalloc=false]) if test $gnut_dmalloc = true ; then AC_MSG_RESULT([compiling with dmalloc support]) AC_CHECK_LIB(dmallocth,main) if test $HAVE_LIBDMALLOCTH = yes ; then AC_MSG_ERROR("NO DMALLOC") fi LIBS="$LIBS -ldmallocth" CFLAGS="-DDMALLOC=1 $CFLAGS" fi AC_ARG_ENABLE(gnome, [ --enable-gnome Compile in gnome support], [gnut_gnome=true],[gnut_gnome=false]) AC_ARG_ENABLE(mcheck, [ --enable-mcheck Link in support for malloc heap checking], [gnut_mcheck=true],[gnut_mcheck=false]) if test $gnut_mcheck = true ; then AC_MSG_RESULT([compiling with mcheck]) LIBS="$LIBS -lmcheck" CFLAGS="-DMCHECK=1 $CFLAGS" fi dnl Checks for libraries. AC_CACHE_CHECK([for readline in readline.h], [g_cv_readline],[ save_LIBS="$LIBS" LIBS="-lreadline $LIBS" AC_TRY_LINK([ #include #include ], [readline(NULL);], [g_cv_readline=yes],[g_cv_readline=no]) LIBS="$save_LIBS" ]) if test $g_cv_readline = yes ; then LIBS="$LIBS -lreadline" AC_DEFINE(HAVE_READLINE) fi if test $g_cv_readline = no ; then AC_CACHE_CHECK([for readline in readline.h with curses], [g_cv_readline_w_curses],[ save_LIBS="$LIBS" LIBS="-lreadline -lcurses $LIBS" AC_TRY_LINK([ #include #include ], [readline(NULL);], [g_cv_readline_w_curses=yes],[g_cv_readline_w_curses=no]) LIBS="$save_LIBS" ]) if test $g_cv_readline_w_curses = yes ; then LIBS="$LIBS -lreadline -lcurses" g_cv_readline=yes AC_DEFINE(HAVE_READLINE) fi fi if test $g_cv_readline = no ; then AC_CACHE_CHECK([for readline in readline.h with termcap], [g_cv_readline_w_termcap],[ save_LIBS="$LIBS" LIBS="-lreadline -ltermcap $LIBS" AC_TRY_LINK([ #include #include ], [readline(NULL);], [g_cv_readline_w_termcap=yes],[g_cv_readline_w_termcap=no]) LIBS="$save_LIBS" ]) if test $g_cv_readline_w_termcap = yes ; then LIBS="$LIBS -lreadline -ltermcap" g_cv_readline=yes AC_DEFINE(HAVE_READLINE) fi fi AC_CHECK_FUNC(xmalloc, AC_DEFINE(HAVE_XMALLOC)) AC_CHECK_FUNC(flock,AC_DEFINE(HAVE_FLOCK)) AC_CHECK_FUNC(fcntl,AC_DEFINE(HAVE_FCNTL)) AC_CHECK_FUNC(strtok_r,AC_DEFINE(HAVE_STRTOK_R)) AC_CHECK_LIB(termcap, main) AC_CHECK_FUNC(socket, [have_socket=yes], [ AC_CHECK_LIB(socket,main) AC_CHECK_LIB(net,main) AC_CHECK_LIB(nsl_s,main) AC_CHECK_LIB(nsl,main) AC_CHECK_LIB(inet,socket) AC_CHECK_LIB(gen,main) AC_CHECK_LIB(resolv,main) ]) AC_CHECK_HEADERS(regex.h) AC_CHECK_HEADERS(getopt.h) AC_CHECK_HEADERS(sys/sockio.h) AC_CHECK_HEADERS(pthread.h) AC_CHECK_HEADERS(err.h) AC_CHECK_HEADERS(term.h termcap.h termio.h termios.h) AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS)) g_link_threads=no if test $g_link_threads = no ; then dnl look for libpthread.so AC_CHECK_LIB(pthread,pthread_create, [g_cv_libpthread=yes],[g_cv_libpthread=no]) if test $g_cv_libpthread = yes ; then LTHREAD_LIBS="$LTHREAD_LIBS -lpthread" g_link_threads=posix fi fi if test $g_link_threads = no ; then dnl try -pthreads AC_CACHE_CHECK([for pthread_create with -pthreads], [g_cv_pthreads_flag], [ dnl save the flags save_LIBS="$LIBS" LIBS="-pthreads $LIBS" AC_TRY_LINK([#include ], [pthread_create(NULL,NULL,NULL,NULL);], [g_cv_pthreads_flag=yes], [g_cv_pthreads_flag=no]) dnl restore the libs LIBS="$save_LIBS" ]) if test $g_cv_pthreads_flag = yes ; then LTHREAD_LIBS="$LTHREAD_LIBS -pthreads" g_link_threads=posix fi fi if test $g_link_threads = no ; then dnl try -pthread in CFLAGS AC_CACHE_CHECK([for pthread_create with -pthread in CFLAGS], [g_cv_pthread_flag], [ dnl save the flags save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="-pthread $LIBS" CFLAGS="-pthread $LiBS" AC_TRY_LINK([#include ], [pthread_create(NULL,NULL,NULL,NULL);], [g_cv_pthread_flag=yes], [g_cv_thread_flag=no]) dnl restore flags LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" ]) if test $g_cv_pthread_flag = yes ; then LTHREAD_LIBS="$LTHREAD_LIBS -pthread" LTHREAD_CFLAGS="$LTHREAD_CFLAGS -pthread" g_link_threads=posix fi fi if test $g_link_threads = no ; then dnl try -pthread AC_CACHE_CHECK([for pthread_create with -pthread], [g_cv_pthread_flag], [ dnl save the flags save_LIBS="$LIBS" LIBS="-pthread $LIBS" AC_TRY_LINK([#include ], [pthread_create(NULL,NULL,NULL,NULL);], [g_cv_pthread_flag=yes], [g_cv_thread_flag=no]) dnl restore the libs LIBS="$save_LIBS" ]) if test $g_cv_pthread_flag = yes ; then LTHREAD_LIBS="$LTHREAD_LIBS -pthread" g_link_threads=posix fi fi if test $g_link_threads = no ; then dnl try -thread AC_CACHE_CHECK([for pthread_create with -thread], [g_cv_thread_flag], [ dnl save the flags save_LIBS="$LIBS" LIBS="-thread $LIBS" AC_TRY_LINK([char pthread_create();], [pthread_create();] [g_cv_thread_flag=yes], [g_cv_thread_flag=no]) dnl restore the libs LIBS="$save_LIBS" ]) if test $g_cv_thread_flag = yes ; then LTHREAD_LIBS="$LTHREAD_LIBS -thread" g_link_threads=posix fi fi if test $g_link_threads = no ; then dnl try -lpthread save_LIBS="$LIBS" AC_CHECK_LIB(pthread, pthread_create, [ g_link_threads=posix LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"],:) LIBS="$save_LIBS" fi if test $g_link_threads = no ; then AC_MSG_ERROR([You must have some sort of thread library!]) fi dnl HP-UX 10.20 uses POSIX draft 4 threads if test `uname` = "HP-UX" && test `uname -r` = "B.10.20" ; then LTHREAD_CFLAGS="-DPTHREADS_DRAFT4 $LTHREAD_CFLAGS" fi LIBS="$LTHREAD_LIBS $LIBS" CFLAGS="-D_REENTRANT $LTHREAD_CFLAGS $CFLAGS" dnl Checks for header files. AC_HEADER_STDC dnl Checks for typedefs, structures, and compiler characteristics. AC_HEADER_TIME AC_C_BIGENDIAN dnl Checks for library functions. AC_FUNC_MEMCMP AC_TYPE_SIGNAL AC_CHECK_FUNCS(gethostname select socket strstr re_comp regcomp) if test $gnut_gnome = true ; then AC_MSG_RESULT([compiling for gnome]) GNOME_INIT GNOME_X_CHECKS GNOME_XML_CHECK GNOME_COMPILE_WARNINGS AC_MSG_CHECKING(For Glade libraries) if gnome-config --libs libglade > /dev/null 2>&1; then AC_MSG_RESULT(found) else AC_MSG_ERROR(Did not find libglade installed) fi EXTRA_GNOME_LIBS=`gnome-config --libs xml libglade` EXTRA_GNOME_CFLAGS=`gnome-config --cflags xml libglade` GNUT_GNOME=" ggnut " GNOME_LIBS="$LIBS `gnome-config --libs gnome gnomeui libglade`" GNOME_CFLAGS="$CFLAGS `gnome-config --cflags gnome gnomeui libglade`" fi AC_SUBST(EXTRA_GNOME_LIBS) AC_SUBST(EXTRA_GNOME_CFLAGS) AC_SUBST(GNUT_GNOME) AC_OUTPUT([ Makefile src/Makefile src/win32pth/Makefile macros/Makefile doc/Makefile ])