diff --git a/Makefile.raw b/Makefile.raw index 8fcaefdb6..b266c5be5 100644 --- a/Makefile.raw +++ b/Makefile.raw @@ -1,10 +1,18 @@ SUBDIRS=build_tools po win32 lib src data pkg -all clean: $(SUBDIRS) +# Figure out top source dir: The Makefile.raw will be in it, and it is relative to this directory +build_path:=$(patsubst %/Makefile.raw,%,$(lastword $(MAKEFILE_LIST))) +ifneq ($(strip $(build_path)),Makefile.raw) +export top_srcdir:=$(CURDIR)/$(build_path) +else +export top_srcdir:=$(CURDIR) +endif -.PHONY: $(SUBDIRS) -$(SUBDIRS): - $(MAKE) -f Makefile.raw -C $@ $(MAKECMDGOALS) +# Top build dir is this directory +export top_builddir:=$(CURDIR) -src: win32 lib build_tools -packaging: data src po +include $(top_srcdir)/makerules/configure.mk +include $(top_srcdir)/makerules/submake.mk + +src: build_tools win32 lib +pkg: data src po diff --git a/build_tools/Makefile.raw b/build_tools/Makefile.raw index 67a80c732..d535a0aa6 100644 --- a/build_tools/Makefile.raw +++ b/build_tools/Makefile.raw @@ -1,8 +1,5 @@ +include $(top_srcdir)/makerules/configure.mk + SUBDIRS=autorevision -all clean: $(SUBDIRS) - -$(SUBDIRS): - $(MAKE) -f Makefile.raw -C $@ $(MAKECMDGOALS) - -.PHONY: all clean $(SUBDIRS) +include $(top_srcdir)/makerules/submake.mk diff --git a/build_tools/autorevision/Makefile.raw b/build_tools/autorevision/Makefile.raw index 7aeef88af..8c408bf6b 100644 --- a/build_tools/autorevision/Makefile.raw +++ b/build_tools/autorevision/Makefile.raw @@ -1,26 +1,29 @@ -MAKERULES=../../makerules -include $(MAKERULES)/configure.mk -include $(MAKERULES)/common.mk +include $(top_srcdir)/makerules/configure.mk + +# Hacks to build for compiling system, not for target +CC:=g++ +CXX:=g++ +CPPFLAGS:=$(subst -DWIN32,,$(CPPFLAGS)) +CFLAGS:=$(subst -mwindows,,$(CFLAGS)) +CXXFLAGS:=$(subst -mwindows,,$(CXXFLAGS)) +LDFLAGS:= +EXEEXT= SRC=autorevision.cpp EXE=autorevision -CXX=g++ -DEPS=$(patsubst %.c,%.o, $(SRC:%.cpp=%.o)) $(LIBS) +include $(top_srcdir)/makerules/exe.mk + +.PHONY: all all-local clean clean-local all: all-local -$(EXE)$(EXEEXT): $(DEPS) - $(CXX) -o $@ $< - all-local: $(EXE)$(EXEEXT) - $(EXE)$(EXEEXT) +cstr -v ../.. ../../src/autorevision.h + $(builddir)$(DIRSEP)$(EXE)$(EXEEXT) +cstr -v $(top_srcdir) $(top_builddir)/src/autorevision.h clean-local: - -$(RMF) ../../src/autorevision.h + -$(RM_F) $(top_builddir)/src/autorevision.h -clean: - $(RMF) $(DEPS) $(EXE)$(EXEEXT) - -.PHONY: all all-local clean +clean: clean-local + $(RM_F) $(DEPS) $(EXE)$(EXEEXT) diff --git a/data/Makefile.raw b/data/Makefile.raw index b0428c155..8e53e96e7 100644 --- a/data/Makefile.raw +++ b/data/Makefile.raw @@ -1,35 +1,41 @@ +include $(top_srcdir)/makerules/configure.mk + SUBDIRS=mods -MAKERULES=../makerules -include $(MAKERULES)/configure.mk - -BASELIST = anims audio components effects features tagdefinitions \ - gamedesc.lev images messages misc multiplay novideo.rpl \ - script sequenceaudio stats stats-sql structs texpages wrf -PATCHLIST = addon.lev anims components effects \ +BASELIST=anims audio components effects features tagdefinitions \ + gamedesc.lev images messages misc multiplay music novideo.rpl script \ + sequenceaudio stats stats-sql structs texpages wrf +PATCHLIST=addon.lev anims components effects \ messages multiplay stats structs wrf BASEARCHIVE=base.wz PATCHARCHIVE=mp.wz +CLEANFILES=$(BASEARCHIVE) $(PATCHARCHIVE) + +include $(top_srcdir)/makerules/submake.mk + +.PHONY: all clean $(BASEARCHIVE) $(PATCHARCHIVE) $(SUBDIRS) + all: ifdef DATA all: $(BASEARCHIVE) $(PATCHARCHIVE) $(SUBDIRS) endif -$(SUBDIRS): - $(MAKE) -f Makefile.raw -C $@ $(MAKECMDGOALS) +stamp: + touch stamp -$(BASEARCHIVE): $(BASELIST:%=base/%) - cd base && zip -ru0 $@ $(BASELIST) -x *svn* +$(BASEARCHIVE): $(srcdir)/$(basename $(BASEARCHIVE)) stamp $(patsubst %,$(srcdir)/$(basename $(BASEARCHIVE))/%,$(BASELIST)) + (cd $< && zip -ru0 $(builddir)/$@ $(filter-out stamp,$(filter-out $<,$(^:$