]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - Makefile
fix make -j
[xonotic/netradiant.git] / Makefile
index 09c7e9640060a76a313546df3f6f3de8668a5cb3..630968430d5ccded38aacacd477c1e4278dce1be 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 include Makefile.conf
 
 CFLAGS   = -MMD -W -Wall -Wcast-align -Wcast-qual -Wno-unused-parameter -fPIC
-CPPFLAGS = -DPOSIX -DXWINDOWS -D_LINUX
+CPPFLAGS = 
 CXXFLAGS = $(CFLAGS) -Wno-non-virtual-dtor -Wreorder -fno-exceptions -fno-rtti
 
 CFLAGS_OPT ?= -O3
@@ -13,10 +13,11 @@ else ifeq ($(BUILD),release)
        CFLAGS += $(CFLAGS_OPT)
        LDFLAGS += -s
 else
-       $(error Unsupported build type)
+$(error Unsupported build type)
 endif
 
 ifeq ($(OS),Linux)
+       CPPFLAGS += -DPOSIX -DXWINDOWS -D_LINUX
        LDFLAGS_DLL = -fPIC -ldl
        LIBS = -lpthread
        EXE = x86
@@ -33,12 +34,12 @@ ifeq ($(OS),Linux)
        LIBS_GTK = `pkg-config gtk+-2.0 --libs-only-l --libs-only-L`
        CPPFLAGS_GTKGLEXT = `pkg-config gtkglext-1.0 --cflags`
        LIBS_GTKGLEXT = `pkg-config gtkglext-1.0 --libs-only-l --libs-only-L`
-else ifeq($(OS),Win32)
-       $(error Unsupported build OS)
-else ifeq($(OS),Darwin)
-       $(error Unsupported build OS)
+else ifeq ($(OS),Win32)
+$(error Unsupported build OS)
+else ifeq ($(OS),Darwin)
+$(error Unsupported build OS)
 else
-       $(error Unsupported build OS)
+$(error Unsupported build OS)
 endif
 
 RADIANT_ABOUTMSG = Custom build
@@ -67,7 +68,6 @@ TEE_STDERR ?= | tee /dev/stderr
 
 .PHONY: all
 all: \
-       makeversion \
        install/heretic2/h2data.$(EXE) \
        install/modules/archivepak.$(DLL) \
        install/modules/archivewad.$(DLL) \
@@ -115,10 +115,10 @@ clean:
        $(CXX) -shared -o $@ $^ $(LDFLAGS) $(LDFLAGS_DLL) $(LIBS) $(LIBS_EXTRA)
        [ -z "$(LDD)" ] || [ -z "`$(LDD) -r $@ 2>&1 >/dev/null $(TEE_STDERR)`" ] || { $(RM) $@; exit 1; }
 
-%.o: %.cpp
+%.o: %.cpp makeversion
        $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) $(CPPFLAGS_EXTRA)
 
-%.o: %.c
+%.o: %.c makeversion
        $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) $(CPPFLAGS_EXTRA)
 
 install/q3map2.$(EXE): LIBS_EXTRA := $(LIBS_XML) $(LIBS_GLIB) $(LIBS_PNG)
@@ -687,21 +687,38 @@ makeversion:
        ver=`cat include/version.default`; \
        major=`echo $$ver | cut -d . -f 2`; \
        minor=`echo $$ver | cut -d . -f 3 | cut -d - -f 1`; \
-       echo "// generated header, see Makefile" > include/version.h; \
-       echo "#define RADIANT_VERSION \"$$ver\"" >> include/version.h; \
-       echo "#define RADIANT_MAJOR_VERSION \"$$major\"" >> include/version.h; \
-       echo "#define RADIANT_MINOR_VERSION \"$$minor\"" >> include/version.h; \
-       echo "$$major" > include/RADIANT_MAJOR; \
-       echo "$$minor" > include/RADIANT_MINOR; \
-       echo "$$ver" > include/version; \
-       echo "// generated header, see Makefile" > include/aboutmsg.h; \
-       echo "#define RADIANT_ABOUTMSG \"$(RADIANT_ABOUTMSG)\"" >> include/aboutmsg.h; \
+       echo "// generated header, see Makefile" > include/version.h.new; \
+       echo "#define RADIANT_VERSION \"$$ver\"" >> include/version.h.new; \
+       echo "#define RADIANT_MAJOR_VERSION \"$$major\"" >> include/version.h.new; \
+       echo "#define RADIANT_MINOR_VERSION \"$$minor\"" >> include/version.h.new; \
+       echo "$$major" > include/RADIANT_MAJOR.new; \
+       echo "$$minor" > include/RADIANT_MINOR.new; \
+       echo "$$ver" > include/version.new; \
+       echo "// generated header, see Makefile" > include/aboutmsg.h.new; \
+       echo "#define RADIANT_ABOUTMSG \"$(RADIANT_ABOUTMSG)\"" >> include/aboutmsg.h.new; \
+       mv_if_diff() \
+       { \
+               if diff $$1 $$2 >/dev/null 2>&1; then \
+                       rm -f $$1; \
+               else \
+                       mv $$1 $$2; \
+               fi; \
+       }; \
+       mv_if_diff include/version.h.new include/version.h; \
+       mv_if_diff include/RADIANT_MAJOR.new include/RADIANT_MAJOR; \
+       mv_if_diff include/RADIANT_MINOR.new include/RADIANT_MINOR; \
+       mv_if_diff include/version.new include/version; \
+       mv_if_diff include/aboutmsg.h.new include/aboutmsg.h
 
 .PHONY: install-data
-install-data:
+install-data: makeversion
        $(MKDIR) install/games
+       $(FIND) install/ -name .svn -exec $(RM_R) {} \; -prune; \
        set -ex; \
        for GAME in games/*; do \
+               if [ -d "$$GAME/tools" ]; then \
+                       GAME=$$GAME/tools; \
+               fi; \
                for GAMEFILE in $$GAME/games/*.game; do \
                        $(CP) "$$GAMEFILE" install/games/; \
                done; \