diff --git a/build_tools/autorevision/makefile.raw b/build_tools/autorevision/makefile.raw index 2c79ef446..abac5692a 100644 --- a/build_tools/autorevision/makefile.raw +++ b/build_tools/autorevision/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk # Hacks to build for compiling system, not for target CC:=g++ diff --git a/build_tools/makefile.raw b/build_tools/makefile.raw index d535a0aa6..dd69e7866 100644 --- a/build_tools/makefile.raw +++ b/build_tools/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SUBDIRS=autorevision diff --git a/data/makefile.raw b/data/makefile.raw index acf833eb6..723e70d7f 100644 --- a/data/makefile.raw +++ b/data/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SUBDIRS=mods diff --git a/data/mods/global/makefile.raw b/data/mods/global/makefile.raw index 055908f14..98df00b0a 100644 --- a/data/mods/global/makefile.raw +++ b/data/mods/global/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk AIVOLUTIONLIST=multiplay commands.txt GRIMLIST=components structs texpages wrf COPYING diff --git a/data/mods/makefile.raw b/data/mods/makefile.raw index 7b7280b4a..5f9a23da0 100644 --- a/data/mods/makefile.raw +++ b/data/mods/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SUBDIRS=global diff --git a/lib/exceptionhandler/makefile.raw b/lib/exceptionhandler/makefile.raw index 54448ceca..6c06b613a 100644 --- a/lib/exceptionhandler/makefile.raw +++ b/lib/exceptionhandler/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SRC=dumpinfo.cpp \ exceptionhandler.c \ diff --git a/lib/framework/makefile.raw b/lib/framework/makefile.raw index ad8575f96..ff7ff48bf 100644 --- a/lib/framework/makefile.raw +++ b/lib/framework/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SRC=configfile.c \ cursors.c \ diff --git a/lib/gamelib/makefile.raw b/lib/gamelib/makefile.raw index c46f7796b..6a280857d 100644 --- a/lib/gamelib/makefile.raw +++ b/lib/gamelib/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SRC=anim.c \ animobj.c \ diff --git a/lib/ivis_common/makefile.raw b/lib/ivis_common/makefile.raw index 6e58f37e0..e68482707 100644 --- a/lib/ivis_common/makefile.raw +++ b/lib/ivis_common/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SRC=bitimage.c \ imd.c \ diff --git a/lib/ivis_opengl/makefile.raw b/lib/ivis_opengl/makefile.raw index 0bc10d223..9bc623373 100644 --- a/lib/ivis_opengl/makefile.raw +++ b/lib/ivis_opengl/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SRC=GLee.c \ ivi.c \ diff --git a/lib/makefile.raw b/lib/makefile.raw index 7edb7fe38..4feec7746 100644 --- a/lib/makefile.raw +++ b/lib/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SUBDIRS=framework \ exceptionhandler \ diff --git a/lib/netplay/makefile.raw b/lib/netplay/makefile.raw index e44fbf9c9..3f9688cef 100644 --- a/lib/netplay/makefile.raw +++ b/lib/netplay/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SRC=netjoin_stub.c \ netlog.c \ diff --git a/lib/script/makefile.raw b/lib/script/makefile.raw index dc909f0b2..a443f6b19 100644 --- a/lib/script/makefile.raw +++ b/lib/script/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SRC=codeprint.c \ event.c \ diff --git a/lib/sequence/makefile.raw b/lib/sequence/makefile.raw index 698924c49..783e50822 100644 --- a/lib/sequence/makefile.raw +++ b/lib/sequence/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SRC=sequence.c diff --git a/lib/sound/makefile.raw b/lib/sound/makefile.raw index 14453174d..a5bdba100 100644 --- a/lib/sound/makefile.raw +++ b/lib/sound/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SRC=audio.c \ audio_id.c \ diff --git a/lib/sqlite3/makefile.raw b/lib/sqlite3/makefile.raw index 89691ec40..c8ab3744f 100644 --- a/lib/sqlite3/makefile.raw +++ b/lib/sqlite3/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SRC=physfs_vfs.c sqlite3.c diff --git a/lib/widget/makefile.raw b/lib/widget/makefile.raw index 931febf69..6ea515b2d 100644 --- a/lib/widget/makefile.raw +++ b/lib/widget/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SRC=bar.c \ button.c \ diff --git a/makefile.raw b/makefile.raw index 16b7a1d4d..8dde2af2a 100644 --- a/makefile.raw +++ b/makefile.raw @@ -3,7 +3,7 @@ SUBDIRS=build_tools po win32 lib src data pkg top_srcdir=. top_builddir=. -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk include $(top_srcdir)/makerules/submake.mk src: build_tools win32 lib diff --git a/makerules/common.mk b/makerules/common.mk index 76c55fe09..867d2788c 100644 --- a/makerules/common.mk +++ b/makerules/common.mk @@ -1,11 +1,17 @@ +ifeq ($(MAKELEVEL),0) +include $(top_srcdir)/makerules/configure.mk +endif + +RM_CPPFLAGS:=-I$(top_srcdir) + %.o: %.rc - $(WINDRES) $(CPPFLAGS) -o $(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<) + $(WINDRES) $(RM_CPPFLAGS) $(CPPFLAGS) -o $(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<) %.o: %.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<) + $(CC) $(RM_CPPFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<) %.o: %.cpp - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<) + $(CXX) $(RM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c -o $(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<) %.lex.h %.lex.c: %.l $(FLEX) $(FLEXFLAGS) -o $(subst /,$(DIRSEP),$@) $(subst /,$(DIRSEP),$<) diff --git a/makerules/config.mk.tmpl b/makerules/config.mk.tmpl index 75536c792..c0295b399 100644 --- a/makerules/config.mk.tmpl +++ b/makerules/config.mk.tmpl @@ -5,10 +5,13 @@ PACKAGE_VERSION:=TRUNK PACKAGE_BUGREPORT:=http://wz2100.net/ INSTALLER_VERSION:=9.9.9.9 -# Platform you are running -#PLATFORM:=windows -#PLATFORM:=linux -#PLATFORM:=mingw32 +# Platform used to build Warzone 2100 +#BUILD:=windows +#BUILD:=linux + +# Platform Warzone 2100 shall run on +#TARGET:=windows +#TARGET:=linux # Compilation mode #MODE:=debug @@ -17,24 +20,12 @@ INSTALLER_VERSION:=9.9.9.9 # Directory where you store your dev stuff (lib and include) #DEVDIR:=C:/devpkg -# Remind the user to install Flex and Bison -#BISON:=bison -#FLEX:=flex - -## This is only needed for people planning to distribute this package and/or -## create installers from it. -# Path to makensis -#MAKENSIS:="wine C:/Program\ Files/NSIS/makensis.exe" -#MAKENSIS:=makensis - # Whether to build data package and installer #DATA:=yes #INSTALLER:=yes -#USE_GETTEXT:=yes +#TRANSLATION:=yes -# Gettext stuff -#PACKAGE:=warzone2100 -#LOCALEDIR:="" -#XGETTEXT:="xgettext" -#MSGMERGE:="msgmerge" -#MSGFMT:="msgfmt" +# Make config known throughout the whole buildsystem +export PACKAGE PACKAGE_NAME PACKAGE_VERSION PACKAGE_BUGREPORT +export BUILD TARGET MODE DEVDIR +export DATA INSTALLER TRANSLATION diff --git a/makerules/configure.mk b/makerules/configure.mk index c62401a2d..13f467a48 100644 --- a/makerules/configure.mk +++ b/makerules/configure.mk @@ -3,8 +3,6 @@ include $(top_builddir)/config.mk # Check for unset config -ifeq ($(MAKELEVEL),0) - $(info Checking config...) ifeq ($(strip $(PACKAGE)),) @@ -31,10 +29,16 @@ else $(info PACKAGE_BUGREPORT := $(PACKAGE_BUGREPORT)) endif -ifeq ($(strip $(PLATFORM)),) -$(error You must set PLATFORM in $(top_srcdir)/makerules/config.mk) +ifeq ($(strip $(BUILD)),) +$(error You must set BUILD in $(top_srcdir)/makerules/config.mk) else -$(info PLATFORM := $(PLATFORM)) +$(info BUILD := $(BUILD)) +endif + +ifeq ($(strip $(TARGET)),) +$(error You must set TARGET in $(top_srcdir)/makerules/config.mk) +else +$(info TARGET := $(TARGET)) endif ifeq ($(strip $(MODE)),) @@ -49,119 +53,107 @@ else $(info DEVDIR := $(DEVDIR)) endif -ifeq ($(strip $(BISON)),) -$(error You must set BISON in $(top_srcdir)/makerules/config.mk) -else -$(info BISON := $(BISON)) -endif - -ifeq ($(strip $(FLEX)),) -$(error You must set FLEX in $(top_srcdir)/makerules/config.mk) -else -$(info FLEX := $(FLEX)) -endif - -ifneq ($(strip $(INSTALLER)),) -ifeq ($(strip $(MAKENSIS)),) -$(error You must set MAKENSIS in $(top_srcdir)/makerules/config.mk) -else -$(info MAKENSIS is := $(MAKENSIS)) -endif -endif - $(info Config seems valid.) -endif - # Setup paths and static values -CPPFLAGS+=-DPACKAGE=\"$(PACKAGE)\" -DPACKAGE_VERSION=\"$(PACKAGE_VERSION)\" -DYY_STATIC -I$(top_srcdir) -I$(DEVDIR)/include/SDL -I$(DEVDIR)/include/libpng12 -I$(DEVDIR)/include/bfd -I$(DEVDIR)/include -CFLAGS+=-std=gnu99 -CXXFLAGS+= -LDFLAGS+=-L$(DEVDIR)/lib +WZ_CPPFLAGS:=-DPACKAGE=\"$(PACKAGE)\" -DPACKAGE_VERSION=\"$(PACKAGE_VERSION)\" -DYY_STATIC -I$(DEVDIR)/include/SDL -I$(DEVDIR)/include/libpng12 -I$(DEVDIR)/include/bfd -I$(DEVDIR)/include +WZ_CFLAGS:=-std=gnu99 +WZ_CXXFLAGS:= +WZ_LDFLAGS:=-L$(DEVDIR)/lib + # Setup build environment with config values ifeq ($(strip $(MODE)),debug) -CPPFLAGS+=-DDEBUG -CFLAGS+=-g -O0 -Wall -Werror-implicit-function-declaration -CXXFLAGS+=-g -O0 -Wall -Werror-implicit-function-declaration +WZ_CPPFLAGS+=-DDEBUG +WZ_CFLAGS+=-g -O0 -Wall -Werror-implicit-function-declaration +WZ_CXXFLAGS+=-g -O0 -Wall -Werror-implicit-function-declaration else -CPPFLAGS+=-DNDEBUG +WZ_CPPFLAGS+=-DNDEBUG endif -ifneq ($(strip $(USE_GETTEXT)),) -CPPFLAGS+=-DENABLE_NLS=1 -ifneq ($(LOCALEDIR),) -CPPFLAGS+=-DLOCALEDIR=$(LOCALEDIR) -endif +ifneq ($(strip $(TRANSLATION)),) +WZ_CPPFLAGS+=-DENABLE_NLS=1 endif -ifeq ($(strip $(PLATFORM)),windows) +ifeq ($(strip $(BUILD)),windows) DIRSEP:=\\ MV:=move RM_F:=del /F RMDIR:=rmdir MKDIR_P:=mkdir -EXEEXT:=.exe -AR:=ar -CC:=gcc -CXX:=g++ -WINDRES:=windres -CPPFLAGS+=-DWIN32 -CFLAGS+=-mwindows -CXXFLAGS+=-mwindows -LDFLAGS+=-lmingw32 -lSDLmain +XGETTEXT:=xgettext +MSGMERGE:=msgmerge +MSGFMT:=msgfmt +FLEX:=flex +BISON:=bison +MAKENSIS:=makensis else -ifeq ($(strip $(PLATFORM)),mingw32) DIRSEP:=/ MV:=mv RM_F:=rm -f RMDIR:=rmdir MKDIR_P:=mkdir -p +XGETTEXT:=xgettext +MSGMERGE:=msgmerge +MSGFMT:=msgfmt +FLEX:=flex +BISON:=bison +MAKENSIS:=makensis +endif + +ifeq ($(strip $(TARGET)),windows) EXEEXT:=.exe AR:=mingw32-ar CC:=mingw32-gcc CXX:=mingw32-g++ WINDRES:=mingw32-windres -CPPFLAGS+=-DWIN32 -CFLAGS+=-mwindows -CXXFLAGS+=-mwindows -LDFLAGS+=-lmingw32 -lSDLmain +WZ_CPPFLAGS+=-DWIN32 +WZ_CFLAGS+=-mwindows +WZ_CXXFLAGS+=-mwindows +WZ_LDFLAGS+=-lmingw32 -lSDLmain else -DIRSEP:=/ -MV:=mv -RM_F:=rm -f -RMDIR:=rmdir -MKDIR_P:=mkdir -p EXEEXT:= AR:=ar CC:=gcc CXX:=g++ WINDRES:= endif -endif + # Generic libs -LDFLAGS+=-lSDL -lSDL_net -lpng12 -lphysfs -lz -lvorbisfile -lvorbis -logg -lpopt -lintl +WZ_LDFLAGS+=-lSDL -lSDL_net -lpng12 -lphysfs -lz -lvorbisfile -lvorbis -logg -lpopt -lintl -# Additional platform-dependend libs -ifeq ($(strip $(PLATFORM)),windows) -LDFLAGS+=-lGLC -lglu32 -lopengl32 -lopenal32 -ldbghelp -lshfolder -lwinmm -lwsock32 -lbfd -liberty +# Additional target-platform-dependend libs + +ifeq ($(strip $(TARGET)),windows) +WZ_LDFLAGS+=-lGLC -lglu32 -lopengl32 -lopenal32 -ldbghelp -lshfolder -lwinmm -lwsock32 -lbfd -liberty else -ifeq ($(strip $(PLATFORM)),mingw32) -LDFLAGS+=-lGLC -lglu32 -lopengl32 -lopenal32 -ldbghelp -lshfolder -lwinmm -lwsock32 -lbfd -liberty -else -LDFLAGS+=-lGLC -lGLU -lGL -lopenal -endif +WZ_LDFLAGS+=-lGLC -lGLU -lGL -lopenal endif + # Additionaly link against the deps of our deps -LDFLAGS+=-liconv -lz -lfreetype -lfontconfig -lexpat +WZ_LDFLAGS+=-liconv -lz -lfreetype -lfontconfig -lexpat -include $(top_srcdir)/makerules/common.mk +# Import environment variables + +CPPFLAGS:=$(WZ_CPPFLAGS) $(CPPFLAGS) +CFLAGS:=$(WZ_CFLAGS) $(CFLAGS) +CXXFLAGS:=$(WZ_CXXFLAGS) $(CXXFLAGS) +LDFLAGS:=$(WZ_LDFLAGS) $(LDFLAGS) + + +# Export to environment + +export DIRSEP MV RM_F RMDIR MKDIR_P +export XGETTEXT MSGMERGE MSGFMT +export FLEX BISON MAKENSIS +export EXEEXT AR CC CXX WINDRES +export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS diff --git a/pkg/makefile.raw b/pkg/makefile.raw index 72c16787b..62b36d0e1 100644 --- a/pkg/makefile.raw +++ b/pkg/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SUBDIRS=nsis diff --git a/pkg/nsis/makefile.raw b/pkg/nsis/makefile.raw index 0a0985f8f..d650d5f17 100644 --- a/pkg/nsis/makefile.raw +++ b/pkg/nsis/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SETUPFILE=$(PACKAGE)-$(PACKAGE_VERSION).exe diff --git a/po/makefile.raw b/po/makefile.raw index 26db1e9f1..4dbf036f4 100644 --- a/po/makefile.raw +++ b/po/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk include Makevars @@ -17,7 +17,7 @@ mo-files: $(MO_FILES) update-po: clean all $(DOMAIN).pot: POTFILES.in - $(XGETTEXT) $(XGETTEXT_OPTIONS) --default-domain=$(DOMAIN) --copyright-holder=$(COPYRIGHT_HOLDER) --msgid-bugs-address=$(MSGID_BUGS_ADDRESS) --directory=$(top_builddir) --add-comments=TRANSLATORS: --files-from=$< + $(XGETTEXT) $(XGETTEXT_OPTIONS) --default-domain="$(DOMAIN)" --copyright-holder="$(COPYRIGHT_HOLDER)" --msgid-bugs-address="$(MSGID_BUGS_ADDRESS)" --directory="$(top_builddir)" --add-comments=TRANSLATORS: --files-from=$< mv $(DOMAIN).po $@ %.po: $(DOMAIN).pot diff --git a/src/makefile.raw b/src/makefile.raw index 9a80b5d79..29c0b1530 100644 --- a/src/makefile.raw +++ b/src/makefile.raw @@ -1,4 +1,4 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk SRC=ai.c \ aiexperience.c \ @@ -118,7 +118,7 @@ LIBS=$(top_builddir)/lib/libgamelib.a \ $(top_builddir)/lib/libexceptionhandler.a \ $(top_builddir)/lib/libsqlite3.a -ifeq ($(strip $(PLATFORM)),windows) +ifeq ($(strip $(TARGET)),windows) LIBS += $(top_builddir)/win32/warzone2100.o endif diff --git a/tools/lobbyserver_cpp/src/makefile.raw b/tools/lobbyserver_cpp/src/makefile.raw index cab1aa621..58a6d3dad 100644 --- a/tools/lobbyserver_cpp/src/makefile.raw +++ b/tools/lobbyserver_cpp/src/makefile.raw @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk OBJS=main.o lobby/read_write_mutex.o networking/tcp_server.o lobby/lobby.o lobby/game.o lobby/raii_counter.o lobby/lobby_iterator.o lobby/lobby_gamelock.o requesthandler.o networking/nattester.o diff --git a/win32/makefile.raw b/win32/makefile.raw index db0d50d6e..5528d37b8 100644 --- a/win32/makefile.raw +++ b/win32/makefile.raw @@ -1,6 +1,6 @@ -include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/common.mk -ifeq ($(strip $(PLATFORM)),windows) +ifeq ($(strip $(TARGET)),windows) all: warzone2100.o endif