dnl $Id$ dnl Process this file with autoconf to produce a configure script. dnl stick the revision info into the resulting configure script AC_REVISION($Revision$) dnl AC_PREREQ(2.50) AC_INIT(quake2, 0.2.1, quake2-devel@lists.quakeforge.net) AC_CONFIG_AUX_DIR(.) AC_CONFIG_SRCDIR(src/main.c) AM_CONFIG_HEADER(config.h) dnl get the build and target hosts AC_CANONICAL_SYSTEM AM_INIT_AUTOMAKE([1.6 foreign]) dnl configure --enable-maintainer-mode gets some extra targets AM_MAINTAINER_MODE dnl set some macros AC_DEFINE_UNQUOTED(BUILDHOST, "${target_cpu}-${target_os}", [Set to the canonical name of the target machine]) AC_SUBST(PROGRAM) AC_SUBST(VERSION) dnl ---------------------------------- dnl Overall configuration success flag dnl ---------------------------------- quake2_config_ok=yes dnl ------------------- dnl Checks for programs dnl ------------------- AC_PROG_CC dnl libtool is evil AC_PROG_LIBTOOL HAVE_MASM="" AC_SUBST(HAVE_MASM) AS="$CC" ASFLAGS="\$(DEFS) \$(CFLAGS) \$(CPPFLAGS) \$(DEFAULT_INCLUDES) \$(INCLUDES)" CCAS="$AS" CCASFLAGS="$ASFLAGS" AC_SUBST(AS) AC_SUBST(ASFLAGS) AC_SUBST(CCAS) AC_SUBST(CCASFLAGS) dnl -------------------- dnl Checks for libraries dnl -------------------- dnl Solaris networking libraries AC_PATH_PROG(unamepath, uname) if test "_$unamepath" = _; then system="unknown" else AC_MSG_CHECKING(system type) system=`$unamepath -s` AC_MSG_RESULT($system) if test "$system" = "SunOS"; then SYSTEM_LIBS="$SYSTEM_LIBS -lsocket -lnsl" else SYSTEM_LIBS="" fi AC_SUBST(SYSTEM_LIBS) fi dnl Check for ossaudio on NetBSD OSS_LIBS="" AC_CHECK_LIB([ossaudio], [_oss_ioctl], [OSS_LIBS="-lossaudio"]) AC_SUBST(OSS_LIBS) dnl Check for POSIX threads ACX_PTHREAD(,AC_MSG_ERROR(["POSIX threads required!"])) dnl ----------------- dnl Check for SVGAlib dnl ----------------- HAVE_SVGALIB=no AC_ARG_WITH(svgalib, AC_HELP_STRING([--with-svgalib(=DIR)], [use SVGAlib (optionally, found in DIR)]), dnl argument was given, check for --without if test "x${with_svgalib}" != xno ; then ac_with_svgalib=yes else ac_with_svgalib=no fi, ac_with_svgalib=auto ) if test "x${ac_with_svgalib}" != xno ; then # --with-svgalib was explicitly given, then, so # look in that directory if test "x${ac_with_svgalib}" != xauto; then SVGALIB_CFLAGS="$SVGALIB_CFLAGS -I$withval/include" SVGALIB_LIBS="$SVGALIB_LIBS -L$withval/lib" fi # set CPPFLAGS for the coming tests save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $SVGALIB_CFLAGS" # test for the library first, for people who may have the libs # installed but no headers AC_CHECK_LIB(vga, vga_getmousetype, HAVE_SVGALIB=maybe, HAVE_SVGALIB=no, [ $SVGALIB_LIBS ] ) # check the header now if test "x$HAVE_SVGALIB" = xmaybe ; then AC_CHECK_HEADER(vga.h, HAVE_SVGALIB="yes", HAVE_SVGALIB="no" ) fi # if it's all there, define the relevant bits if test "x$HAVE_SVGALIB" = xyes ; then AC_DEFINE(HAVE_SVGALIB, 1, [Define this if you have SVGAlib]) SVGALIB_LIBS="-lvga" AC_SUBST(SVGALIB_CFLAGS) AC_SUBST(SVGALIB_LIBS) else # we were explicitly told to use svgalib and it's not there if test "x${ac_with_svgalib}" = xyes; then AC_MSG_WARN([ *** You have explicitly asked for SVGAlib support, but the required libraries *** and development files could not be found. *** SVGAlib based refreshers will NOT be built]) fi fi # unset CPPFLAGS CPPFLAGS="$save_CPPFLAGS" else HAVE_SVGALIB=disabled fi dnl ------------- dnl Check for X11 dnl ------------- AC_PATH_XTRA if test "x$no_x" = x; then HAVE_X=yes HAVE_XF86_VIDMODE=yes HAVE_XF86_DGA=yes XTRA_LIBS="-lX11" AC_CHECK_LIB(Xext, XShmQueryExtension, XTRA_LIBS="$XTRA_LIBS -lXext", HAVE_X=no, [ $X_LIBS $XTRA_LIBS $X_EXTRA_LIBS ] ) if test "x$HAVE_X" = xyes; then save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $X_CFLAGS" AC_CHECK_HEADER(X11/extensions/xf86vmode.h, dnl Make sure the library works AC_CHECK_LIB(Xxf86vm, XF86VidModeSwitchToMode, XTRA_LIBS="$XTRA_LIBS -lXxf86vm" AC_DEFINE(HAVE_XF86_VIDMODE, 1, [Define this if you have the xf86vmode extension and its Xxf86vm library.]), HAVE_XF86_VIDMODE=no, [$X_LIBS $XTRA_LIBS $X_EXTRA_LIBS] ), HAVE_XF86_VIDMODE=no, [#include ] ) CPPFLAGS="$save_CPPFLAGS" fi if test "x$HAVE_X" = xyes; then save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $X_CFLAGS" AC_CHECK_HEADER(X11/extensions/xf86dga.h, AC_CHECK_LIB(Xxf86dga, XF86DGAQueryVersion, XTRA_LIBS="$XTRA_LIBS -lXxf86dga" AC_DEFINE(HAVE_XF86_DGA, 1, [Define this if you have the xf86dga extension and its Xxf86dga library.]), HAVE_XF86_DGA=no, [$X_LIBS $XTRA_LIBS $X_EXTRA_LIBS] ), HAVE_XF86_DGA=no, [#include ] ) CPPFLAGS="$save_CPPFLAGS" fi if test "x$HAVE_X" != xyes; then XTRA_LIBS="" fi fi AC_SUBST(HAVE_X) AC_SUBST(HAVE_XF86_VIDMODE) AC_SUBST(HAVE_XF86_DGA) AC_SUBST(XTRA_LIBS) dnl ---------------- dnl Check for OpenGL dnl ---------------- HAVE_OPENGL=no AC_ARG_WITH(opengl, AC_HELP_STRING([--with-opengl(=DIR)], [use OpenGL (optionall, found in DIR)]), dnl argument was given check for --without if test "x${with_opengl}" != xno ; then ac_with_opengl=yes else ac_with_opengl=no fi, ac_with_opengl=auto ) if test "x${ac_with_opengl}" != xno ; then # --with-opengl was explicitly given, so look in that directory if test "x${ac_with_opengl}" != xauto ; then OPENGL_CFLAGS="$OPENGL_CFLAGS -I$withval/include" OPENGL_LIBS="$OPENGL_CFLAGS -L$withval/lib" fi # set CPPFLAGS for coming tests save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $OPENGL_CFLAGS" # test for installed library first, for people who may have # the libs installed but no headers AC_CHECK_LIB(GL, glBegin, OPENGL_LIBS="$OPENGL_LIBS -lGL" HAVE_OPENGL="maybe", dnl add -lX11 and -lXext if the first test failed dnl (for, e.g. FreeBSD) unset ac_cv_lib_GL_glBegin AC_CHECK_LIB(GL, glBegin, OPENGL_LIBS="$OPENGL_LIBS -lX11 -lXext" HAVE_OPENGL="maybe", HAVE_OPENGL="no", [$OPENGL_LIBS -lX11 -lXext] ), [ $OPENGL_LIBS ] ) # check the header now if test "x$HAVE_OPENGL" = xmaybe ; then AC_CHECK_HEADER(GL/gl.h, HAVE_OPENGL="yes", HAVE_OPENGL="no" ) fi # check for glext.h if test "x$HAVE_OPENGL" = xyes; then AC_CHECK_HEADER(GL/glext.h, HAVE_OPENGL_GLEXT=yes AC_DEFINE(HAVE_OPENGL_GLEXT, 1, [Define this if you have GL/glext.h]), HAVE_OPENGL_GLEXT=no, [#include ]) fi if test "x$HAVE_OPENGL" = xyes; then AC_DEFINE(HAVE_OPENGL, 1, [Define this if you have OpenGL]) OPENGL_LIBS="-lGL" AC_SUBST(OPENGL_CFLAGS) AC_SUBST(OPENGL_LIBS) else # we were explicitly told to use opengl and it's not there if test "x${ac_with_opengl}" = xyes ; then AC_MSG_WARN([ *** You have explicitly asked for OpenGL support, but the required libraries *** and development files could not be found. *** OpenGL based refreshers will NOT be built]) fi fi # unset CPPFLAGS CPPFLAGS="$save_CPPFLAGS" else HAVE_OPENGL=disabled fi dnl ------------- dnl Check for SDL dnl ------------- AC_ARG_ENABLE(sdl, [ --disable-sdl disable checking for SDL ], ) if test "x$enable_sdl" != xno; then AM_PATH_SDL(1.2.0, HAVE_SDL=yes, HAVE_SDL=no) AC_SUBST(HAVE_SDL) fi dnl ------------------------ dnl Check for MPG123 library dnl ------------------------ HAVE_MPG123=disabled dnl --------------------- dnl Check for zip library dnl --------------------- HAVE_ZIP=disabled dnl ----------------------- dnl Checks for header files dnl ----------------------- #AC_PATH_X #AC_HEADER_DIRENT #AC_HEADER_STDC dnl AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([ sys/soundcard.h ]) dnl ------------------------------------------------------------- dnl Checks for typedefs, structures, and compiler characteristics dnl ------------------------------------------------------------- AC_C_CONST AC_C_INLINE AC_TYPE_SIZE_T AC_HEADER_TIME AC_STRUCT_TM AC_TYPE_UID_T AC_TYPE_VA_LIST AC_MSG_CHECKING(for underscore prefix in names) AC_TRY_LINK( [asm(".long _bar"); int bar;], [], AC_DEFINE(HAVE_SYM_PREFIX_UNDERSCORE, 1, [Define this if C symbols are prefixed with an underscore]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no) ) if test "x$ac_cv_header_sys_soundcard_h" = "xyes"; then AC_MSG_CHECKING(for AFMT_S16_NE in sys/soundcard.h) AC_EGREP_CPP([QF_maGiC_VALUE], [ #include #ifdef AFMT_S16_NE QF_maGiC_VALUE #endif ], HAVE_AFMT_S16_NE=yes AC_MSG_RESULT(yes) , AC_MSG_RESULT(no) ) else if test "x$ac_cv_header_soundcard_h" = "xyes"; then AC_MSG_CHECKING(for AFMT_S16_NE in soundcard.h) AC_EGREP_CPP([QF_maGiC_VALUE], [ #include #ifdef AFMT_S16_NE QF_maGiC_VALUE #endif ], HAVE_AFMT_S16_NE=yes AC_MSG_RESULT(yes) , AC_MSG_RESULT(no) ) fi fi AC_SUBST(HAVE_AFMT_S16_NE) dnl ----------------------------- dnl Checks for library functions. dnl ----------------------------- #AC_FUNC_ERROR_AT_LINE #AC_PROG_GCC_TRADITIONAL #AC_FUNC_MALLOC #AC_FUNC_MEMCMP #AC_FUNC_MMAP #AC_TYPE_SIGNAL #AC_FUNC_STAT #AC_FUNC_VPRINTF #AC_CHECK_FUNCS([bzero floor getcwd gethostbyname getmntent getpagesize gettimeofday memmove memset mkdir munmap pow putenv select socket sqrt strcasecmp strchr strdup strerror strrchr strstr]) AC_FUNC_VA_COPY AC_FUNC__VA_COPY dnl Check for dynamic loader -- needed for the GL refreshers AC_CHECK_FUNCS(dlopen) DL_LIBS="" if test "x$ac_cv_func_dlopen" != "xyes"; then AC_CHECK_LIB(dl, dlopen, AC_DEFINE(HAVE_DLOPEN, 1, [Define if you have the dlopen function.]) DL_LIBS="-ldl" ) fi AC_SUBST(DL_LIBS) #SDL_FLAGS=`sdl-config --libs` #AC_SUBST(SDL_FLAGS) dnl -------------------- dnl Input device support dnl -------------------- AC_MSG_CHECKING(whether to enable joystick support) AC_ARG_ENABLE(joystick, [ --disable-joystick disable joystick support ], AC_MSG_RESULT(no), AC_MSG_RESULT(yes) HAVE_JOYSTICK=yes ) if test "x$HAVE_JOYSTICK" = "xyes";then AC_CHECK_HEADER(linux/joystick.h, HAVE_JOYSTICK=yes AC_DEFINE(HAVE_JOYSTICK, 1, [Define this if you want joystick support to be built]) , HAVE_JOYSTICK=no) fi dnl ------------------------- dnl Optimising compiler flags dnl ------------------------- OPT_CFLAGS="" USE_OPT="" AC_MSG_CHECKING(whether to allow compiler optimisations) AC_ARG_ENABLE(opt, [ --disable-opt disable compiler optimisations ], AC_MSG_RESULT(no), AC_MSG_RESULT(yes) USE_OPT="yes" OPT_CFLAGS="$OPT_CFLAGS -O2 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations" ) if test "x$USE_OPT" = "xyes"; then case "${host}" in i?86-*-*) AC_MSG_CHECKING(whether -falign-functions works) save_CFLAGS="$CFLAGS" CFLAGS="-falign-functions" AC_TRY_COMPILE( [], [], OPT_CFLAGS="$OPT_CFLAGS -falign-loops=2 -falign-jumps=2 -falign-functions=2" AC_MSG_RESULT(yes), OPT_CFLAGS="$OPT_CFLAGS -malign-loops=2 -malign-jumps=2 -malign-functions=2" AC_MSG_RESULT(no), ) CFLAGS="$save_CFLAGS" ;; *) ;; esac fi AC_SUBST(OPT_CFLAGS) dnl ----------------- dnl Compiler warnings dnl ----------------- WARN_CFLAGS="" dnl USE_WARN="" AC_MSG_CHECKING(whether to enable compiler warnings) AC_ARG_ENABLE(warn, [ --disable-warn disable compiler warnings ], AC_MSG_RESULT(no), AC_MSG_RESULT(yes) dnl USE_WARN="yes" WARN_CFLAGS="$WARN_CFLAGS -Wall -Werror" ) AC_SUBST(WARN_CFLAGS) dnl ------------------------------ dnl Check for archs that use lib64 dnl ------------------------------ AC_MSG_CHECKING(whether 64 bit library install path applies) if test "x${libdir}" = "x\${exec_prefix}/lib"; then case "${host}" in powerpc64|x86_64|mips64|s390x-*) libdir=${libdir}64 AC_MSG_RESULT(yes) ;; *) AC_MSG_RESULT(no) ;; esac else AC_MSG_RESULT(no) fi dnl ------------------- dnl Checks for asm junk dnl ------------------- AC_MSG_CHECKING(if assembler can be used) case "${host}" in i?86-*-*) AC_MSG_RESULT(yes) AC_MSG_CHECKING(if asm is disabled) AC_ARG_ENABLE(asm, [ --disable-asm disable assembler optimisation ], AC_MSG_RESULT(asm disabled), AC_DEFINE(USE_ASM, 1, [Define this if you want to use assembler optimised code]) ASM_ARCH=yes AC_MSG_RESULT(asm enabled) ) ;; *) AC_MSG_RESULT(no) ;; esac AM_CONDITIONAL(ASM_ARCH, test "$ASM_ARCH" = "yes") dnl ------------------- dnl Checks for SDL-only platforms dnl ------------------- AC_MSG_CHECKING(if SDL sound can be used instead of native drivers) case "${host}" in *-sun-solaris*) AC_MSG_RESULT(yes) AC_MSG_WARN(Defaulting to SDL sound under Solaris due to temporary lack of native support.) BUILD_SDLQUAKE2=yes AC_DEFINE(BUILD_SDLQUAKE2, 1, [Define this if you want SDL sound instead of native drivers]) ;; i?86-*-*) AC_MSG_RESULT(yes) AC_MSG_CHECKING(if SDL sound will be used) AC_ARG_ENABLE(sdlsound, [ --enable-sdlsound enable SDL sound instead of native drivers ], AC_MSG_RESULT(yes) AC_DEFINE(BUILD_SDLQUAKE2, 1, [Define this if you want SDL sound instead of native drivers]) BUILD_SDLQUAKE2=yes, AC_MSG_RESULT(no) ) ;; *) AC_MSG_RESULT(no) ;; esac AM_CONDITIONAL(BUILD_SDLQUAKE2, test "x$BUILD_SDLQUAKE2" = "xyes") dnl --------------------------------------------------- dnl Check if the xatrix and rogue sources are available dnl --------------------------------------------------- AC_MSG_CHECKING(if Xatrix missionpack source is available) if test -f src/xatrix/g_main.c; then AC_MSG_RESULT(yes) DO_XATRIX=yes else AC_MSG_RESULT(no) fi AC_MSG_CHECKING(if Rogue missionpack source is available) if test -f src/rogue/g_main.c; then AC_MSG_RESULT(yes) DO_ROGUE=yes else AC_MSG_RESULT(no) fi AM_CONDITIONAL(DO_XATRIX, test "$DO_XATRIX" = "yes") AM_CONDITIONAL(DO_ROGUE, test "$DO_ROGUE" = "yes") dnl ---------------------- dnl Fill in path variables dnl ---------------------- dnl $libdir usually gets set to ${exec_prefix}/lib, dnl $prefix and $exec_prefix is likely to be "NONE" dnl Autoconf usually sets pkglibdir correctly in the Makefile, but not in dnl the configure script :( test "$prefix" = "NONE" && prefix=/usr/local test "$exec_prefix" = "NONE" && exec_prefix=$prefix eval PKGLIBDIR="$libdir/$PACKAGE" AC_DEFINE_UNQUOTED(PKGLIBDIR, "$PKGLIBDIR", [Define this to the path containing the dynamic modules (\${exec-prefix}/lib/quake2/)]) eval PKGDATADIR="$datadir/$PACKAGE" AC_DEFINE_UNQUOTED(PKGDATADIR, "$PKGDATADIR", [Define this to the path containing the game data (\${prefix}/share/quake2/)]) dnl --------------------------------- dnl Work out what refreshers to build dnl --------------------------------- VID_REFS="" if test "x$HAVE_SVGALIB" = xyes; then VID_REFS="$VID_REFS ref_soft.la" BUILD_SOFT="yes" fi if test "x$HAVE_X" = xyes; then VID_REFS="$VID_REFS ref_softx.la" BUILD_SOFTX="yes" fi if test "x$HAVE_SDL" = xyes; then VID_REFS="$VID_REFS ref_softsdl.la" BUILD_SOFTSDL="yes" fi if test "x$HAVE_X" = xyes -a "x$HAVE_OPENGL" = xyes; then VID_REFS="$VID_REFS ref_glx.la" BUILD_GLX="yes" fi if test "x$HAVE_X" = xyes -a "x$HAVE_OPENGL" = xyes -a "x$HAVE_SVGALIB" = xyes; then VID_REFS="$VID_REFS ref_tdfx.la" BUILD_TDFX="yes" fi if test "x$HAVE_X" = xyes -a "x$HAVE_OPENGL" = xyes -a "x$HAVE_SDL" = xyes; then VID_REFS="$VID_REFS ref_sdlgl.la" BUILD_SDLGL="yes" fi AM_CONDITIONAL(BUILD_SOFT, test "x$BUILD_SOFT" = xyes) AM_CONDITIONAL(BUILD_SOFTX, test "x$BUILD_SOFTX" = xyes) AM_CONDITIONAL(BUILD_SOFTSDL, test "x$BUILD_SOFTSDL" = xyes) AM_CONDITIONAL(BUILD_GLX, test "x$BUILD_GLX" = xyes) AM_CONDITIONAL(BUILD_TDFX, test "x$BUILD_TDFX" = xyes) AM_CONDITIONAL(BUILD_SDLGL, test "x$BUILD_SDLGL" = xyes) AC_SUBST(VID_REFS) dnl ----------------------------------------------------------- dnl Configuraton tests complete -- provide a summary of results dnl ----------------------------------------------------------- if test $quake2_config_ok = no ; then dnl AC_MSG_RESULT([ dnl Quake2Forge $VERSION: Automatic configuration FAILED. dnl dnl The file config.log has full details. dnl dnl The following required libraries are missing or misconfigured dnl on your system: dnl ]) dnl if test "x$HAVE_OPENGL" != xyes echo "nothing yet" else dnl Dump it out AC_CONFIG_FILES([ Makefile src/Makefile src/baseq2/Makefile src/ctf/Makefile src/xatrix/Makefile src/rogue/Makefile data/Makefile data/pixmaps/Makefile data/baseq2/Makefile quake2.spec ]) AC_OUTPUT VID_REFS=`echo $VID_REFS | sed -e 's/ref_//g' -e 's/\.la//g'` AC_MSG_RESULT([ Quake2Forge $VERSION: Automatic configuration OK. Configuration summary: Platform: .......... ${host} Video refreshers: .. ${VID_REFS- none}]) AC_MSG_RESULT([ SVGAlib: ......... $HAVE_SVGALIB]) if test "x${ac_with_svgalib}" = xyes; then if test "x${HAVE_SVGALIB}" != xyes; then AC_MSG_RESULT([ *** SVGAlib was specifically requested but the development files *** and libraries could not be found. ]) if test "x${with_svgalib}" != xyes; then AC_MSG_RESULT([*** The path given was `$with_svgalib'.]) fi fi fi AC_MSG_RESULT([ X11: ............. $HAVE_X]) AC_MSG_RESULT([ OpenGL: .......... $HAVE_OPENGL]) if test "x${ac_with_opengl}" = xyes ; then if test "x${HAVE_OPENGL}" != xyes ; then AC_MSG_RESULT([ *** OpenGL was specifically requested but the development files *** and libraries could not be found. ]) if test "x${with_svgalib}" != xyes ; then AC_MSG_RESULT([*** The path given was `$with_svgalib'.]) fi fi fi AC_MSG_RESULT([ SDL: ............. $HAVE_SDL]) dnl AC_MSG_RESULT([ Framebuffer: ..... $HAVE_FB]) dnl AC_MSG_RESULT([ AAlib: ........... $HAVE_AA]) AC_MSG_RESULT([ Installation directories: Program: ........... ${prefix}/bin Audio/Video plugins: $PKGLIBDIR Game data: ......... $PKGDATADIR Type 'make' to compile Quake2Forge. Type 'make install' to install Quake2Forge. Game data needs to be installed in the game data directory shown above, before the game can be played. See the file README in the top directory of the source for more details. Happy fragging! ]) fi