foxygit / doom Log in
commit a0062502d183d5d526c1f801b1206234b664898b
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Tue Dec 9 19:56:43 2008 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Tue Dec 9 19:56:43 2008 +0000

    Add SDL_CFLAGS, SDL_LDFLAGS to default compile flags, and check for SDL
    in configure before checking for libraries and headers, to fix Windows.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 1412
---
 configure.in                    | 22 +++++++++++++++++-----
 pcsound/Makefile.am             |  2 +-
 setup/Makefile.am               |  5 +++--
 src/Makefile.am                 | 11 ++++++++---
 textscreen/Makefile.am          |  2 +-
 textscreen/examples/Makefile.am |  2 +-
 6 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/configure.in b/configure.in
index bf2a2c75..43e3438f 100644
--- a/configure.in
+++ b/configure.in
@@ -7,7 +7,6 @@ orig_CFLAGS="$CFLAGS"
 AC_PROG_CC
 AC_PROG_RANLIB
 AC_CHECK_PROG(HAVE_PYTHON, python, true, false)
-AC_CHECK_FUNCS(mmap)

 OPT_LEVEL=2

@@ -25,24 +24,37 @@ then
         CFLAGS="-O$OPT_LEVEL -g -Wall $orig_CFLAGS"
 fi

-AC_CHECK_HEADERS([linux/kd.h dev/isa/spkrio.h dev/speaker/speaker.h])
+dnl Search for SDL ...

 AM_PATH_SDL(1.1.3)

+# Add the SDL compiler flags to the default compiler flag variables.
+# It is important to do this now, before checking for headers and
+# library functions.  The reason being that on Windows, sdl-config
+# sets the -mno-cygwin compiler option in order to generate MinGW
+# executables.  If we don't do this now, we might end up discovering
+# header files that are not actually available to us when we come
+# to compile.
+
+CFLAGS="$CFLAGS $SDL_CFLAGS"
+LDFLAGS="$LDFLAGS $SDL_LIBS"
+
 AC_CHECK_LIB(SDL_mixer,Mix_LoadMUS,[
-dnl    AC_DEFINE(HAVE_LIBSDL_MIXER)
     SDLMIXER_LIBS="$SDLMIXER_LIBS -lSDL_mixer"
 ],[
     echo "*** Could not find SDL_mixer.  Please install it."
     exit -1
-],$SDL_LIBS $SDLMIXER_LIBS)
+])

 AC_CHECK_LIB(SDL_net,SDLNet_UDP_Send,[
     SDLNET_LIBS="$SDLNET_LIBS -lSDL_net"
 ],[
     echo "*** Could not find SDL_net.  Please install it."
     exit -1
-] ,$SDL_LIBS $SDLNET_LIBS)
+])
+
+AC_CHECK_HEADERS([linux/kd.h dev/isa/spkrio.h dev/speaker/speaker.h])
+AC_CHECK_FUNCS(mmap)

 # DWF 2008-02-10:  FIXME
 AC_CHECK_LIB(samplerate, src_new)
diff --git a/pcsound/Makefile.am b/pcsound/Makefile.am
index 63c76f77..b956a886 100644
--- a/pcsound/Makefile.am
+++ b/pcsound/Makefile.am
@@ -1,5 +1,5 @@

-AM_CFLAGS= @SDL_CFLAGS@ @SDLMIXER_CFLAGS@
+AM_CFLAGS=@SDLMIXER_CFLAGS@

 noinst_LIBRARIES=libpcsound.a

diff --git a/setup/Makefile.am b/setup/Makefile.am
index f845f853..b7b05520 100644
--- a/setup/Makefile.am
+++ b/setup/Makefile.am
@@ -1,11 +1,10 @@

 gamesdir = $(prefix)/games

-AM_CFLAGS = @SDL_CFLAGS@ -I../textscreen -I../src -DINSTALL_DIR="\"$(gamesdir)\""
+AM_CFLAGS = -I../textscreen -I../src -DINSTALL_DIR="\"$(gamesdir)\""

 games_PROGRAMS = chocolate-setup

-chocolate_setup_LDADD = ../textscreen/libtextscreen.a @LDFLAGS@ @SDL_LIBS@
 SOURCE_FILES =                                  \
     compatibility.c   compatibility.h           \
     configfile.c      configfile.h              \
@@ -32,6 +31,8 @@ else
 chocolate_setup_SOURCES=$(SOURCE_FILES)
 endif

+chocolate_setup_LDADD = ../textscreen/libtextscreen.a @LDFLAGS@
+
 .rc.o:
 	$(WINDRES) $^ -o $@
 %.o : %.rc
diff --git a/src/Makefile.am b/src/Makefile.am
index e43cb7f0..63ddc98f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,7 +3,7 @@ gamesdir = $(prefix)/games

 games_PROGRAMS = chocolate-doom chocolate-server

-AM_CFLAGS = -I../textscreen -I../pcsound @SDL_CFLAGS@ @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@
+AM_CFLAGS = -I../textscreen -I../pcsound @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@

 DEDSERV_FILES=\
 d_dedicated.c                              \
@@ -21,7 +21,7 @@ net_structrw.c       net_structrw.h        \
 z_native.c           z_zone.h

 chocolate_server_SOURCES=$(DEDSERV_FILES)
-chocolate_server_LDADD = @LDFLAGS@ @SDL_LIBS@ @SDLNET_LIBS@
+chocolate_server_LDADD = @LDFLAGS@ @SDLNET_LIBS@

 MAIN_SOURCE_FILES=\
 am_map.c             am_map.h              \
@@ -169,7 +169,12 @@ else
 chocolate_doom_SOURCES=$(SOURCE_FILES)
 endif

-chocolate_doom_LDADD = ../textscreen/libtextscreen.a ../pcsound/libpcsound.a @LDFLAGS@ @SDL_LIBS@ @SDLMIXER_LIBS@ @SDLNET_LIBS@
+chocolate_doom_LDADD =                               \
+                       ../textscreen/libtextscreen.a \
+                       ../pcsound/libpcsound.a       \
+                       @LDFLAGS@                     \
+                       @SDLMIXER_LIBS@               \
+                       @SDLNET_LIBS@

 EXTRA_DIST =                        \
         icon.c                      \
diff --git a/textscreen/Makefile.am b/textscreen/Makefile.am
index 752e6361..76fe8f0f 100644
--- a/textscreen/Makefile.am
+++ b/textscreen/Makefile.am
@@ -1,5 +1,5 @@

-AM_CFLAGS = @SDL_CFLAGS@ -I../src
+AM_CFLAGS = -I../src

 # build this directory before the examples directory.

diff --git a/textscreen/examples/Makefile.am b/textscreen/examples/Makefile.am
index f6d247ea..e314e7e8 100644
--- a/textscreen/examples/Makefile.am
+++ b/textscreen/examples/Makefile.am
@@ -1,5 +1,5 @@

-AM_CFLAGS = @SDL_CFLAGS@ -I.. -I../../src
+AM_CFLAGS = -I.. -I../../src

 noinst_PROGRAMS=guitest calculator