dnl Process this file with autoconf to produce a configure script. AC_INIT(src/dopewars.c) dnl Initialise automake AM_INIT_AUTOMAKE(dopewars,1.5.12) dnl Write configuration defines into config.h AM_CONFIG_HEADER(config.h) dnl We need this for the Darwin test, plus gettext uses it anyway AC_CANONICAL_HOST dnl Checks for programs. AC_PROG_CC AC_ISC_POSIX AC_PROG_INSTALL AC_PROG_MAKE_SET AC_PROG_LIBTOOL dnl Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h stdlib.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_HEADER_TIME AC_STRUCT_TM dnl Fix Apple's stupid C preprocessor case "$host_os" in darwin*) CPPFLAGS="$CPPFLAGS -no-cpp-precomp" esac HAVE_FIXED_GTK="no" dnl Process client options AC_ARG_ENABLE(gui-client, [ --enable-gui-client include graphical client (GTK+/Win32)], [ GUI_CLIENT="$enableval" ],[ GUI_CLIENT="probe" ]) AC_ARG_ENABLE(curses-client, [ --enable-curses-client include curses client], [ CURSES_CLIENT="$enableval" ],[ CURSES_CLIENT="probe" ]) AC_ARG_ENABLE(gui-server, [ --enable-gui-server use a simple GTK+/Win32 GUI for the server], [ GUI_SERVER="$enableval" ],[ GUI_SERVER="probe" ]) AC_ARG_ENABLE(glib2, [ --disable-glib2 use GLib/GTK+ 1.x, even if 2.x is found], [ USE_GLIB2="$enableval" ],[ USE_GLIB2="yes" ]) AC_ARG_WITH(esd, [ --without-esd do not support ESD sound output], [ USE_ESD="$withval" ], [ USE_ESD="probe" ]) AC_ARG_WITH(sdl, [ --without-sdl do not support SDL sound output], [ USE_SDL="$withval" ], [ USE_SDL="probe" ]) ESD=no SDL=no dnl Test for Cygwin environment AC_CYGWIN dnl Let the user override this with the --enable-nativewin32 option AC_ARG_ENABLE(nativewin32, [ --enable-nativewin32 build a native Win32 binary under Cygwin], [ CYGWIN="$enableval" ]) if test "$CYGWIN" = "yes" ; then AC_MSG_RESULT([Configuring for native Win32 binary under Cygwin]) AC_DEFINE(CYGWIN, 1, [Define if building under the Cygwin environment]) dnl This flag allows linking with MSVC-generated DLLs. -fnative-struct was dnl used by gcc 2, and -mms-bitfields by gcc 3, so it is tested for here. bkp_CFLAGS="$CFLAGS" AC_MSG_CHECKING(for compiler MSVC compatibility flag) CFLAGS="$CFLAGS -mms-bitfields" AC_COMPILE_IFELSE([ AC_LANG_PROGRAM() ], [ mscompat="-mms-bitfields" ], [ mscompat="-fnative-struct" ]) AC_MSG_RESULT($mscompat) CFLAGS="$bkp_CFLAGS" dnl Libraries and flags dnl N.B. -mno-cygwin is included in CPPFLAGS so the right headers dnl are detected (in /usr/include/mingw/ rather than /usr/include) dnl later on - e.g. sys/param.h isn't in mingw. CFLAGS="$CFLAGS -mwindows $mscompat" CPPFLAGS="$CPPFLAGS -mno-cygwin" LIBS="$LIBS -lwsock32 -lcomctl32 -lmpr" LDFLAGS="$LDFLAGS -mno-cygwin" AM_PATH_GLIB_2_0(2.0.0, , [AC_MSG_ERROR(GLib is required)]) AC_DEFINE(HAVE_GLIB2, 1, [Do we have GLIB 2.0 ?]) dnl We need to compile and then link in the Windows resources WNDRES="dopewars.res" AC_SUBST(WNDRES) dnl Add support for the Windows multimedia system SOUND_LIBS="$SOUND_LIBS -lwinmm" PLUGOBJS="$PLUGOBJS plugins/sound_winmm.o" AC_DEFINE(HAVE_WINMM, 1, [Do we have the Windows multimedia system?]) dnl The gtkport implementation works just fine dnl for gtk_entry_set_visibility() HAVE_FIXED_GTK="yes" dnl Use graphical server by default if test "$GUI_SERVER" = "probe"; then GUI_SERVER="yes" fi dnl Read high score files, docs and locale files from current directory datadir="." localstatedir="." else AC_MSG_RESULT([Configuring for Unix binary]) dnl On true Unix systems, test for valid curses-like libraries if test "$CURSES_CLIENT" != "no" ; then AC_CHECK_LIB(ncurses,newterm) if test "$ac_cv_lib_ncurses_newterm" = "no" ; then AC_CHECK_LIB(curses,newterm) if test "$ac_cv_lib_curses_newterm" = "no" ; then AC_CHECK_LIB(cur_colr,newterm) if test "$ac_cv_lib_cur_colr_newterm" = "no" ; then if test "$CURSES_CLIENT" = "yes" ; then AC_MSG_ERROR(Cannot find any curses-type library) else AC_MSG_WARN(Cannot find any curses-type library) CURSES_CLIENT="no" fi fi fi fi fi gtk2_found="probe" if test "$GUI_CLIENT" != "no" -o "$GUI_SERVER" != "no"; then if test "$USE_GLIB2" = "yes" ; then AM_PATH_GTK_2_0(2.0.0,gtk2_found="yes",gtk2_found="no") fi if test "$gtk2_found" = "yes" ; then HAVE_FIXED_GTK="yes" else gtk_found="no" AM_PATH_GTK(1.2.0,gtk_found="yes") if test "$gtk_found" = "no" ; then if test "$GUI_CLIENT" = "yes" -o "$GUI_SERVER" = "yes" ; then AC_MSG_ERROR(Cannot find GTK+) else AC_MSG_WARN(Cannot find GTK+) GUI_CLIENT="no" GUI_SERVER="no" fi else AC_MSG_CHECKING([for non-buggy GTK+ ( >= 1.2.10 )]) dnl Versions older than 1.2.10 are buggy if test "$gtk_config_major_version" -gt 1 ; then HAVE_FIXED_GTK="yes" elif test "$gtk_config_major_version" -eq 1 ; then if test "$gtk_config_minor_version" -gt 2 ; then dnl We assume all 1.3.x releases are OK HAVE_FIXED_GTK="yes" elif test "$gtk_config_minor_version" -eq 2 -a \ "$gtk_config_micro_version" -ge 10 ; then HAVE_FIXED_GTK="yes" fi fi AC_MSG_RESULT([$HAVE_FIXED_GTK]) fi fi fi dnl We NEED glib; N.B. don't link against glib2 if we're using GTK+1 glib2_found="no" if test "$USE_GLIB2" = "yes" -a "$gtk2_found" != "no"; then AM_PATH_GLIB_2_0(2.0.0, glib2_found="yes") fi if test "$glib2_found" = "no" ; then AM_PATH_GLIB(1.2.0, , [AC_MSG_ERROR(Cannot find glib - aborting)]) else AC_DEFINE(HAVE_GLIB2, 1, [Do we have GLIB 2.0 ?]) fi dnl Add esound support if available if test "$USE_ESD" != "no"; then AM_PATH_ESD(0.0.20, ESD=yes) if test "$ESD" = "yes"; then SOUND_CFLAGS="$SOUND_CFLAGS $ESD_CFLAGS" SOUND_LIBS="$SOUND_LIBS $ESD_LIBS" PLUGOBJS="$PLUGOBJS plugins/sound_esd.o" AC_SUBST(ESD_LIBS) AC_DEFINE(HAVE_ESD, 1, [Do we have the ESD sound library?]) elif test "$USE_ESD" = "yes"; then AC_MSG_ERROR(Cannot find ESD library) fi fi dnl Add SDL_mixer sound support if available if test "$USE_SDL" != "no"; then SDL_ALL=no AM_PATH_SDL(1.0.0, SDL=yes) if test "$SDL" = "yes"; then headers=no libs=no AC_CHECK_HEADER(SDL/SDL_mixer.h, headers=yes) AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio, libs=yes) if test "$libs" = "yes"; then if test "$headers" = "yes"; then SOUND_CFLAGS="$SOUND_CFLAGS $SDL_CFLAGS" SDL_LIBS="$SDL_LIBS -lSDL_mixer" SOUND_LIBS="$SOUND_LIBS $SDL_LIBS" PLUGOBJS="$PLUGOBJS plugins/sound_sdl.o" AC_SUBST(SDL_LIBS) AC_DEFINE(HAVE_SDL_MIXER, 1, [Do we have the SDL_mixer sound library?]) SDL_ALL=yes fi fi fi if test "$USE_SDL" = "yes" -a "$SDL_ALL" = "no"; then AC_MSG_ERROR(Cannot find SDL library) fi fi dnl Use console server by default if test "$GUI_SERVER" = "probe"; then GUI_SERVER="no" fi dnl Some systems use int rather than socklen_t as an argument to getsockopt AC_MSG_CHECKING([for socklen_t data type]) AC_TRY_COMPILE([#include #include ],[socklen_t val], [AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_SOCKLEN_T, 1, [Do we have the socklen_t data type?])], [AC_MSG_RESULT([no])]) fi AM_CONDITIONAL(ESD, test "$ESD" = "yes") AM_CONDITIONAL(SDL, test "$SDL" = "yes") dnl If probing was unsuccessful, these will be set to "no"; therefore, dnl if still set to "probe" then everything worked, so set to "yes" if test "$GUI_CLIENT" = "probe"; then GUI_CLIENT="yes" fi if test "$CURSES_CLIENT" = "probe"; then CURSES_CLIENT="yes" fi dnl Do i18n stuff ALL_LINGUAS="de pl pt_BR fr fr_CA nn es es_ES" AM_GNU_GETTEXT if test "$gt_cv_func_gettext_libintl" = "yes"; then LIBS="-lintl $LIBS" fi if test "$GUI_CLIENT" = "yes" ; then AC_DEFINE(GUI_CLIENT, 1, [Use the graphical client?]) fi if test "$CURSES_CLIENT" = "yes" ; then AC_DEFINE(CURSES_CLIENT, 1, [Use the (n)curses client?]) fi if test "$GUI_SERVER" = "yes" ; then AC_DEFINE(GUI_SERVER, 1, [Use a graphical server?]) fi if test "$HAVE_FIXED_GTK" = "yes" ; then AC_DEFINE(HAVE_FIXED_GTK, 1, [Do we have GTK+ with a non-buggy gtk_entry_set_visibility() ? (i.e. >= 1.2.10)]) fi dnl Can we use a long long datatype for price_t ? AC_CHECK_SIZEOF(long long) dnl Checks for library functions. AC_FUNC_MEMCMP AC_FUNC_SETVBUF_REVERSED AC_FUNC_STRFTIME AC_CHECK_FUNCS(strdup strstr getopt getopt_long fork) dnl Enable plugins only if we can find the dlopen function, and dnl the user does not disable them with --disable-plugins or --disable-shared AC_ARG_ENABLE(plugins, [ --enable-plugins use dynamically-loaded sound modules], [ plugins="$enableval" ],[ plugins="probe" ]) if test "$enable_shared" = "no" ; then plugins="no" fi if test "$plugins" != "no" ; then AC_SEARCH_LIBS(dlopen, dl) AC_CHECK_FUNC(dlopen, [plugins="yes"], [plugins="no"]) fi if test "$plugins" = "yes" ; then AC_DEFINE(PLUGINS, 1, [Define if using dynamically-loaded sound modules]) plugindir="${libdir}/dopewars" AC_SUBST(plugindir) DP_EXPAND_DIR(PLUGINDIR, '${plugindir}') AC_DEFINE_UNQUOTED(PLUGINDIR, "$PLUGINDIR", [The directory containing the plugins]) PLUGOBJS="" else PLUGLIBS="$SOUND_LIBS" AC_SUBST(PLUGLIBS) fi AC_SUBST(PLUGOBJS) AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes") dnl Enable networking by default under Win32, but on Unix systems dnl make it dependent on the availability of select and socket network="no" if test "$CYGWIN" = "yes" ; then network="yes" else dnl Check for socket and select even if networking gets manually dnl disabled below, since select is used if available for dnl millisecond sleeping AC_SEARCH_LIBS(socket,socket) AC_SEARCH_LIBS(gethostbyname,nsl socket) AC_CHECK_FUNCS(socket gethostbyname select) if test "$ac_cv_func_select" = "yes" ; then if test "$ac_cv_func_socket" = "yes" ; then if test "$ac_cv_func_gethostbyname" = "yes" ; then network="yes" fi fi fi fi dnl Let the user override this with the --enable-networking option AC_ARG_ENABLE(networking, [ --enable-networking dopewars will use TCP/IP to connect to servers], [ network="$enableval" ]) dnl Inform the user of the status of networking if test "$network" = "yes" ; then AC_DEFINE(NETWORKING, 1, [Define if dopewars should use TCP/IP networking to connect to servers]) fi AC_ARG_ENABLE(strict, [ --enable-strict if using gcc, enable extra warnings above -Wall], [ extrawarnings="$enableval" ]) dnl Enable full warnings if using gcc if test -n "$GCC"; then if test "$extrawarnings" = "yes" ; then CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wcast-qual -Wcast-align -Wsign-compare -Waggregate-return -Wredundant-decls -Wnested-externs -Wunused" else CFLAGS="$CFLAGS -Wall" fi fi dnl Tell dopewars where the high scores, docs and locale files are DP_EXPAND_DIR(DPSCOREDIR, '${localstatedir}') AC_DEFINE_UNQUOTED(DPSCOREDIR, "$DPSCOREDIR", [The directory containing the high score file]) AC_SUBST(DPSCOREDIR) DP_EXPAND_DIR(DPDATADIR, '${datadir}') AC_DEFINE_UNQUOTED(DPDATADIR, "$DPDATADIR", [The directory containing the docs and sounds]) AC_SUBST(DPDATADIR) localedir=${datadir}/locale AC_SUBST(localedir) DP_EXPAND_DIR(LOCALEDIR, '${localedir}') AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR", [The directory containing locale files]) dnl Add in the required clients AM_CONDITIONAL(GUI_CLIENT, test "$GUI_CLIENT" = "yes") if test "$GUI_CLIENT" = "yes" ; then GUILIB="gui_client/libguiclient.a" AC_SUBST(GUILIB) fi AM_CONDITIONAL(CURSES_CLIENT, test "$CURSES_CLIENT" = "yes") if test "$CURSES_CLIENT" = "yes" ; then CURSESLIB="curses_client/libcursesclient.a" AC_SUBST(CURSESLIB) fi dnl Compile in the gtkport stuff for any kind of GUI AM_CONDITIONAL(GTKPORT, test "$GUI_CLIENT" = "yes" -o "$GUI_SERVER" = "yes") if test "$GUI_CLIENT" = "yes" -o "$GUI_SERVER" = "yes" ; then GTKPORTLIB="gtkport/libgtkport.a" AC_SUBST(GTKPORTLIB) fi dnl Compile in the cursesport stuff for the curses client only AM_CONDITIONAL(CURSESPORT, test "$CURSES_CLIENT" = "yes") if test "$CURSES_CLIENT" = "yes" ; then CURSESPORTLIB="cursesport/libcursesport.a" AC_SUBST(CURSESPORTLIB) fi AC_SUBST(SOUND_CFLAGS) AC_SUBST(SOUND_LIBS) AC_OUTPUT([ Makefile src/Makefile src/gui_client/Makefile src/curses_client/Makefile src/gtkport/Makefile src/cursesport/Makefile src/plugins/Makefile sounds/Makefile sounds/19.5degs/Makefile doc/Makefile doc/help/Makefile intl/Makefile dopewars.spec doc/dopewars.6 po/Makefile.in], [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile]) echo echo "dopewars has been configured as follows:" echo if test "$CYGWIN" = "yes" ; then echo "Building native Windows (Win32) version" else echo "Building Unix version" fi echo echo "CLIENTS" if test "$CURSES_CLIENT" = "no" -a "$GUI_CLIENT" = "no" ; then echo " - No clients will be compiled (binary will be server/AI only)" else if test "$CURSES_CLIENT" = "yes" ; then echo " - Text-mode (curses) client" fi if test "$GUI_CLIENT" = "yes" ; then echo " - Graphical (GTK+ or Win32) client" fi fi echo if test "$network" = "yes" ; then echo "TCP/IP networking support enabled for multi-player games" echo echo "SERVER" if test "$GUI_SERVER" = "yes" ; then echo " - Graphical server" else echo " - Text-mode server" fi else echo "Networking support DISABLED; single-player mode only" fi if test "$GUI_SERVER" = "yes" -o "$GUI_CLIENT" = "yes" ; then if test "$HAVE_FIXED_GTK" = "no" ; then cat <