ref: dd8db653e08cc3029a84dbfd36b2c927a8d3e8fc
parent: f0ad54afe62f6e2ae8e194bf81f9efc356b9ccd7
parent: d793e0ac6e0ed29e1df56f1e96e0150bd3751da4
author: Fabien <fabien.sanglard@gmail.com>
date: Tue Sep 1 19:19:02 EDT 2015
Merge pull request #32 from darealshinji/automake-2 Use GNU automake build system
--- a/.gitignore
+++ b/.gitignore
@@ -18,5 +18,21 @@
# Linux
*.o
*.a
+*~
chocolate-duke3d
+duke3d.cfg
duke3d.grp
+
+# GNU automake
+.deps
+/aclocal.m4
+/autom4te.cache
+/build-aux
+Makefile
+Makefile.in
+/config.h
+/config.h.in
+/config.log
+/config.status
+/configure
+/stamp-h1
--- a/Engine/src/Makefile
+++ /dev/null
@@ -1,10 +1,0 @@
-SOURCES=cache.c display.c draw.c dummy_multi.c engine.c filesystem.c fixedPoint_math.c mmulti.c network.c tiles.c
-OBJECTS=cache.o display.o draw.o dummy_multi.o engine.o filesystem.o fixedPoint_math.o mmulti.o network.o tiles.o
-
-../../libEngine.a: $(SOURCES)
- gcc -DPLATFORM_UNIX -DBYTE_ORDER=LITTLE_ENDIAN -D_XOPEN_SOURCE=500 -I /usr/include/SDL -I enet/include -c $(SOURCES)
- ar cru ../../libEngine.a $(OBJECTS)
- ranlib ../../libEngine.a
-
-clean:
- rm $(OBJECTS) ../../libEngine.a
--- /dev/null
+++ b/Engine/src/Makefile.am
@@ -1,0 +1,3 @@
+noinst_LIBRARIES = libEngine.a
+libEngine_a_SOURCES = cache.c display.c draw.c dummy_multi.c engine.c filesystem.c fixedPoint_math.c mmulti.c network.c tiles.c
+libEngine_a_CFLAGS = -I$(top_srcdir)/Game/src
--- a/Engine/src/mmulti.c
+++ b/Engine/src/mmulti.c
@@ -15,10 +15,10 @@
#include "mmulti_unstable.h"
-#if defined(__APPLE__)
- #include "enet/include/enet.h"
+#if (HAVE_ENET_ENET_H == 1)
+ #include <enet/enet.h>
#else
- #include <enet.h>
+ #include "enet/include/enet.h"
#endif
//STL
--- a/Game/Game.vcxproj
+++ b/Game/Game.vcxproj
@@ -184,7 +184,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <ResourceCompile Include="chocolateDukeRessources.rc" />
+ <ResourceCompile Include="chocolateDukeResources.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
--- a/Game/Game.vcxproj.filters
+++ b/Game/Game.vcxproj.filters
@@ -186,6 +186,6 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
- <ResourceCompile Include="chocolateDukeRessources.rc" />
+ <ResourceCompile Include="chocolateDukeResources.rc" />
</ItemGroup>
</Project>
\ No newline at end of file
--- /dev/null
+++ b/Game/Makefile.am
@@ -1,0 +1,4 @@
+if WITH_WIN_ICON
+chocolateDukeResources.o: chocolateDukeResources.rc
+ @WINDRES@ $^ -o $@
+endif
--- /dev/null
+++ b/Game/chocolateDukeResources.rc
@@ -1,0 +1,12 @@
+#include <windows.h>
+#include <commctrl.h>
+#include <richedit.h>
+
+
+
+
+
+//
+// Icon resources
+//
+IDI_ICON1 ICON ".\\duke_icon.ico"
--- a/Game/chocolateDukeRessources.rc
+++ /dev/null
@@ -1,12 +1,0 @@
-#include <windows.h>
-#include <commctrl.h>
-#include <richedit.h>
-
-
-
-
-
-//
-// Icon resources
-//
-IDI_ICON1 ICON ".\\duke_icon.ico"
--- a/Game/src/Makefile
+++ /dev/null
@@ -1,17 +1,0 @@
-SOURCES=actors.c animlib.c config.c console.c control.c cvar_defs.c cvars.c dummy_audiolib.c game.c gamedef.c global.c keyboard.c menues.c player.c premap.c rts.c scriplib.c sector.c sounds.c
-OBJECTS=actors.o animlib.o config.o console.o control.o cvar_defs.o cvars.o dummy_audiolib.o game.o gamedef.o global.o keyboard.o menues.o player.o premap.o rts.o scriplib.o sector.o sounds.o
-
-../../libGame.a: audiolib.a libmidi.a $(SOURCES)
- gcc -DPLATFORM_UNIX -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -I /usr/include/SDL/ -I ../../Engine/src/ -c $(SOURCES)
- ar cru ../../libGame.a $(OBJECTS) audiolib/*.o midi/*.o
- ranlib ../../libGame.a
-
-audiolib.a:
- cd audiolib && make
-libmidi.a:
- cd midi && make
-
-clean:
- rm $(OBJECTS) ../../libGame.a
- cd midi && make clean
- cd audiolib && make clean
--- /dev/null
+++ b/Game/src/Makefile.am
@@ -1,0 +1,14 @@
+SUBDIRS = audiolib midi
+
+noinst_LIBRARIES = libGame.a
+
+libGame_a_SOURCES = \
+ actors.c animlib.c config.c console.c control.c cvar_defs.c cvars.c dummy_audiolib.c game.c \
+ gamedef.c global.c keyboard.c menues.c player.c rts.c scriplib.c sector.c sounds.c
+libGame_a_LIBADD = premap.o
+libGame_a_CFLAGS = -I$(top_srcdir)/Engine/src
+
+# Starting a new game will lead to a crash if premap.o was built with -O1/-O2/-O3,
+# that's why we're compiling it seperately with -O0
+premap.o: premap.c
+ $(AM_V_CC)$(CC) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -I$(top_srcdir)/Engine/src -O0 -c $^ -o $@
--- a/Game/src/audiolib/Makefile
+++ /dev/null
@@ -1,22 +1,0 @@
-CC=gcc
-AR=ar
-RANLIB=ranlib
-CFLAGS=-g -O2
-LDLIBS=
-
-CFLAGS += $(shell sdl-config --cflags) -DPLATFORM_UNIX -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -DBYTE_ORDER=LITTLE_ENDIAN -I /usr/include/SDL -I ../../../Engine/src/
-LDLIBS += $(shell sdl-config --libs)
-
-OBJ=fx_man.o dsl.o ll_man.o multivoc.o mv_mix.o mvreverb.o nodpmi.o \
- pitch.o user.o usrhooks.o
-
-../audiolib.a: $(OBJ)
- rm -rf $@
- $(AR) rc $@ $^
- $(RANLIB) $@
-
-clean:
- rm -rf ../audiolib.a *.o
-
-distclean: clean
- rm -rf *~
--- /dev/null
+++ b/Game/src/audiolib/Makefile.am
@@ -1,0 +1,4 @@
+noinst_LIBRARIES = libaudio.a
+libaudio_a_SOURCES = fx_man.c dsl.c ll_man.c multivoc.c mv_mix.c mvreverb.c nodpmi.c pitch.c user.c usrhooks.c
+
+AM_CFLAGS = -I$(top_srcdir)/Engine/src
--- a/Game/src/audiolib/assert.h
+++ b/Game/src/audiolib/assert.h
@@ -17,6 +17,8 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#if (HAVE_ASSERT_H != 1)
+
#ifndef __ASSERT_H
#define __ASSERT_H
@@ -43,3 +45,5 @@
#error Multiple definition of ASSERT()
#endif
+
+#endif //HAVE_ASSERT_H
--- a/Game/src/midi/Makefile
+++ /dev/null
@@ -1,10 +1,0 @@
-SOURCES=sdl_midi.c
-OBJECTS=sdl_midi.o
-
-../libmidi.a: $(SOURCES)
- gcc -DPLATFORM_UNIX -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -DBYTE_ORDER=LITTLE_ENDIAN -I /usr/include/SDL/ -I ../../../Engine/src/ -c $(SOURCES)
- ar cru ../libmidi.a $(OBJECTS)
- ranlib ../libmidi.a
-
-clean:
- rm ../libmidi.a $(OBJECTS)
--- /dev/null
+++ b/Game/src/midi/Makefile.am
@@ -1,0 +1,3 @@
+noinst_LIBRARIES = libmidi.a
+libmidi_a_SOURCES = sdl_midi.c
+libmidi_a_CFLAGS = -I$(top_srcdir)/Engine/src
--- a/Makefile
+++ /dev/null
@@ -1,9 +1,0 @@
-all:
- cd Engine/src && make
- cd Game/src && make
- gcc libGame.a libEngine.a `pkg-config --cflags --libs sdl SDL_mixer` -o chocolate-duke3d
-
-clean:
- cd Game/src && make clean
- cd Engine/src && make clean
- rm chocolate-duke3d
--- /dev/null
+++ b/Makefile.am
@@ -1,0 +1,18 @@
+SUBDIRS = Game/src Engine/src Game
+
+bin_PROGRAMS = chocolate-duke3d
+chocolate_duke3d_SOURCES =
+chocolate_duke3d_LDADD = \
+ Game/src/libGame.a \
+ Game/src/audiolib/libaudio.a \
+ Game/src/midi/libmidi.a \
+ Engine/src/libEngine.a \
+ $(SDL_LIBS) $(SDL_MIXER_LIBS)
+if WITH_WIN_ICON
+chocolate_duke3d_LDADD += Game/chocolateDukeResources.o
+endif
+
+doc_DATA = README.md
+
+pixmapdir = $(datadir)/pixmaps
+pixmap_DATA = Game/duke_icon.png
--- /dev/null
+++ b/autogen.sh
@@ -1,0 +1,4 @@
+#!/bin/sh
+rm -rf autom4te.cache build-aux aclocal.m4
+autoreconf -ivf
+rm -rf autom4te.cache
--- /dev/null
+++ b/configure.ac
@@ -1,0 +1,46 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_INIT([Chocolate Duke3D],
+ [1.0],
+ [https://github.com/fabiensanglard/chocolate_duke3D/issues])
+AC_CONFIG_SRCDIR([.])
+
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE([foreign])
+AM_SILENT_RULES([yes])
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_RANLIB
+case "$host" in
+ *cygwin*|*mingw*)
+ AC_CHECK_TOOL([WINDRES], [windres], [])
+ ;;
+esac
+AM_CONDITIONAL([WITH_WIN_ICON], [test "$WINDRES" != ""])
+
+# Checks for libraries.
+PKG_CHECK_MODULES([SDL], [sdl], [], [
+ AC_CHECK_LIB([SDL], [main], [], [exit 1])
+])
+PKG_CHECK_MODULES([SDL_MIXER], [SDL_mixer], [], [
+ AC_CHECK_LIB([SDL_mixer], [main], [], [exit 1])
+])
+
+dnl Compiler flags
+CFLAGS_WARNINGS="-Wall -Wno-pointer-sign -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast \
+-Wno-parentheses -Wno-maybe-uninitialized -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-result"
+CFLAGS="${CFLAGS_WARNINGS} -fno-strict-aliasing -fno-aggressive-loop-optimizations -DPLATFORM_UNIX $(pkg-config --cflags SDL_mixer) ${CFLAGS}"
+LDFLAGS="$(pkg-config --libs sdl) $(pkg-config --libs SDL_mixer) ${LDFLAGS}"
+
+# Checks for header files.
+AC_CHECK_HEADERS([assert.h enet/enet.h])
+
+AC_CONFIG_FILES([Engine/src/Makefile
+ Game/src/Makefile
+ Game/src/audiolib/Makefile
+ Game/src/midi/Makefile
+ Game/Makefile
+ Makefile])
+AC_OUTPUT