tconfigure.ac - vaccinewars - be a doctor and try to vaccinate the world
 (HTM) git clone git://src.adamsgaard.dk/vaccinewars
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       tconfigure.ac (16008B)
       ---
            1 dnl Process this file with autoconf to produce a configure script.
            2 AC_INIT([dopewars], [SVN])
            3 AC_CONFIG_SRCDIR([src/dopewars.c])
            4 AC_CONFIG_AUX_DIR(auxbuild)
            5 
            6 AC_CONFIG_MACRO_DIR([m4])
            7 
            8 AC_CANONICAL_TARGET
            9 AC_USE_SYSTEM_EXTENSIONS
           10 
           11 dnl Initialize automake
           12 dnl 'foreign' because we have README.md instead of README
           13 AM_INIT_AUTOMAKE([foreign])
           14 
           15 dnl Write configuration defines into config.h
           16 AM_CONFIG_HEADER([src/config.h])
           17 
           18 dnl We need this for the Darwin test, plus gettext uses it anyway
           19 AC_CANONICAL_HOST
           20 
           21 dnl Checks for programs.
           22 AC_PROG_CC
           23 AC_ISC_POSIX
           24 AC_PROG_INSTALL
           25 AC_PROG_MAKE_SET
           26 AC_PROG_LIBTOOL
           27 
           28 dnl Checks for header files.
           29 AC_HEADER_STDC
           30 AC_HEADER_SYS_WAIT
           31 AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h stdlib.h)
           32 
           33 dnl Checks for typedefs, structures, and compiler characteristics.
           34 AC_HEADER_TIME
           35 AC_STRUCT_TM
           36 
           37 dnl Fix Apple's stupid C preprocessor
           38 case "$host_os" in darwin*)
           39    CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
           40 esac
           41 
           42 dnl Process client options
           43 AC_ARG_ENABLE(gui-client,
           44 [  --enable-gui-client     include graphical client (GTK+/Win32)],
           45 [ GUI_CLIENT="$enableval" ],[ GUI_CLIENT="probe" ])
           46 
           47 AC_ARG_ENABLE(curses-client,
           48 [  --enable-curses-client  include curses client],
           49 [ CURSES_CLIENT="$enableval" ],[ CURSES_CLIENT="probe" ])
           50 
           51 AC_ARG_ENABLE(gui-server,
           52 [  --enable-gui-server     use a simple GTK+/Win32 GUI for the server],
           53 [ GUI_SERVER="$enableval" ],[ GUI_SERVER="probe" ])
           54 
           55 AC_ARG_ENABLE(gtk4,
           56 [  --enable-gtk4           use GTK 4 if available (experimental)],
           57 [ USE_GTK4="$enableval" ],[ USE_GTK4="no" ])
           58 
           59 AC_ARG_ENABLE(gtk3,
           60 [  --disable-gtk3          use GTK+ 2.x, even if 3.x is found],
           61 [ USE_GTK3="$enableval" ],[ USE_GTK3="yes" ])
           62 
           63 AC_ARG_WITH(esd,
           64 [  --without-esd           do not support ESD sound output],
           65 [ USE_ESD="$withval" ], [ USE_ESD="probe" ])
           66 
           67 AC_ARG_WITH(sdl,
           68 [  --without-sdl           do not support SDL sound output],
           69 [ USE_SDL="$withval" ], [ USE_SDL="probe" ])
           70 
           71 if test "$host_vendor" = "apple" ; then
           72   APPLE=yes
           73   AC_DEFINE(APPLE, 1, [Are we building on an Apple Mac?])
           74   default_cocoa="yes"
           75 else
           76   APPLE=no
           77   default_cocoa="no"
           78 fi
           79 AM_CONDITIONAL(APPLE, test "$APPLE" = "yes")
           80 
           81 AC_ARG_WITH(cocoa,
           82 [  --without-cocoa         do not support Cocoa (Mac) sound output],
           83 [ USE_COCOA="$withval" ], [ USE_COCOA="${default_cocoa}" ])
           84 
           85 ESD=no
           86 SDL=no
           87 COCOA=no
           88 
           89 dnl Test for Cygwin environment
           90 AC_CYGWIN
           91 dnl Let the user override this with the --enable-nativewin32 option
           92 AC_ARG_ENABLE(nativewin32,
           93 [  --enable-nativewin32    build a native Win32 binary under Cygwin],
           94 [ CYGWIN="$enableval" ])
           95 
           96 if test "$CYGWIN" = "yes" ; then
           97    AC_MSG_RESULT([Configuring for native Win32 binary under Cygwin])
           98    AC_DEFINE(CYGWIN, 1, [Define if building under the Cygwin environment])
           99 
          100    dnl Otherwise we get the error
          101    dnl 'conditional "am__fastdepOBJC" was never defined'
          102    am__fastdepOBJC_TRUE='#'
          103    am__fastdepOBJC_FALSE=
          104 
          105    AC_CHECK_TOOL([WINDRES], [windres], [windres])
          106    dnl This flag allows linking with MSVC-generated DLLs. -fnative-struct was
          107    dnl used by gcc 2, and -mms-bitfields by gcc 3, so it is tested for here.
          108    bkp_CFLAGS="$CFLAGS"
          109    AC_MSG_CHECKING(for compiler MSVC compatibility flag)
          110    CFLAGS="$CFLAGS -mms-bitfields"
          111    AC_COMPILE_IFELSE([ AC_LANG_PROGRAM() ], [ mscompat="-mms-bitfields" ],
          112                      [ mscompat="-fnative-struct" ])
          113    AC_MSG_RESULT($mscompat)
          114    CFLAGS="$bkp_CFLAGS"
          115 
          116    dnl If using older Cygwin -mno-cygwin is included in CPPFLAGS so the
          117    dnl right headers are detected (in /usr/include/mingw/ rather than
          118    dnl /usr/include) later on - e.g. sys/param.h isn't in mingw.
          119    bkp_CFLAGS="$CFLAGS"
          120    AC_MSG_CHECKING(for no-Cygwin flag)
          121    CFLAGS="$CFLAGS -no-cygwin"
          122    AC_COMPILE_IFELSE([ AC_LANG_PROGRAM() ], [ nocyg="-no-cygwin" ],
          123                      [ nocyg="" ])
          124    AC_MSG_RESULT($nocyg)
          125    CFLAGS="$bkp_CFLAGS"
          126 
          127    dnl Libraries and flags
          128    CFLAGS="$CFLAGS -mwindows $mscompat $nocyg"
          129    CPPFLAGS="$CPPFLAGS $nocyg"
          130    LIBS="$LIBS -lwsock32 -lcomctl32 -luxtheme -lmpr"
          131    LDFLAGS="$LDFLAGS $nocyg"
          132 
          133    AM_PATH_GLIB_2_0(2.0.0, , [AC_MSG_ERROR(GLib is required)])
          134 
          135    dnl Find libcurl for metaserver support
          136    dnl 7.17.0 or later is needed as prior versions did not copy input strings
          137    LIBCURL_CHECK_CONFIG(7.17.0)
          138 
          139    dnl We need to compile and then link in the Windows resources
          140    WNDRES="dopewars.res"
          141    AC_SUBST(WNDRES)
          142 
          143    dnl Add support for the Windows multimedia system
          144    SOUND_LIBS="$SOUND_LIBS -lwinmm"
          145    PLUGOBJS="$PLUGOBJS plugins/sound_winmm.o"
          146    AC_DEFINE(HAVE_WINMM, 1, [Do we have the Windows multimedia system?])
          147 
          148    dnl Use graphical server by default
          149    if test "$GUI_SERVER" = "probe"; then
          150      GUI_SERVER="yes"
          151    fi
          152 
          153    dnl Read high score files, docs and locale files from current directory
          154    datadir="."
          155    localstatedir="."
          156 else
          157    AC_MSG_RESULT([Configuring for Unix binary])
          158 
          159    dnl On true Unix systems, test for valid curses-like libraries
          160    if test "$CURSES_CLIENT" != "no" ; then
          161       AC_CHECK_LIB(ncurses,newterm)
          162       if test "$ac_cv_lib_ncurses_newterm" = "no" ; then
          163          AC_CHECK_LIB(curses,newterm)
          164          if test "$ac_cv_lib_curses_newterm" = "no" ; then
          165             AC_CHECK_LIB(cur_colr,newterm)
          166             if test "$ac_cv_lib_cur_colr_newterm" = "no" ; then
          167                if test "$CURSES_CLIENT" = "yes" ; then
          168                  AC_MSG_ERROR(Cannot find any curses-type library)
          169                else
          170                  AC_MSG_WARN(Cannot find any curses-type library)
          171                  CURSES_CLIENT="no"
          172                fi
          173             fi
          174          fi
          175       fi
          176    fi
          177 
          178    gtk2_found="probe"
          179    if test "$GUI_CLIENT" != "no" -o "$GUI_SERVER" != "no"; then
          180       PKG_PROG_PKG_CONFIG()
          181       gtk4_found="no"
          182       if test "$USE_GTK4" = "yes" ; then
          183         PKG_CHECK_MODULES([GTK], [gtk4], gtk4_found="yes", gtk4_found="no")
          184       fi
          185       if test "$gtk4_found" = "no" ; then
          186         gtk3_found="no"
          187         if test "$USE_GTK3" = "yes" ; then
          188           PKG_CHECK_MODULES([GTK], [gtk+-3.0], gtk3_found="yes", gtk3_found="no")
          189         fi
          190         if test "$gtk3_found" = "no" ; then
          191           AM_PATH_GTK_2_0(2.0.0,gtk2_found="yes",gtk2_found="no")
          192           if test "$gtk2_found" = "no" ; then
          193             if test "$GUI_CLIENT" = "yes" -o "$GUI_SERVER" = "yes" ; then
          194                AC_MSG_ERROR(Cannot find GTK+)
          195             else
          196                AC_MSG_WARN(Cannot find GTK+; not building GUI client or server)
          197                GUI_CLIENT="no"
          198                GUI_SERVER="no"
          199             fi
          200           fi
          201         fi
          202       fi
          203    fi
          204 
          205    dnl We NEED glib
          206    AM_PATH_GLIB_2_0(2.0.0, , [AC_MSG_ERROR(GLib is required)])
          207 
          208    dnl Find libcurl for metaserver support
          209    dnl 7.17.0 or later is needed as prior versions did not copy input strings
          210    LIBCURL_CHECK_CONFIG(7.17.0)
          211 
          212    dnl Add esound support if available
          213    if test "$USE_ESD" != "no"; then
          214      AM_PATH_ESD(0.0.20, ESD=yes)
          215      if test "$ESD" = "yes"; then
          216        SOUND_CFLAGS="$SOUND_CFLAGS $ESD_CFLAGS"
          217        SOUND_LIBS="$SOUND_LIBS $ESD_LIBS"
          218        PLUGOBJS="$PLUGOBJS plugins/sound_esd.o"
          219        AC_SUBST(ESD_LIBS)
          220        AC_DEFINE(HAVE_ESD, 1, [Do we have the ESD sound library?])
          221      elif test "$USE_ESD" = "yes"; then
          222        AC_MSG_ERROR(Cannot find ESD library)
          223      fi
          224    fi
          225 
          226    dnl Add SDL_mixer sound support if available
          227    if test "$USE_SDL" != "no"; then
          228      SDL_ALL=no
          229      SDL2=yes
          230      AM_PATH_SDL2(2.0.0, SDL=yes)
          231      if test "$SDL" != "yes"; then
          232        SDL2=no
          233        AM_PATH_SDL(1.0.0, SDL=yes)
          234      fi
          235      if test "$SDL" = "yes"; then
          236        headers=no
          237        libs=no
          238        ORIG_CPPFLAGS="$CPPFLAGS"
          239        ORIG_LDFLAGS="$LDFLAGS"
          240        CPPFLAGS="$ORIG_CPPFLAGS $SDL_CFLAGS"
          241        LDLAGS="$ORIG_LDFLAGS $SDL_LIBS"
          242        AC_CHECK_HEADER(SDL_mixer.h, headers=yes)
          243        if test "$SDL2" = "yes"; then
          244          AC_CHECK_LIB(SDL2_mixer, Mix_OpenAudio, libs=yes)
          245        else
          246          AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio, libs=yes)
          247        fi
          248        CPPFLAGS="$ORIG_CPPFLAGS"
          249        LDFLAGS="$ORIG_LDFLAGS"
          250        if test "$libs" = "yes"; then
          251          if test "$headers" = "yes"; then
          252            SOUND_CFLAGS="$SOUND_CFLAGS $SDL_CFLAGS"
          253            if test "$SDL2" = "yes"; then
          254              SDL_LIBS="$SDL_LIBS -lSDL2_mixer"
          255            else
          256              SDL_LIBS="$SDL_LIBS -lSDL_mixer"
          257            fi
          258            SOUND_LIBS="$SOUND_LIBS $SDL_LIBS"
          259            PLUGOBJS="$PLUGOBJS plugins/sound_sdl.o"
          260            AC_SUBST(SDL_LIBS)
          261            AC_DEFINE(HAVE_SDL_MIXER, 1,
          262                      [Do we have the SDL_mixer sound library?])
          263            SDL_ALL=yes
          264            if test "$APPLE" = "yes"; then
          265              SDL_LIBS="$SDL_LIBS -module"
          266            fi
          267          fi
          268        fi
          269      fi
          270      if test "$USE_SDL" = "yes" -a "$SDL_ALL" = "no"; then
          271        AC_MSG_ERROR(Cannot find SDL library)
          272      fi
          273    fi
          274 
          275    dnl Add Cocoa (Mac) sound support if on Mac and so requested
          276    if test "$USE_COCOA" != "no"; then
          277      AC_PROG_OBJC
          278      COCOA="yes"
          279      PLUGOBJS="$PLUGOBJS plugins/sound_cocoa.o"
          280      AC_DEFINE(HAVE_COCOA, 1, [Do we have the Cocoa sound library?])
          281    else
          282      dnl Otherwise we get the error
          283      dnl 'conditional "am__fastdepOBJC" was never defined'
          284      am__fastdepOBJC_TRUE='#'
          285      am__fastdepOBJC_FALSE=
          286    fi
          287 
          288    dnl Use console server by default
          289    if test "$GUI_SERVER" = "probe"; then
          290      GUI_SERVER="no"
          291    fi
          292 
          293    dnl Some systems use int rather than socklen_t as an argument to getsockopt
          294    AC_MSG_CHECKING([for socklen_t data type])
          295    AC_TRY_COMPILE([#include <sys/types.h>
          296                    #include <sys/socket.h>],[socklen_t val],
          297                   [AC_MSG_RESULT([yes])
          298                    AC_DEFINE(HAVE_SOCKLEN_T, 1,
          299                              [Do we have the socklen_t data type?])],
          300                   [AC_MSG_RESULT([no])])
          301 fi
          302 
          303 AM_CONDITIONAL(ESD, test "$ESD" = "yes")
          304 AM_CONDITIONAL(SDL, test "$SDL" = "yes")
          305 AM_CONDITIONAL(COCOA, test "$COCOA" = "yes")
          306 
          307 dnl If probing was unsuccessful, these will be set to "no"; therefore,
          308 dnl if still set to "probe" then everything worked, so set to "yes"
          309 if test "$GUI_CLIENT" = "probe"; then
          310   GUI_CLIENT="yes"
          311 fi
          312 if test "$CURSES_CLIENT" = "probe"; then
          313   CURSES_CLIENT="yes"
          314 fi
          315 
          316 dnl Do i18n stuff
          317 ALL_LINGUAS="de pl pt_BR fr fr_CA nn es es_ES en_GB"
          318 AM_GNU_GETTEXT([external])
          319 if test "$gt_cv_func_gettext_libintl" = "yes"; then
          320     LIBS="-lintl $LIBS"
          321 fi
          322 
          323 if test "$GUI_CLIENT" = "yes" ; then
          324    AC_DEFINE(GUI_CLIENT, 1, [Use the graphical client?])
          325 fi
          326 
          327 if test "$CURSES_CLIENT" = "yes" ; then
          328    AC_DEFINE(CURSES_CLIENT, 1, [Use the (n)curses client?])
          329 fi
          330 
          331 if test "$GUI_SERVER" = "yes" ; then
          332    AC_DEFINE(GUI_SERVER, 1, [Use a graphical server?])
          333 fi
          334 
          335 dnl Can we use a long long datatype for price_t ?
          336 AC_CHECK_SIZEOF(long long)
          337 
          338 dnl Checks for library functions.
          339 AC_FUNC_MEMCMP
          340 AC_FUNC_SETVBUF_REVERSED
          341 AC_FUNC_STRFTIME
          342 AC_CHECK_FUNCS(strdup strstr getopt getopt_long fork issetugid)
          343 
          344 dnl Enable plugins only if we can find the dlopen function, and
          345 dnl the user does not disable them with --disable-plugins or --disable-shared
          346 AC_ARG_ENABLE(plugins,
          347 [  --enable-plugins        use dynamically-loaded sound modules],
          348 [ plugins="$enableval" ],[ plugins="probe" ])
          349 
          350 if test "$enable_shared" = "no" ; then
          351   plugins="no"
          352 fi
          353 
          354 if test "$plugins" != "no" ; then
          355   AC_SEARCH_LIBS(dlopen, dl)
          356   AC_CHECK_FUNC(dlopen, [plugins="yes"], [plugins="no"])
          357 fi
          358 
          359 if test "$plugins" = "yes" ; then
          360   AC_DEFINE(PLUGINS, 1, [Define if using dynamically-loaded sound modules])
          361   plugindir="${libdir}/dopewars"
          362   AC_SUBST(plugindir)
          363   DP_EXPAND_DIR(PLUGINDIR, '${plugindir}')
          364   AC_DEFINE_UNQUOTED(PLUGINDIR, "$PLUGINDIR",
          365                    [The directory containing the plugins])
          366   PLUGOBJS=""
          367 else
          368   PLUGLIBS="$SOUND_LIBS"
          369   AC_SUBST(PLUGLIBS)
          370 fi
          371 AC_SUBST(PLUGOBJS)
          372 AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
          373 
          374 dnl Enable networking by default under Win32, but on Unix systems
          375 dnl make it dependent on the availability of select and socket
          376 network="no"
          377 if test "$CYGWIN" = "yes" ; then
          378    network="yes"
          379 else
          380    dnl Check for socket and select even if networking gets manually
          381    dnl disabled below, since select is used if available for
          382    dnl millisecond sleeping
          383    AC_SEARCH_LIBS(socket,socket network)
          384    AC_SEARCH_LIBS(gethostbyname,nsl socket)
          385    AC_CHECK_FUNCS(socket gethostbyname select)
          386    if test "$ac_cv_func_select" = "yes" ; then
          387       if test "$ac_cv_func_socket" = "yes" ; then
          388          if test "$ac_cv_func_gethostbyname" = "yes" ; then
          389             network="yes"
          390          fi
          391       fi
          392    fi
          393 fi
          394 
          395 dnl Let the user override this with the --enable-networking option
          396 AC_ARG_ENABLE(networking,
          397 [  --enable-networking     dopewars will use TCP/IP to connect to servers],
          398 [ network="$enableval" ])
          399 
          400 dnl Inform the user of the status of networking
          401 if test "$network" = "yes" ; then
          402    AC_DEFINE(NETWORKING, 1,
          403        [Define if dopewars should use TCP/IP networking to connect to servers])
          404 fi
          405 
          406 AC_ARG_ENABLE(strict,
          407 [  --enable-strict         if using gcc, enable extra warnings above -Wall],
          408 [ extrawarnings="$enableval" ])
          409 
          410 dnl Enable full warnings if using gcc
          411 if test -n "$GCC"; then
          412    if test "$extrawarnings" = "yes" ; then
          413       CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wcast-qual -Wcast-align -Wsign-compare -Waggregate-return -Wredundant-decls -Wnested-externs -Wunused"
          414    else
          415       CFLAGS="$CFLAGS -Wall"
          416    fi
          417 fi
          418 
          419 dnl Tell dopewars where the high scores, docs and locale files are
          420 DP_EXPAND_DIR(DPSCOREDIR, '${localstatedir}')
          421 AC_DEFINE_UNQUOTED(DPSCOREDIR, "$DPSCOREDIR",
          422                    [The directory containing the high score file])
          423 AC_SUBST(DPSCOREDIR)
          424 
          425 DP_EXPAND_DIR(DPDATADIR, '${datadir}')
          426 AC_DEFINE_UNQUOTED(DPDATADIR, "$DPDATADIR",
          427                    [The directory containing the sounds])
          428 AC_SUBST(DPDATADIR)
          429 
          430 DP_EXPAND_DIR(DPDOCDIR, '${docdir}')
          431 AC_DEFINE_UNQUOTED(DPDOCDIR, "$DPDOCDIR",
          432                    [The directory containing the docs])
          433 
          434 localedir=${datadir}/locale
          435 AC_SUBST(localedir)
          436 DP_EXPAND_DIR(LOCALEDIR, '${localedir}')
          437 AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR",
          438                    [The directory containing locale files])
          439 
          440 dnl Add in the required clients
          441 AM_CONDITIONAL(GUI_CLIENT, test "$GUI_CLIENT" = "yes")
          442 if test "$GUI_CLIENT" = "yes" ; then
          443   GUILIB="gui_client/libguiclient.a"
          444   AC_SUBST(GUILIB)
          445 fi
          446 AM_CONDITIONAL(CURSES_CLIENT, test "$CURSES_CLIENT" = "yes")
          447 if test "$CURSES_CLIENT" = "yes" ; then
          448   CURSESLIB="curses_client/libcursesclient.a"
          449   AC_SUBST(CURSESLIB)
          450 fi
          451 
          452 dnl Compile in the gtkport stuff for any kind of GUI
          453 AM_CONDITIONAL(GTKPORT, test "$GUI_CLIENT" = "yes" -o "$GUI_SERVER" = "yes")
          454 if test "$GUI_CLIENT" = "yes" -o "$GUI_SERVER" = "yes" ; then
          455   GTKPORTLIB="gtkport/libgtkport.a"
          456   AC_SUBST(GTKPORTLIB)
          457 fi
          458 
          459 dnl Compile in the cursesport stuff for the curses client only
          460 AM_CONDITIONAL(CURSESPORT, test "$CURSES_CLIENT" = "yes")
          461 if test "$CURSES_CLIENT" = "yes" ; then
          462   CURSESPORTLIB="cursesport/libcursesport.a"
          463   AC_SUBST(CURSESPORTLIB)
          464 fi
          465 
          466 AC_SUBST(SOUND_CFLAGS)
          467 AC_SUBST(SOUND_LIBS)
          468 
          469 AC_OUTPUT([
          470 Makefile
          471 src/Makefile
          472 src/gui_client/Makefile
          473 src/curses_client/Makefile
          474 src/gtkport/Makefile
          475 src/cursesport/Makefile
          476 src/plugins/Makefile
          477 sounds/Makefile
          478 sounds/19.5degs/Makefile
          479 doc/Makefile
          480 doc/help/Makefile
          481 rpm/dopewars.spec
          482 doc/dopewars.6
          483 win32/install.nsi
          484 po/Makefile.in],
          485 [])
          486 
          487 echo
          488 echo "dopewars has been configured as follows:"
          489 echo
          490 if test "$CYGWIN" = "yes" ; then
          491    echo "Building native Windows (Win32) version"
          492 else
          493    echo "Building Unix version"
          494 fi
          495 echo
          496 echo "CLIENTS"
          497 if test "$CURSES_CLIENT" = "no" -a "$GUI_CLIENT" = "no" ; then
          498    echo " - No clients will be compiled (binary will be server/AI only)"
          499 else
          500    if test "$CURSES_CLIENT" = "yes" ; then
          501       echo " - Text-mode (curses) client"
          502    fi
          503    if test "$GUI_CLIENT" = "yes" ; then
          504       echo " - Graphical (GTK+ or Win32) client"
          505    fi
          506 fi
          507 
          508 echo
          509 if test "$network" = "yes" ; then
          510    echo "TCP/IP networking support enabled for multi-player games"
          511    echo
          512    echo "SERVER"
          513    if test "$GUI_SERVER" = "yes" ; then
          514       echo " - Graphical server"
          515    else
          516       echo " - Text-mode server"
          517    fi
          518 else
          519    echo "Networking support DISABLED; single-player mode only"
          520 fi
          521 
          522 echo