dnl $Header: /fridge/cvs/xscorch/configure.ac,v 1.9 2004/03/25 05:21:11 jacob Exp $ dnl dnl dnl Process this file with autoconf to produce a configure script. dnl Copyright(c) 2001-2004 Justin David Smith dnl AC_PREREQ(2.50) AC_INIT(xscorch.c) AM_INIT_AUTOMAKE(xscorch, 0.2.0) AM_CONFIG_HEADER(config.h) AM_MAINTAINER_MODE dnl Watch out for problems with prefix, datadir dnl test "x$prefix" = "xNONE" && prefix="$ac_default_prefix" test "x$datadir" = 'x${prefix}/share' && datadir="${prefix}/share" test "x$mandir" = 'x${prefix}/man' && mandir="${prefix}/man" dnl Checks for basic programs. dnl LIBJ_CONF_EMBEDDED AC_PROG_INSTALL AC_PROG_LN_S AM_PROG_LIBTOOL dnl This is a very ugly hack. So is libtool... ;) LIBTOOL="$LIBTOOL --preserve-dup-deps" AC_SUBST(LIBTOOL) dnl Use/enable network support? dnl AC_MSG_CHECKING([for --enable-network flag]) AC_ARG_ENABLE(network, [ --enable-network Enable network gameplay [yes]], , enable_network=yes) if test "x$enable_network" != "xyes"; then AC_MSG_RESULT([Network play not enabled]) NETWORK=0 else AC_MSG_RESULT([Network enabled]) NETWORK=1 fi AC_SUBST(NETWORK) AM_CONDITIONAL(NETWORK, test "x$NETWORK" != "x0") dnl Check for --with-readline flags dnl READLINE="0" LIBREADLINE_LIBS="" if test "x$NETWORK" = "x1"; then AC_MSG_CHECKING([for --with-readline flag]) AC_ARG_WITH(readline, [ --with-readline support fancy command line editing], WITH_READLINE=$withval, dnl yes/no - required to use / never use WITH_READLINE="maybe" dnl maybe - use if found [default] ) AC_MSG_RESULT([$WITH_READLINE]) if test "$WITH_READLINE" = "yes"; then AC_CHECK_LIB(readline, rl_callback_handler_install, [READLINE="1", LIBREADLINE_LIBS="-lreadline -ltermcap"], AC_MSG_ERROR([Specified --with-readline but did not find library.])) AC_CHECK_HEADER(readline/readline.h, , AC_MSG_ERROR([Specified --with-readline; found library but not header file. You may need to install a readline \"development\" package.])) elif test "$WITH_READLINE" = "maybe"; then AC_CHECK_HEADER(readline/readline.h, have_readline_h=1, have_readline_h=0) if test "$have_readline_h" = "1"; then AC_CHECK_LIB(readline, rl_callback_handler_install, have_readline_lib=1, have_readline_lib=0) if test "$have_readline_lib" = "1"; then FC_CHECK_READLINE_RUNTIME("", [LIBREADLINE_LIBS="-lreadline"]) fi fi fi else echo "No network support, not checking for libreadline." fi AM_CONDITIONAL(READLINE, test "x$READLINE" = "x1") AC_SUBST(READLINE) AC_SUBST(LIBREADLINE_LIBS) dnl Check for --with-gtk flags dnl AC_MSG_CHECKING([for --with-gtk-12 flag]) AC_ARG_WITH(gtk-12, [ --with-gtk-12 Use GTK 1.2 instead of 2.0 [yes]], , with_gtk_12=yes) if test "x$with_gtk_12" = "xyes"; then AC_MSG_RESULT([using GTK 1.2]) dnl dnl BEGIN of old GTK 1.2 logic dnl dnl Disable GTK 2.0 support GTK20=0 AC_MSG_CHECKING([for --with-gtk flag]) AC_ARG_WITH(gtk, [ --with-gtk[=prefix] Use GTK [yes]], , with_gtk=yes) if test "x$with_gtk" = "xno"; then AC_MSG_RESULT([without GTK]) GTK_CONFIG=no elif test "x$with_gtk" != "xyes"; then GTK_SEARCH_PATH="${with_gtk}:${with_gtk}/bin/:$PATH" AC_MSG_RESULT("$with_gtk") AC_PATH_PROG(GTK_CONFIG, gtk-config, no, "$GTK_SEARCH_PATH") else dnl Check for GTK in default path to decide whether or not to build GTK frontend AC_MSG_RESULT([search for gtk-config]) AC_PATH_PROG(GTK_CONFIG, gtk-config, no) fi dnl Decide whether or not to build GTK dnl if test "x$GTK_CONFIG" = "xno"; then echo "gtk-config not found, disabling GTK frontend" GTK12=0 GTK_LIBS="" GTK_CFLAGS="" else GTK12=1 GTK_VERSION=`$GTK_CONFIG --version` GTK_LIBS=`$GTK_CONFIG --libs` GTK_CFLAGS=`$GTK_CONFIG --cflags` echo "GTK frontend will be built, $GTK_CONFIG, version $GTK_VERSION" echo "GTK link flags: $GTK_LIBS" echo "GTK compile flags: $GTK_CFLAGS" fi dnl Check for --with-gnome flags dnl if test "x$GTK12" = "x1"; then AC_MSG_CHECKING([for --with-gnome flag]) AC_ARG_WITH(gnome, [ --with-gnome[=prefix] Use GNOME [yes]], , with_gnome=yes) if test "x$with_gnome" = "xno"; then AC_MSG_RESULT([without GNOME]) GNOME_CONFIG=no elif test "x$with_gnome" != "xyes"; then GNOME_SEARCH_PATH="${with_gnome}:${with_gnome}/bin/:$PATH" AC_MSG_RESULT("$with_gnome") AC_PATH_PROG(GNOME_CONFIG, gnome-config, no, "$GNOME_SEARCH_PATH") else dnl Check for GNOME in default path AC_MSG_RESULT([search for gnome-config]) AC_PATH_PROG(GNOME_CONFIG, gnome-config, no) fi else echo "GTK missing, so disabling GNOME support." GNOME_CONFIG=no fi dnl Decide whether to implement GNOME-specific stuff dnl if test "x$GNOME_CONFIG" = "xno"; then echo "gnome-config not found, disabling GNOME-specific features" GNOME=0 GNOME_DESKTOP="" GNOME_PIXMAPS="" else GNOME=1 GNOME_DESKTOP=`$GNOME_CONFIG --datadir`/gnome/apps/Games/ GNOME_PIXMAPS=`$GNOME_CONFIG --datadir`/pixmaps/ echo "GNOME features enabled" echo "GNOME desktop directory: $GNOME_DESKTOP" echo "GNOME pixmaps directory: $GNOME_PIXMAPS" fi dnl dnl END of old GTK 1.2 logic dnl else dnl Use GTK 2.0... AC_MSG_RESULT([using GTK 2.0]) dnl dnl BEGIN of new GTK 2.0 logic dnl dnl Disable old GTK and GNOME subsystems GTK12=0 GNOME=0 AM_PATH_GTK_2_0(2.2.0, [GTK20=1; echo "GTK libs: $GTK_LIBS" echo "GTK flags: $GTK_CFLAGS"], [GTK20=0; echo "GTK 2.0 not found, but you can ignore the errors above if you do not want an interface"]) LIBS= dnl dnl END of new GTK 2.0 logic dnl fi dnl Use GTK 1.2 or 2.0? dnl Figure out if ANY GTK interface is being used. dnl if test "x$GTK12" = "x1" -o "x$GTK20" = "x1"; then ANYGTK=1 else ANYGTK=0 fi dnl GTK substitutions dnl AM_CONDITIONAL(GTK12, test "x$GTK12" = "x1") AM_CONDITIONAL(GTK20, test "x$GTK20" = "x1") AM_CONDITIONAL(ANYGTK, test "x$ANYGTK" = "x1") AC_SUBST(GTK12) AC_SUBST(GTK20) AC_SUBST(ANYGTK) AC_SUBST(GTK_LIBS) AC_SUBST(GTK_CFLAGS) dnl GNOME substitutions dnl AM_CONDITIONAL(GNOME, test "x$GNOME" = "x1") AC_SUBST(GNOME) AC_SUBST(GNOME_DESKTOP) AC_SUBST(GNOME_PIXMAPS) dnl Check for --enable-sound flag dnl if test "x$ANYGTK" = "x1"; then AC_MSG_CHECKING([for --enable-sound flag]) AC_ARG_ENABLE(sound, [ --enable-sound Enable sound/music [yes]], , enable_sound=yes) if test "x$enable_sound" != "xyes"; then AC_MSG_RESULT([Sound/music not enabled]) MIKMOD=0 else AC_MSG_RESULT([Sound/music enabled]) MIKMOD=1 fi else echo "No client being built, so disabling MikMod support." MIKMOD=0 fi dnl Check for --with-mikmod flags dnl if test "x$MIKMOD" = "x1"; then AM_PATH_LIBMIKMOD(3.1.5, [MIKMOD=1; echo "libmikmod libs: $LIBMIKMOD_LIBS" echo "libmikmod flags: $LIBMIKMOD_CFLAGS"], [MIKMOD=0; echo "libmikmod not found, but you can ignore the errors above if you do not want sound support"]) LIBS= fi AM_CONDITIONAL(MIKMOD, test "x$MIKMOD" = "x1") AC_SUBST(MIKMOD) dnl Make sure we're building something at all... dnl if test "x$ANYGTK" = "x0" -a "x$NETWORK" = "x0"; then AC_MSG_ERROR([GTK and network support disabled. Nothing left to build!]) fi dnl Check C structures that we will rely on later dnl critical_failure=0 AC_CHECK_HEADERS(sys/time.h, , critical_failure=1) AC_CHECK_HEADERS(sys/stat.h, , critical_failure=1) AC_CHECK_HEADERS(unistd.h, , critical_failure=1) if test "x$critical_failure" = "x1"; then AC_MSG_ERROR([Required header missing, aborting.]) fi AC_HEADER_TIME if test "x$NETWORK" = "x1"; then AC_CHECK_HEADERS(sys/types.h, , critical_failure=1) AC_CHECK_HEADERS(sys/socket.h, , critical_failure=1) AC_CHECK_HEADERS(netdb.h, , critical_failure=1) AC_CHECK_HEADERS(netinet/in.h, , critical_failure=1) AC_CHECK_HEADERS(arpa/inet.h, , critical_failure=1) AC_CHECK_HEADERS(errno.h, , critical_failure=1) AC_CHECK_HEADERS(fcntl.h, , critical_failure=1) AC_CHECK_HEADERS(string.h, , critical_failure=1) if test "x$critical_failure" = "x1"; then AC_MSG_ERROR([Required network header missing, aborting.]) fi fi dnl Checks for library functions. dnl AC_CHECK_FUNCS(gettimeofday, , AC_MSG_ERROR(gettimeofday() not found, aborting.)) AC_CHECK_FUNCS(usleep, , AC_MSG_ERROR(usleep() not found, aborting.)) AC_CHECK_FUNCS(memcpy, , AC_MSG_ERROR(memcpy() not found, aborting.)) AC_CHECK_FUNCS(memset, , AC_MSG_ERROR(memset() not found, aborting.)) AC_CHECK_FUNCS(vsnprintf, , AC_MSG_ERROR(vsnprintf() not found, aborting.)) AC_CHECK_FUNCS(stat, , AC_MSG_ERROR(stat() not found, aborting.)) AC_CHECK_FUNCS(strnlen) dnl Check if we should use the built-in getopt dnl AC_CHECK_FUNCS(getopt_long, NEED_GETOPT=0, NEED_GETOPT=1) AM_CONDITIONAL(NEED_GETOPT, test "x$NEED_GETOPT" = "x1") dnl Checks for network library functions dnl NET_LIBS="" AC_SUBST(NET_LIBS) if test "x$NETWORK" = "x1"; then AC_CHECK_FUNCS(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname, NET_LIBS="$NET_LIBS -lnsl", AC_MSG_ERROR(gethostbyname() network function not found, aborting.))) AC_CHECK_FUNCS(socket, , AC_CHECK_LIB(socket, socket, NET_LIBS="$NET_LIBS -lsocket", AC_MSG_ERROR(socket() network function not found, aborting.))) echo "Network libraries we're linking against: "`if test "x$NET_LIBS" = "x"; then echo "(none)"; else echo "$NET_LIBS"; fi` fi dnl A random check dnl AC_CHECK_LIB(reality, convolution, , , ) dnl Checks for X Windows dnl if test "x$ANYGTK" = "x1"; then AC_PATH_XTRA AC_CHECK_LIB(X11, XOpenDisplay, , AC_MSG_ERROR(libX11 is required for GTK interface, aborting.), $X_LIBS) AC_CHECK_LIB(Xpm, XpmCreateImageFromData, , AC_MSG_ERROR(libXpm is required for GTK interface, aborting.), $X_LIBS) LIBS= fi AC_SUBST(X_LIBS) LIBJ_PROG_CC_CFLAGS dnl Output the makefiles and headers dnl AC_OUTPUT([ Makefile xscorch.h libj/libj.h sai/Makefile sconsole/Makefile sgame/Makefile sgtk/Makefile sgtk/swidgets/Makefile snet/Makefile snet/tcpnet/Makefile ssound/Makefile sutil/Makefile libj/Makefile libj/jreg/Makefile libj/jstr/Makefile data/Makefile doc/Makefile img/Makefile snd/Makefile ]) dnl Display final configure status dnl echo "" echo "$PACKAGE $VERSION Configuration:" echo " Prefix: $prefix" echo " Datadir: $datadir" echo " Mandir: $mandir" echo " CFLAGS: $CFLAGS" echo -n " Sound: " LIBJ_PRINT_YES_NO($MIKMOD) echo -n " Network: " LIBJ_PRINT_YES_NO($NETWORK) echo -n " Readline: " LIBJ_PRINT_YES_NO($READLINE) echo -n " GTK 1.2: " LIBJ_PRINT_YES_NO($GTK12) echo -n " GTK 2.0: " LIBJ_PRINT_YES_NO($GTK20) echo -n " GNOME: " LIBJ_PRINT_YES_NO($GNOME) echo "" if test "x$NETWORK" = "x1"; then echo "*** WARNING ***" echo "Network games are UNSTABLE. PLEASE read doc/NETWORK before sending in bug" echo "reports. Also, check out the document if you are interested in network" echo "development. We appreciate any feedback/bugfixes on the networking code." echo "" fi if test "x$MIKMOD" = "x1"; then echo "*** NOTE ***" echo "You have enabled sound support, but currently there is no music, nor are" echo "there sound effects in the game. xscorch will be linked to mikmod but the" echo "sound options will currently do nothing. We are currently looking for" echo "volunteers to create music for xscorch. If you'd like to write us some" echo "tracks, please drop us an e-mail!" echo "" fi