diff --git a/AUTHORS b/AUTHORS index 1b9c26d..cd68234 100644 --- a/AUTHORS +++ b/AUTHORS @@ -51,3 +51,7 @@ Math fixes/optimizations: Documentation: Nelson J. Rush Joseph Carter + +SDL Support: + Sam Lantinga + Maas van den Berg diff --git a/common/cd_wrapper.c b/common/cd_wrapper.c index 4cbe299..1af598e 100644 --- a/common/cd_wrapper.c +++ b/common/cd_wrapper.c @@ -17,9 +17,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#if defined(__linux__) - #include "cd_linux.c" -#else - #include "cd_null.c" +#if defined(SDL) + #include "cd_sdl.c" +#else + #if defined(__linux__) + #include "cd_linux.c" + #else + #include "cd_null.c" + #endif #endif diff --git a/configure.in b/configure.in index fd804d4..366c226 100644 --- a/configure.in +++ b/configure.in @@ -63,7 +63,6 @@ if test "x$HAS_GGI" != xno; then CPPFLAGS="$save_CPPFLAGS" fi - dnl Checks for SVGALib support SVGA_CFLAGS="" SVGA_LIBS="" @@ -86,6 +85,23 @@ if test "x$HAS_SVGA" != xno; then CPPFLAGS="$save_CPPFLAGS" fi +dnl Checks for SDL support +SDL_CFLAGS="" +SDL_LIBS="" +AC_ARG_WITH(sdl, +[ --with-sdl=DIR use SDL found in DIR], +HAS_SDL=$withval, HAS_SDL=auto) +if test "x$HAS_SDL" != xno; then + if test "x$HAS_SDL" != xauto; then + SDL_CFLAGS="-I$withval/include" + SDL_LIB="-L$withbal/lib" + fi + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $SDL_CFLAGS" + AC_CHECK_HEADER(SDL/SDL.h, HAS_SDL=yes, HAS_SDL=no) + CPPFLAGS="$save_CPPFLAGS" +fi + dnl Checks for GLIDE support GLIDE_CFLAGS="" @@ -200,6 +216,26 @@ if test "x$HAS_SVGA" != xyes; then SVGA_CFLAGS="" SVGA_LIBS="" fi +dnl Make sure -lpthread works (for SDL) +if test "x$HAS_SDL" = xyes; then + AC_CHECK_LIB(pthread, pthread_exit ,SDL_LIBS="$SDL_LIBS -lpthread" + HAS_SDL=yes, HAS_SDL=no, [$SDL_LIBS]) +fi +if test "x$HAS_SDL" != xyes; then + SDL_CFLAGS="" SDL_LIBS="" +fi + +dnl Make sure -lSDL works +if test "x$HAS_SDL" = xyes; then + AC_CHECK_LIB(SDL, SDL_Init, SDL_LIBS="$SDL_LIBS -lSDL" + HAS_SDL=yes, HAS_SDL=no, [$SDL_LIBS]) +fi +if test "x$HAS_SDL" != xyes; then + SDL_CFLAGS="" SDL_LIBS="" +fi + + + dnl Make sure -lglide2x works if test "x$HAS_GLIDE" = xyes; then @@ -292,6 +328,9 @@ AC_DEFINE(HAVE_GL_COLOR_INDEX8_EXT, HAS_INDEX8) AC_SUBST(HAS_TDFXGL) AC_SUBST(TDFXGL_CFLAGS) AC_SUBST(TDFXGL_LIBS) +AC_SUBST(HAS_SDL) +AC_SUBST(SDL_CFLAGS) +AC_SUBST(SDL_LIBS) dnl Checks for library functions. AC_PROG_GCC_TRADITIONAL diff --git a/qw_client/Makefile.in b/qw_client/Makefile.in index 2c00196..c6498ff 100644 --- a/qw_client/Makefile.in +++ b/qw_client/Makefile.in @@ -27,6 +27,7 @@ HAS_TDFXGL = @HAS_TDFXGL@ HAS_OGL = @HAS_OGL@ HAS_XIL = @HAS_XIL@ HAS_X11 = @HAS_X11@ +HAS_SDL = @HAS_SDL@ MAKE_SURE_DIR = if test -d "$(BUILD_DIR)/$$DIR"; \ then \ @@ -62,6 +63,10 @@ ifeq ($(HAS_GGI),yes) GGIQUAKE = $(BIN_PREFIX)-ggi endif +ifeq ($(HAS_SDL),yes) +SDLQUAKE = $(BIN_PREFIX)-sdl +endif + RELEASE = @RELEASE@ ifeq ($(RELEASE),yes) OPTFLAGS = @RELEASE_CFLAGS@ @@ -69,7 +74,7 @@ else OPTFLAGS = -g endif -targets = $(GGIQUAKE) $(SVGAQUAKE) $(GLQUAKE) $(TDFXQUAKE) $(X11QUAKE) +targets = $(GGIQUAKE) $(SVGAQUAKE) $(GLQUAKE) $(TDFXQUAKE) $(X11QUAKE) $(SDLQUAKE) CLEAN_TARGETS = $(patsubst %,clean-%, $(targets)) .PHONY: $(targets) ($CLEAN_TARGETS) @@ -461,6 +466,54 @@ clean-$(TDFXQUAKE): endif +########################################################################### +# +# qw-client-sdl +# +ifneq ($(SDLQUAKE),) +ALL_SDL_SRC = $(GENERAL_SRC) $(SW_REND_SRC) $(SDL_VID_SRC) model.c +OBJSquake-sdl= $(patsubst %,$(BUILD_DIR)/sdl/%,$(addsuffix .@OBJEXT@, $(basename $(ALL_SDL_SRC) .c .s))) + +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_LDFLAGS = @SDL_LIBS@ -lm +SDL_VID_SRC = vid_sdl.c + +# This can be thought of as a macro that makes sure that the x11 +# sub-directory is created +# XXX - can we avoid doing every compile? +MAKE_SURE_sdl_DIR = @DIR=sdl; $(MAKE_SURE_DIR) + +$(BUILD_DIR)/sdl/%.o: $(SRC_DIR)/%.c + $(MAKE_SURE_sdl_DIR) + $(CC) $(CFLAGS) $(SDL_CFLAGS) -o $@ -c $< + +$(BUILD_DIR)/sdl/%.o: $(SRC_DIR)/%.s + $(MAKE_SURE_sdl_DIR) + $(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $< + +$(BUILD_DIR)/sdl/%.o: $(COMMON_DIR)/%.c + $(MAKE_SURE_sdl_DIR) + $(CC) $(CFLAGS) $(SDL_CFLAGS) -o $@ -c $< + +ifneq ($(QW_COMMON_DIR),) +$(BUILD_DIR)/sdl/%.o: $(QW_COMMON_DIR)/%.c + $(MAKE_SURE_sdl_DIR) + $(CC) $(CFLAGS) $(SDL_CFLAGS) -o $@ -c $< +endif + +$(BUILD_DIR)/sdl/%.o: $(COMMON_DIR)/%.s + $(MAKE_SURE_sdl_DIR) + $(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $< + +$(SDLQUAKE): $(BUILD_DIR)/../$(SDLQUAKE) + +$(BUILD_DIR)/../$(SDLQUAKE): $(OBJSquake-sdl) + $(CC) $(CFLAGS) $(OBJSquake-sdl) $(SDL_LDFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/../$(SDLQUAKE) +# XXX - Can this be automated? +clean-$(SDLQUAKE): + rm -f $(OBJSquake-sdl) +endif + ########################################################################### # # cleaning (clean, distclean) diff --git a/uquake/Makefile.in b/uquake/Makefile.in index 1458eeb..cd2407e 100644 --- a/uquake/Makefile.in +++ b/uquake/Makefile.in @@ -26,6 +26,7 @@ HAS_TDFXGL = @HAS_TDFXGL@ HAS_OGL = @HAS_OGL@ HAS_XIL = @HAS_XIL@ HAS_X11 = @HAS_X11@ +HAS_SDL = @HAS_SDL@ MAKE_SURE_DIR = if test -d "$(BUILD_DIR)/$$DIR"; \ then \ @@ -61,6 +62,10 @@ ifeq ($(HAS_GGI),yes) GGIQUAKE = $(BIN_PREFIX)-ggi endif +ifeq ($(HAS_SDL),yes) +SDLQUAKE = $(BIN_PREFIX)-sdl +endif + RELEASE = @RELEASE@ ifeq ($(RELEASE),yes) OPTFLAGS = @RELEASE_CFLAGS@ @@ -68,7 +73,7 @@ else OPTFLAGS = -g endif -targets = $(GGIQUAKE) $(SVGAQUAKE) $(GLQUAKE) $(TDFXQUAKE) $(X11QUAKE) +targets = $(GGIQUAKE) $(SVGAQUAKE) $(GLQUAKE) $(TDFXQUAKE) $(X11QUAKE) $(SDLQUAKE) CLEAN_TARGETS = $(patsubst %,clean-%, $(targets)) .PHONY: $(targets) ($CLEAN_TARGETS) @@ -419,6 +424,48 @@ clean-$(TDFXQUAKE): endif +########################################################################### +# +# quake-sdl +# +ifneq ($(SDLQUAKE),) +ALL_SDL_SRC = $(GENERAL_SRC) $(SW_REND_SRC) $(SDL_VID_SRC) model.c +OBJSquake-sdl= $(patsubst %,$(BUILD_DIR)/sdl/%,$(addsuffix .@OBJEXT@, $(basename $(ALL_SDL_SRC) .c .s))) + +SDL_CFLAGS = @SDL_CFLAGS@ -DSDL +SDL_LDFLAGS = @SDL_LIBS@ -lm +SDL_VID_SRC = vid_sdl.c + +# This can be thought of as a macro that makes sure that the x11 +# sub-directory is created +# XXX - can we avoid doing every compile? +MAKE_SURE_sdl_DIR = @DIR=sdl; $(MAKE_SURE_DIR) + +$(BUILD_DIR)/sdl/%.o: $(SRC_DIR)/%.c + $(MAKE_SURE_sdl_DIR) + $(CC) $(CFLAGS) $(SDL_CFLAGS) -o $@ -c $< + +$(BUILD_DIR)/sdl/%.o: $(SRC_DIR)/%.s + $(MAKE_SURE_sdl_DIR) + $(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $< + +$(BUILD_DIR)/sdl/%.o: $(COMMON_DIR)/%.c + $(MAKE_SURE_sdl_DIR) + $(CC) $(CFLAGS) $(SDL_CFLAGS) -o $@ -c $< + +$(BUILD_DIR)/sdl/%.o: $(COMMON_DIR)/%.s + $(MAKE_SURE_sdl_DIR) + $(CC) $(CFLAGS) -DELF -x assembler-with-cpp -o $@ -c $< + +$(SDLQUAKE): $(BUILD_DIR)/../$(SDLQUAKE) + +$(BUILD_DIR)/../$(SDLQUAKE): $(OBJSquake-sdl) + $(CC) $(CFLAGS) $(OBJSquake-sdl) $(SDL_LDFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/../$(SDLQUAKE) +# XXX - Can this be automated? +clean-$(SDLQUAKE): + rm -f $(OBJSquake-sdl) +endif + ########################################################################### # # cleaning (clean, distclean)