Add RCS ID tag
[btb/d2x.git] / configure.ac
index dab505f..a7552f4 100644 (file)
@@ -1,8 +1,8 @@
 # -*- mode: shell-script -*-
 
 define([D2X_MAJOR],0)
-define([D2X_MINOR],1)
-define([D2X_MICRO],4)
+define([D2X_MINOR],2)
+define([D2X_MICRO],6)
 
 AC_INIT(d2x,[D2X_MAJOR.D2X_MINOR.D2X_MICRO],[descent-source@warpcore.org])
 AC_PREREQ(2.52)
@@ -11,6 +11,9 @@ AC_CANONICAL_BUILD
 AC_CANONICAL_HOST
 AC_CANONICAL_TARGET
 
+AC_EXEEXT
+AC_OBJEXT
+
 AM_INIT_AUTOMAKE([1.6])
 
 AM_CONFIG_HEADER(conf.h)
@@ -37,6 +40,12 @@ AC_STDC_HEADERS
 AC_PATH_PROGS(NASM, nasm nasmw, no)
 AC_C_BIGENDIAN
 
+case $host_cpu in
+       sparc)
+               AC_DEFINE(WORDS_NEED_ALIGNMENT,,[Define if your processor needs data to be word-aligned])
+       ;;
+esac
+
 case $host_os in
     cygwin)
         AC_MSG_WARN([Cygwin found, setting -mno-cygwin])
@@ -48,12 +57,16 @@ case $host_os in
         ;;
     darwin*)
         MACOSX=yes
-        ;;
+       CFLAGS="-no-cpp-precomp $CFLAGS"
+       ;;
     msdos*)
         MSDOS=yes
         ;;
 esac
 
+AC_CHECK_DECLS(nanosleep,,,[#include <time.h>])
+AC_CHECK_TYPES([struct timespec, struct timeval],,,[#include <sys/time.h>])
+
 AM_CONDITIONAL(MINGW32, test x$MINGW32 = xyes)
 if test x$MINGW32 = xyes; then
     GL_LIBS="opengl32 glu32"
@@ -63,9 +76,6 @@ else
     GL_LIBS="GL GLU"
 fi
 
-if test x$MACOSX = xyes; then
-    AC_DEFINE(__MACOSX__,,[Define if building on MAC OS X])
-fi
 AM_CONDITIONAL(MACOSX, test x$MACOSX = xyes)
 
 dnl Set $prefix and $exec_prefix to $ac_default_prefix if they are not set
@@ -75,25 +85,29 @@ test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"
 dnl Set default locations to find data files.
 default_sharepath="$datadir/games/$PACKAGE"
 
-CFLAGS="-Wall $CFLAGS"
+CFLAGS="-Wall -Wno-char-subscripts $CFLAGS"
+
+D2X_SUBDIRS=""
+D2X_MAIN_SUBDIRS=""
 
 dnl Enable editor build?
 AC_ARG_ENABLE(editor,
     [  --enable-editor         Build editor? (not functional)],,)
 if test x$enable_editor = xyes; then
     AC_DEFINE(EDITOR,,[Define if you want to build the editor])
-    D2X_MAIN_SUBDIRS=editor
+    D2X_SUBDIRS="ui ${D2X_SUBDIRS}"
+    D2X_MAIN_SUBDIRS="editor ${D2X_MAIN_SUBDIRS}"
 fi
 AM_CONDITIONAL(EDITOR, test x$enable_editor = xyes)
 
-dnl Enable shareware build?
-AC_ARG_ENABLE(shareware,
-    [  --enable-shareware      Build for demo datafiles (not functional)],,)
-if test x$enable_shareware = xyes; then
-    AC_DEFINE(SHAREWARE,,[Define if you want to build the demo version])
-    D2X_FEATURES="shareware ${D2X_FEATURES}"
+dnl Enable macdata build?
+AC_ARG_ENABLE(macdata,
+    [  --enable-macdata        Build for mac datafiles],,)
+if test x$enable_macdata = xyes; then
+    AC_DEFINE(MACDATA,,[Define if you want to build for mac datafiles])
+    D2X_FEATURES="macdata ${D2X_FEATURES}"
 fi
-AM_CONDITIONAL(SHAREWARE, test x$enable_shareware = xyes)
+AM_CONDITIONAL(MACDATA, test x$enable_macdata = xyes)
 
 dnl Build with NDEBUG?
 AC_ARG_ENABLE(debug,
@@ -114,6 +128,15 @@ if test x$enable_release = xyes; then
     D2X_FEATURES="release ${D2X_FEATURES}"
 fi
 
+dnl Build without using sdl-joystick ?
+AC_ARG_ENABLE(linuxjoy,
+    [  --enable-linuxjoy       do not use the SDL Joystick. (eg for MS Sidewinder)],,)
+if test x$enable_linuxjoy = xyes; then
+    AC_DEFINE(USE_LINUX_JOY,,[define to not use the SDL_Joystick routines.])
+    D2X_FEATURES="linuxjoy ${D2X_FEATURES}"
+fi
+AM_CONDITIONAL(USE_LINUX_JOY, test x$enable_linuxjoy = xyes)
+
 dnl Build with FAST_FILE_IO?
 AC_ARG_ENABLE(fastfileio,
     [  --disable-fastfileio    Disable fast file i/o. ],,)
@@ -128,6 +151,15 @@ if test x$enable_fastfileio != xno; then
     D2X_FEATURES="fastfileio ${D2X_FEATURES}"
 fi
 
+dnl Build with CONSOLE?
+AC_ARG_ENABLE(console,
+    [  --enable-console        Enable console (experimental) ],,)
+if test x$enable_console = xyes; then
+    AC_DEFINE(CONSOLE,,[Define to enable console])
+    D2X_SUBDIRS="console ${D2X_SUBDIRS}"
+fi
+AM_CONDITIONAL(CONSOLE, test x$enable_console = xyes)
+
 AC_ARG_WITH(sharepath,
     [[  --with-sharepath=DIR    Use DIR for shared game data (unix only) [DATADIR/games/d2x]]],
     sharepath=$withval, sharepath="auto")
@@ -160,6 +192,26 @@ else
 
     AC_CHECK_HEADERS(netipx/ipx.h)
 
+  # Check for SDL_image
+    AC_CHECK_LIB(SDL_image, IMG_ReadXPMFromArray,
+        LIBS="-lSDL_image $LIBS"
+        AC_DEFINE(SDL_IMAGE,,[Define if you have the SDL_image library]))
+
+  # Check for libpng
+    have_libpng=no
+    #PKG_CHECK_MODULES(LIBPNG, libpng,
+    #  AC_DEFINE(HAVE_LIBPNG,,[Define if you have libpng])
+    #  have_libpng=yes
+    #  LIBS="$LIBPNG_LIBS $LIBS",
+    #  AC_MSG_WARN([libpng not found. disabling png replacement texture support])
+#)
+    AM_CONDITIONAL(USE_LIBPNG, test x$have_libpng = xyes)
+
+  # Check for PhysicsFS
+    AC_CHECK_HEADERS(physfs.h, , [AC_MSG_ERROR([physfs.h required])])
+    AC_CHECK_LIB(physfs, PHYSFS_init, LIBS="-lphysfs $LIBS",
+                 [AC_MSG_ERROR([physfs library required])])
+
   # Check for OpenGL
     AC_ARG_WITH(opengl,
         [  --with-opengl           Build OpenGL support ],,)
@@ -229,10 +281,46 @@ dnl Check for network
 AC_ARG_ENABLE(network,
     [  --disable-network       Do not build network/serial support ],,)
 if test x$enable_network != xno; then
+    case $host_os in
+        cygwin* | mingw* | msdos* | linux*)
+            enable_native_ipx="yes";
+           ;;
+       *)
+            AC_MSG_WARN([d2x does not support native ipx on this host.  disabling native ipx])
+            enable_native_ipx="no";
+            ;;
+    esac
+       case $host_os in
+               cygwin* | mingw* | msdos*)
+                       enable_kalinix="no";
+                       ;;
+       esac
+    case $host_os in
+        *solaris*)
+            AC_CHECK_LIB(socket, socket, LIBS="${LIBS} -lsocket",
+               [AC_MSG_ERROR(socket lib required for net support on solaris not found)])
+            AC_CHECK_LIB(nsl, inet_addr, LIBS="${LIBS} -lnsl",
+               [AC_MSG_ERROR(nsl lib required for net support on solaris not found)])          
+           ;;
+    esac
+fi
+AC_ARG_ENABLE(kalinix,
+    [  --disable-kalinix       Disable the KaliNix driver (unix-only)],,)
+if test x$enable_network != xno; then
+    if test x$enable_native_ipx != xno; then
+        D2X_FEATURES="ipx ${D2X_FEATURES}"
+        AC_DEFINE(NATIVE_IPX,,[Define to use the IPX support of the OS])
+    fi
+    if test x$enable_kalinix != xno; then
+        D2X_FEATURES="kalinix ${D2X_FEATURES}"
+        AC_DEFINE(KALINIX,,[Define to enable use of the KaliNix driver])
+    fi
     AC_DEFINE(NETWORK,,[Define if you want a network build])
     D2X_FEATURES="network ${D2X_FEATURES}"
 fi
 AM_CONDITIONAL(USE_NETWORK, test x$enable_network != xno)
+AM_CONDITIONAL(USE_NATIVE_IPX, test x$enable_native_ipx != xno)
+AM_CONDITIONAL(USE_KALINIX, test x$enable_kalinix != xno)
 
 dnl Check for assembler
 AC_ARG_ENABLE(assembler,
@@ -244,14 +332,14 @@ if test x$enable_assembler != xno; then
     else
         NASMFLAGS="-i\$(srcdir)/ $NASMFLAGS"
         case $host_os in
-            cygwin*)
+            cygwin* | mingw*)
                 NASMFLAGS="-f win32 $NASMFLAGS"
                 ;;
             msdos*)
                 NASMFLAGS="-f coff $NASMFLAGS"
                 ;;
-            linux*)
-                NASMFLAGS="-f elf -d__linux__ $NASMFLAGS"
+                       linux* | freebsd*)
+                               NASMFLAGS="-f elf -d__ELF__ $NASMFLAGS"
                 ;;
             *)
                 AC_MSG_WARN([nasm not supported for this OS. disabling assembler])
@@ -268,12 +356,16 @@ AM_CONDITIONAL(USE_ASM, test x$enable_assembler != xno)
 
 AH_BOTTOM([
         /* General defines */
+#ifndef PACKAGE_STRING
+#define PACKAGE_STRING PACKAGE " " VERSION
+#endif
+#define VERSION_NAME PACKAGE_STRING
 #define NMONO 1
 #define PIGGY_USE_PAGING 1
 #define NEWDEMO 1
 
-#ifdef __MACOSX__
-#define __unix__
+#if defined(__APPLE__) && defined(__MACH__)
+#define __unix__ /* since we're doing a unix-style compilation... */
 #endif
 
 #ifdef __unix__
@@ -295,7 +387,7 @@ AH_BOTTOM([
 # endif
 #endif
 
-#ifdef __MINGW32__
+#ifdef _WIN32
 # define SDL_INPUT 1
 # ifdef OGL
 #  define SDL_GL_VIDEO 1
@@ -305,8 +397,12 @@ AH_BOTTOM([
 #endif
         ])
 
+TARGETS="$TARGETS$ac_cv_exeext"
+
 AM_PROG_AS
 
+AC_SUBST(D2X_SUBDIRS)
+
 AC_SUBST(D2X_ARCH_SUBDIRS)
 
 AC_SUBST(D2X_MAIN_SUBDIRS)
@@ -329,14 +425,16 @@ AC_OUTPUT(
     arch/sdl/Makefile
     arch/svgalib/Makefile
     arch/win32/Makefile
-    cfile/Makefile
+    console/Makefile
     iff/Makefile
+    libmve/Makefile
     main/Makefile
     main/editor/Makefile
     maths/Makefile
     mem/Makefile
     misc/Makefile
     texmap/Makefile
+    ui/Makefile
     utilities/Makefile
     debian/changelog
     rpm/d2x.spec
@@ -346,7 +444,7 @@ AC_MSG_RESULT([
         d2x has been configured successfully.
 
         Platform(s): $D2X_ARCH_SUBDIRS
-        Features   : $D2X_FEATURES $D2X_MAIN_SUBDIRS
+        Features   : $D2X_FEATURES $D2X_SUBDIRS $D2X_MAIN_SUBDIRS
 
         Shared game data directory (unix only): $sharepath
         ])