Callback: work at any arity
[xonotic/netradiant.git] / Makefile
index 376b619..0a2d4b9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,8 @@ CAT                ?= cat
 MKDIR              ?= mkdir -p
 CP                 ?= cp
 CP_R               ?= $(CP) -r
+LN                 ?= ln
+LN_SNF             ?= $(LN) -snf
 RM                 ?= rm
 RM_R               ?= $(RM) -r
 TEE_STDERR         ?= | tee /dev/stderr
@@ -44,12 +46,15 @@ TR                 ?= tr
 FIND               ?= find
 DIFF               ?= diff
 SED                ?= sed
-
-# optional:
-SVNVERSION         ?= svnversion
-
-STDOUT_TO_DEVNULL  ?= >/dev/null
-STDERR_TO_DEVNULL  ?= 2>/dev/null
+GIT                ?= git
+SVN                ?= svn
+WGET               ?= wget
+MV                 ?= mv
+UNZIPPER           ?= unzip
+
+FD_TO_DEVNULL      ?= >/dev/null
+STDOUT_TO_DEVNULL  ?= 1$(FD_TO_DEVNULL)
+STDERR_TO_DEVNULL  ?= 2$(FD_TO_DEVNULL)
 STDERR_TO_STDOUT   ?= 2>&1
 TO_DEVNULL         ?= $(STDOUT_TO_DEVNULL) $(STDERR_TO_STDOUT)
 
@@ -65,6 +70,9 @@ LIBS_PNG           ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) li
 CPPFLAGS_GTK       ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) gtk+-2.0 --cflags $(STDERR_TO_DEVNULL))
 LIBS_GTK           ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) gtk+-2.0 --libs-only-L $(STDERR_TO_DEVNULL)) \
                       $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) gtk+-2.0 --libs-only-l $(STDERR_TO_DEVNULL))
+CPPFLAGS_PANGOFT2  ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) pangoft2 --cflags $(STDERR_TO_DEVNULL))
+LIBS_PANGOFT2      ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) pangoft2 --libs-only-L $(STDERR_TO_DEVNULL)) \
+                      $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) pangoft2 --libs-only-l $(STDERR_TO_DEVNULL))
 CPPFLAGS_GTKGLEXT  ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) gtkglext-1.0 --cflags $(STDERR_TO_DEVNULL))
 LIBS_GTKGLEXT      ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) gtkglext-1.0 --libs-only-L $(STDERR_TO_DEVNULL)) \
                       $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) gtkglext-1.0 --libs-only-l $(STDERR_TO_DEVNULL))
@@ -73,14 +81,25 @@ LIBS_GL            ?= -lGL # -lopengl32 on Win32
 CPPFLAGS_DL        ?=
 LIBS_DL            ?= -ldl # nothing on Win32
 CPPFLAGS_ZLIB      ?=
-LIBS_ZLIB          ?= -lz
+LIBS_ZLIB          ?= -lz -lminizip
+CPPFLAGS_JPEG      ?=
+LIBS_JPEG          ?= -ljpeg
 DEPEND_ON_MAKEFILE ?= yes
+DOWNLOAD_GAMEPACKS ?= yes
+# set to no to disable gamepack, set to all to even download undistributable gamepacks
+
+# Support CHECK_DEPENDENCIES with DOWNLOAD_GAMEPACKS semantics
+ifneq ($(CHECK_DEPENDENCIES),)
+DEPENDENCIES_CHECK = $(patsubst yes,quiet,$(patsubst no,off,$(CHECK_DEPENDENCIES)))
+else
 DEPENDENCIES_CHECK ?= quiet
 # or: off, verbose
+endif
 
 # these are used on Win32 only
 GTKDIR             ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) gtk+-2.0 --variable=prefix $(STDERR_TO_DEVNULL))
 WHICHDLL           ?= which
+DLLINSTALL         ?= install-dlls.sh
 
 # alias mingw32 OSes
 ifeq ($(OS),MINGW32_NT-6.0)
@@ -94,7 +113,7 @@ CFLAGS_COMMON = -MMD -W -Wall -Wcast-align -Wcast-qual -Wno-unused-parameter -fn
 CPPFLAGS_COMMON =
 LDFLAGS_COMMON =
 LIBS_COMMON =
-CXXFLAGS_COMMON = -Wno-non-virtual-dtor -Wreorder -fno-exceptions -fno-rtti
+CXXFLAGS_COMMON = -std=c++11 -Wno-non-virtual-dtor -Wreorder -fno-exceptions -fno-rtti
 
 ifeq ($(BUILD),debug)
 ifeq ($(findstring $(CFLAGS),-g),)
@@ -136,26 +155,39 @@ ifeq ($(BUILD),release)
 ifeq ($(findstring $(CFLAGS),-O),)
        CFLAGS_COMMON += -O3
        # only add -O3 if no -O flag is in $(CFLAGS)
-       # to allow overriding the optimizations
 endif
        CPPFLAGS_COMMON +=
        LDFLAGS_COMMON += -s
 else
 
+ifeq ($(BUILD),native)
+ifeq ($(findstring $(CFLAGS),-O),)
+       CFLAGS_COMMON += -O3
+       # only add -O3 if no -O flag is in $(CFLAGS)
+endif
+       CFLAGS_COMMON += -march=native -mcpu=native
+       CPPFLAGS_COMMON +=
+       LDFLAGS_COMMON += -s
+else
+
 $(error Unsupported build type: $(BUILD))
 endif
 endif
 endif
 endif
+endif
 
 INSTALLDIR_BASE := $(INSTALLDIR)
 
+MAKE_EXE_SYMLINK = false
+
 ifeq ($(OS),Linux)
        CPPFLAGS_COMMON += -DPOSIX -DXWINDOWS
        CFLAGS_COMMON += -fPIC
        LDFLAGS_DLL = -fPIC -ldl
        LIBS_COMMON = -lpthread
-       EXE ?= x86
+       EXE ?= $(shell uname -m)
+       MAKE_EXE_SYMLINK = true
        A = a
        DLL = so
        MWINDOWS =
@@ -164,8 +196,8 @@ else
 ifeq ($(OS),Win32)
        CPPFLAGS_COMMON += -DWIN32 -D_WIN32 -D_inline=inline
        CFLAGS_COMMON += -mms-bitfields
-       LDFLAGS_DLL = --dll -Wl,--add-stdcall-alias
-       LIBS_COMMON = -lws2_32 -luser32 -lgdi32
+       LDFLAGS_DLL = -Wl,--add-stdcall-alias
+       LIBS_COMMON = -lws2_32 -luser32 -lgdi32 -lole32
        EXE ?= exe
        A = a
        DLL = dll
@@ -183,16 +215,15 @@ ifeq ($(OS),Darwin)
        CPPFLAGS_COMMON += -DPOSIX -DXWINDOWS
        CFLAGS_COMMON += -fPIC
        CXXFLAGS_COMMON += -fno-exceptions -fno-rtti
-       CPPFLAGS_COMMON += -I/sw/include -I/usr/X11R6/include
-       LDFLAGS_COMMON += -L/sw/lib  -L/usr/X11R6/lib
-       #LDFLAGS_COMMON += -L/sw/lib -L/usr/lib -L/usr/X11R6/lib
+       MACLIBDIR ?= /opt/local/lib
+       CPPFLAGS_COMMON += -I$(MACLIBDIR)/../include -I/usr/X11R6/include
+       LDFLAGS_COMMON += -L$(MACLIBDIR) -L/usr/X11R6/lib
        LDFLAGS_DLL += -dynamiclib -ldl
-       EXE ?= ppc
-       MACLIBDIR ?= /sw/lib
+       EXE ?= $(shell uname -m)
+       MAKE_EXE_SYMLINK = true
        A = a
        DLL = dylib
        MWINDOWS =
-
        # workaround for weird prints
        ECHO_NOLF = /bin/echo -n
 
@@ -202,8 +233,6 @@ ifeq ($(OS),Darwin)
        # workaround: we have no "ldd" for OS X, so...
        LDD =
        OTOOL = otool
-
-       INSTALLDIR := $(INSTALLDIR_BASE)/NetRadiant.app/Contents/MacOS/install
 else
 
 $(error Unsupported build OS: $(OS))
@@ -212,21 +241,24 @@ endif
 endif
 
 # VERSION!
-RADIANT_VERSION = 1.5.0n
-RADIANT_MAJOR_VERSION = 5
-RADIANT_MINOR_VERSION = 0
+RADIANT_MAJOR_VERSION = 1
+RADIANT_MINOR_VERSION = 5
+RADIANT_PATCH_VERSION = 0
+RADIANT_VERSION_NUMBER = $(RADIANT_MAJOR_VERSION).$(RADIANT_MINOR_VERSION).$(RADIANT_PATCH_VERSION)
+RADIANT_VERSION = $(RADIANT_VERSION_NUMBER)n
 Q3MAP_VERSION = 2.5.17n
 
 # Executable extension
 RADIANT_EXECUTABLE := $(EXE)
 
-SVN_VERSION := $(shell $(SVNVERSION) -n $(STDERR_TO_DEVNULL) | $(SED) 's/M$$//g; s/.*://g;')
-ifneq ($(SVN_VERSION),)
-       RADIANT_VERSION := $(RADIANT_VERSION)-svn$(SVN_VERSION)
-       Q3MAP_VERSION := $(Q3MAP_VERSION)-svn$(SVN_VERSION)
+GIT_VERSION := $(shell $(GIT) rev-parse --short HEAD $(STDERR_TO_DEVNULL))
+ifneq ($(GIT_VERSION),)
+       RADIANT_VERSION := $(RADIANT_VERSION)-git-$(GIT_VERSION)
+       Q3MAP_VERSION := $(Q3MAP_VERSION)-git-$(GIT_VERSION)
 endif
 
-CPPFLAGS += -DRADIANT_VERSION="\"$(RADIANT_VERSION)\"" -DRADIANT_MAJOR_VERSION="\"$(RADIANT_MAJOR_VERSION)\"" -DRADIANT_MINOR_VERSION="\"$(RADIANT_MINOR_VERSION)\"" -DRADIANT_ABOUTMSG="\"$(RADIANT_ABOUTMSG)\"" -DQ3MAP_VERSION="\"$(Q3MAP_VERSION)\"" -DRADIANT_EXECUTABLE="\"$(RADIANT_EXECUTABLE)\""
+CPPFLAGS += -DRADIANT_VERSION="\"$(RADIANT_VERSION)\"" -DRADIANT_MAJOR_VERSION="\"$(RADIANT_MAJOR_VERSION)\"" -DRADIANT_MINOR_VERSION="\"$(RADIANT_MINOR_VERSION)\"" -DRADIANT_PATCH_VERSION="\"$(RADIANT_PATCH_VERSION)\"" -DRADIANT_ABOUTMSG="\"$(RADIANT_ABOUTMSG)\"" -DQ3MAP_VERSION="\"$(Q3MAP_VERSION)\"" -DRADIANT_EXECUTABLE="\"$(RADIANT_EXECUTABLE)\""
+CPPFLAGS += -DGTK_TARGET=2
 
 .PHONY: all
 all: \
@@ -242,12 +274,12 @@ dependencies-check:
 else
 dependencies-check:
        @$(ECHO)
-       @if [ x"$(DEPENDENCIES_CHECK)" = x"verbose" ]; then set -x; fi; \
+       @if [ x"$(DEPENDENCIES_CHECK)" = x"verbose" ]; then set -x; exec 3>&2; else exec 3$(FD_TO_DEVNULL); fi; \
        failed=0; \
        checkbinary() \
        { \
                $(ECHO_NOLF) "Checking for $$2 ($$1)... "; \
-               $$2 --help $(TO_DEVNULL); \
+               $$2 --help >&3 $(STDERR_TO_STDOUT); \
                if [ $$? != 127 ]; then \
                        $(ECHO) "found."; \
                else \
@@ -267,6 +299,7 @@ dependencies-check:
        checkbinary coreutils "$(CP_R)"; \
        checkbinary coreutils "$(RM)"; \
        checkbinary coreutils "$(RM_R)"; \
+       checkbinary coreutils "$(MV)"; \
        checkbinary coreutils "$(ECHO) test $(TEE_STDERR)"; \
        checkbinary sed "$(SED)"; \
        checkbinary findutils "$(FIND)"; \
@@ -276,22 +309,35 @@ dependencies-check:
        checkbinary binutils "$(RANLIB)"; \
        checkbinary binutils "$(AR)"; \
        checkbinary pkg-config "$(PKGCONFIG)"; \
+       checkbinary unzip "$(UNZIPPER)"; \
+       checkbinary git-core "$(GIT)"; \
+       checkbinary subversion "$(SVN)"; \
+       checkbinary wget "$(WGET)"; \
        [ "$(OS)" = "Win32" ] && checkbinary mingw32 "$(WINDRES)"; \
        [ -n "$(LDD)" ] && checkbinary libc6 "$(LDD)"; \
        [ -n "$(OTOOL)" ] && checkbinary xcode "$(OTOOL)"; \
        [ "$$failed" = "0" ] && $(ECHO) All required tools have been found!
        @$(ECHO)
-       @if [ x"$(DEPENDENCIES_CHECK)" = x"verbose" ]; then set -x; fi; \
+       @if [ x"$(DEPENDENCIES_CHECK)" = x"verbose" ]; then set -x; exec 3>&2; else exec 3$(FD_TO_DEVNULL); fi; \
        failed=0; \
        checkheader() \
        { \
                $(ECHO_NOLF) "Checking for $$2 ($$1)... "; \
                if \
-                       $(CXX) conftest.cpp $(CFLAGS) $(CXXFLAGS) $(CFLAGS_COMMON) $(CXXFLAGS_COMMON) $(CPPFLAGS) $(CPPFLAGS_COMMON) $$4 -DCONFTEST_HEADER="<$$2>" -DCONFTEST_SYMBOL="$$3" $(TARGET_ARCH) $(LDFLAGS) -c -o conftest.o $(TO_DEVNULL) && \
-                       $(CXX) conftest.o $(LDFLAGS) $(LDFLAGS_COMMON) $$5 $(LIBS_COMMON) $(LIBS) -o conftest $(TO_DEVNULL); \
+                       $(CXX) conftest.cpp $(CFLAGS) $(CXXFLAGS) $(CFLAGS_COMMON) $(CXXFLAGS_COMMON) $(CPPFLAGS) $(CPPFLAGS_COMMON) $$4 -DCONFTEST_HEADER="<$$2>" -DCONFTEST_SYMBOL="$$3" $(TARGET_ARCH) $(LDFLAGS) -c -o conftest.o >&3 $(STDERR_TO_STDOUT); \
                then \
-                       $(RM) conftest conftest.o conftest.d; \
-                       $(ECHO) "found."; \
+                       if \
+                               $(CXX) conftest.o $(LDFLAGS) $(LDFLAGS_COMMON) $$5 $(LIBS_COMMON) $(LIBS) -o conftest >&3 $(STDERR_TO_STDOUT); \
+                       then \
+                               $(RM) conftest conftest.o conftest.d; \
+                               $(ECHO) "found and links."; \
+                       else \
+                               $(RM) conftest.o conftest.d; \
+                               $(ECHO) "found but does not link, please install it or set PKG_CONFIG_PATH right!"; \
+                               $(ECHO) "To see the failed commands, set DEPENDENCIES_CHECK=verbose"; \
+                               $(ECHO) "To proceed anyway, set DEPENDENCIES_CHECK=off"; \
+                               failed=1; \
+                       fi; \
                else \
                        $(RM) conftest conftest.o conftest.d; \
                        $(ECHO) "not found, please install it or set PKG_CONFIG_PATH right!"; \
@@ -301,11 +347,13 @@ dependencies-check:
                fi; \
        }; \
        $(ECHO) checking that the dependencies exist; \
-       checkheader libglib2.0-dev glib/gutils.h g_path_is_absolute "$(CPPFLAGS_GLIB)" "$(LIBS_GLIB)"; \
+       checkheader libjpeg8-dev jpeglib.h jpeg_set_defaults "$(CPPFLAGS_JPEG)" "$(LIBS_JPEG)"; \
+       checkheader libglib2.0-dev glib.h g_path_is_absolute "$(CPPFLAGS_GLIB)" "$(LIBS_GLIB)"; \
        checkheader libxml2-dev libxml/xpath.h xmlXPathInit "$(CPPFLAGS_XML)" "$(LIBS_XML)"; \
        checkheader libpng12-dev png.h png_create_read_struct "$(CPPFLAGS_PNG)" "$(LIBS_PNG)"; \
        checkheader "mesa-common-dev (or another OpenGL library)" GL/gl.h glClear "$(CPPFLAGS_GL)" "$(LIBS_GL)"; \
        checkheader libgtk2.0-dev gtk/gtkdialog.h gtk_dialog_run "$(CPPFLAGS_GTK)" "$(LIBS_GTK)"; \
+       checkheader libpango1.0-dev pango/pangoft2.h pango_ft2_font_map_new "$(CPPFLAGS_PANGOFT2)" "$(LIBS_PANGOFT2)"; \
        checkheader libgtkglext1-dev gtk/gtkglwidget.h gtk_widget_get_gl_context "$(CPPFLAGS_GTKGLEXT)" "$(LIBS_GTKGLEXT)"; \
        [ "$(OS)" != "Win32" ] && checkheader libc6-dev dlfcn.h dlopen "$(CPPFLAGS_DL)" "$(LIBS_DL)"; \
        checkheader zlib1g-dev zlib.h zlibVersion "$(CPPFLAGS_ZLIB)" "$(LIBS_ZLIB)"; \
@@ -315,7 +363,17 @@ endif
 
 .PHONY: binaries
 binaries: \
-       $(INSTALLDIR)/heretic2/h2data.$(EXE) \
+       binaries-tools \
+       binaries-radiant \
+
+.PHONY: binaries-radiant-all
+binaries-radiant: \
+       binaries-radiant-modules \
+       binaries-radiant-plugins \
+       binaries-radiant-core \
+
+.PHONY: binaries-radiant-modules
+binaries-radiant-modules: \
        $(INSTALLDIR)/modules/archivepak.$(DLL) \
        $(INSTALLDIR)/modules/archivewad.$(DLL) \
        $(INSTALLDIR)/modules/archivezip.$(DLL) \
@@ -330,17 +388,62 @@ binaries: \
        $(INSTALLDIR)/modules/model.$(DLL) \
        $(INSTALLDIR)/modules/shaders.$(DLL) \
        $(INSTALLDIR)/modules/vfspk3.$(DLL) \
+
+.PHONY: binaries-radiant-plugins
+binaries-radiant-plugins: \
        $(INSTALLDIR)/plugins/bobtoolz.$(DLL) \
        $(INSTALLDIR)/plugins/brushexport.$(DLL) \
        $(INSTALLDIR)/plugins/prtview.$(DLL) \
        $(INSTALLDIR)/plugins/shaderplug.$(DLL) \
        $(INSTALLDIR)/plugins/sunplug.$(DLL) \
        $(INSTALLDIR)/plugins/ufoaiplug.$(DLL) \
+
+.PHONY: binaries-radiant
+binaries-radiant-core: \
+       $(INSTALLDIR)/radiant.$(EXE) \
+       $(INSTALLDIR)/radiant \
+
+.PHONY: binaries-tools
+binaries-tools: \
+       binaries-tools-quake2 \
+       binaries-tools-quake3 \
+
+.PHONY: binaries-tools-quake2
+binaries-tools-quake2: \
+       binaries-q2map \
+       binaries-qdata3 \
+       binaries-h2data \
+
+.PHONY: binaries-q2map
+binaries-q2map: \
        $(INSTALLDIR)/q2map.$(EXE) \
+       $(INSTALLDIR)/q2map \
+
+.PHONY: binaries-qdata3
+binaries-qdata3: \
+       $(INSTALLDIR)/qdata3.$(EXE) \
+       $(INSTALLDIR)/qdata3 \
+
+.PHONY: binaries-h2data
+binaries-h2data: \
+       $(INSTALLDIR)/heretic2/h2data.$(EXE) \
+       $(INSTALLDIR)/heretic2/h2data \
+
+.PHONY: binaries-tools-quake3
+binaries-tools-quake3: \
+       binaries-q3data \
+       binaries-q3map2 \
+
+.PHONY: binaries-q3data
+binaries-q3data: \
        $(INSTALLDIR)/q3data.$(EXE) \
+       $(INSTALLDIR)/q3data \
+
+.PHONY: binaries-q3map2
+binaries-q3map2: \
        $(INSTALLDIR)/q3map2.$(EXE) \
-       $(INSTALLDIR)/qdata3.$(EXE) \
-       $(INSTALLDIR)/radiant.$(EXE) \
+       $(INSTALLDIR)/q3map2 \
+
 
 .PHONY: clean
 clean:
@@ -353,6 +456,9 @@ clean:
        $(CXX) $^ $(LDFLAGS) $(LDFLAGS_COMMON) $(LDFLAGS_EXTRA) $(LIBS_EXTRA) $(LIBS_COMMON) $(LIBS) -o $@
        [ -z "$(LDD)" ] || [ -z "`$(LDD) -r $@ $(STDERR_TO_STDOUT) $(STDOUT_TO_DEVNULL) $(TEE_STDERR)`" ] || { $(RM) $@; exit 1; }
 
+$(INSTALLDIR)/%: $(INSTALLDIR)/%.$(EXE)
+       if $(MAKE_EXE_SYMLINK); then o=$<; $(LN_SNF) $${o##*/} $@; else true; fi
+
 %.$(A):
        $(AR) rc $@ $^
        $(RANLIB) $@
@@ -370,24 +476,25 @@ ifeq ($(OS),Win32)
        $(WINDRES) $< $@
 endif
 
-%.o: %.cpp $(if $(findstring $(DEPEND_ON_MAKEFILE),yes),$(wildcard Makefile*),)
+%.o: %.cpp $(if $(findstring $(DEPEND_ON_MAKEFILE),yes),$(wildcard Makefile*),) | dependencies-check
        $(CXX) $< $(CFLAGS) $(CXXFLAGS) $(CFLAGS_COMMON) $(CXXFLAGS_COMMON) $(CPPFLAGS_EXTRA) $(CPPFLAGS_COMMON) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@
 
-%.o: %.c $(if $(findstring $(DEPEND_ON_MAKEFILE),yes),$(wildcard Makefile*),)
+%.o: %.c $(if $(findstring $(DEPEND_ON_MAKEFILE),yes),$(wildcard Makefile*),) | dependencies-check
        $(CC) $< $(CFLAGS) $(CFLAGS_COMMON) $(CPPFLAGS_EXTRA) $(CPPFLAGS_COMMON) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@
 
-$(INSTALLDIR)/q3map2.$(EXE): LIBS_EXTRA := $(LIBS_XML) $(LIBS_GLIB) $(LIBS_PNG) $(LIBS_ZLIB)
-$(INSTALLDIR)/q3map2.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_PNG) -Itools/quake3/common -Ilibs -Iinclude
+
+$(INSTALLDIR)/q3map2.$(EXE): LIBS_EXTRA := $(LIBS_XML) $(LIBS_GLIB) $(LIBS_PNG) $(LIBS_JPEG) $(LIBS_ZLIB)
+$(INSTALLDIR)/q3map2.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_PNG) $(CPPFLAGS_JPEG) -Itools/quake3/common -Ilibs -Iinclude
 $(INSTALLDIR)/q3map2.$(EXE): \
        tools/quake3/common/cmdlib.o \
        tools/quake3/common/imagelib.o \
        tools/quake3/common/inout.o \
+       tools/quake3/common/jpeg.o \
        tools/quake3/common/md4.o \
        tools/quake3/common/mutex.o \
        tools/quake3/common/polylib.o \
        tools/quake3/common/scriplib.o \
        tools/quake3/common/threads.o \
-       tools/quake3/common/unzip.o \
        tools/quake3/common/vfs.o \
        tools/quake3/q3map2/brush.o \
        tools/quake3/q3map2/brush_primit.o \
@@ -395,11 +502,19 @@ $(INSTALLDIR)/q3map2.$(EXE): \
        tools/quake3/q3map2/bspfile_ibsp.o \
        tools/quake3/q3map2/bspfile_rbsp.o \
        tools/quake3/q3map2/bsp.o \
+       tools/quake3/q3map2/bsp_analyze.o \
+       tools/quake3/q3map2/bsp_scale.o \
+       tools/quake3/q3map2/bsp_info.o \
        tools/quake3/q3map2/convert_ase.o \
+       tools/quake3/q3map2/convert_bsp.o \
+       tools/quake3/q3map2/convert_obj.o \
        tools/quake3/q3map2/convert_map.o \
        tools/quake3/q3map2/decals.o \
+       tools/quake3/q3map2/exportents.o \
        tools/quake3/q3map2/facebsp.o \
+       tools/quake3/q3map2/fixaas.o \
        tools/quake3/q3map2/fog.o \
+       tools/quake3/q3map2/help.o \
        tools/quake3/q3map2/image.o \
        tools/quake3/q3map2/leakfile.o \
        tools/quake3/q3map2/light_bounce.o \
@@ -409,6 +524,7 @@ $(INSTALLDIR)/q3map2.$(EXE): \
        tools/quake3/q3map2/light_ydnar.o \
        tools/quake3/q3map2/main.o \
        tools/quake3/q3map2/map.o \
+       tools/quake3/q3map2/minimap.o \
        tools/quake3/q3map2/mesh.o \
        tools/quake3/q3map2/model.o \
        tools/quake3/q3map2/patch.o \
@@ -427,7 +543,8 @@ $(INSTALLDIR)/q3map2.$(EXE): \
        tools/quake3/q3map2/vis.o \
        tools/quake3/q3map2/writebsp.o \
        libddslib.$(A) \
-       libjpeg6.$(A) \
+       libetclib.$(A) \
+       libfilematch.$(A) \
        libl_net.$(A) \
        libmathlib.$(A) \
        libpicomodel.$(A) \
@@ -446,31 +563,6 @@ libl_net.$(A): \
        libs/l_net/l_net.o \
        $(if $(findstring $(OS),Win32),libs/l_net/l_net_wins.o,libs/l_net/l_net_berkley.o) \
 
-libjpeg6.$(A): CPPFLAGS_EXTRA := -Ilibs/jpeg6 -Ilibs
-libjpeg6.$(A): \
-       libs/jpeg6/jcomapi.o \
-       libs/jpeg6/jdapimin.o \
-       libs/jpeg6/jdapistd.o \
-       libs/jpeg6/jdatasrc.o \
-       libs/jpeg6/jdcoefct.o \
-       libs/jpeg6/jdcolor.o \
-       libs/jpeg6/jddctmgr.o \
-       libs/jpeg6/jdhuff.o \
-       libs/jpeg6/jdinput.o \
-       libs/jpeg6/jdmainct.o \
-       libs/jpeg6/jdmarker.o \
-       libs/jpeg6/jdmaster.o \
-       libs/jpeg6/jdpostct.o \
-       libs/jpeg6/jdsample.o \
-       libs/jpeg6/jdtrans.o \
-       libs/jpeg6/jerror.o \
-       libs/jpeg6/jfdctflt.o \
-       libs/jpeg6/jidctflt.o \
-       libs/jpeg6/jmemmgr.o \
-       libs/jpeg6/jmemnobs.o \
-       libs/jpeg6/jpgload.o \
-       libs/jpeg6/jutils.o \
-
 libpicomodel.$(A): CPPFLAGS_EXTRA := -Ilibs
 libpicomodel.$(A): \
        libs/picomodel/lwo/clip.o \
@@ -501,6 +593,10 @@ libddslib.$(A): CPPFLAGS_EXTRA := -Ilibs
 libddslib.$(A): \
        libs/ddslib/ddslib.o \
 
+libetclib.$(A): CPPFLAGS_EXTRA := -Ilibs
+libetclib.$(A): \
+       libs/etclib.o \
+
 $(INSTALLDIR)/q3data.$(EXE): LIBS_EXTRA := $(LIBS_XML) $(LIBS_GLIB) $(LIBS_ZLIB)
 $(INSTALLDIR)/q3data.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_ZLIB) -Itools/quake3/common -Ilibs -Iinclude
 $(INSTALLDIR)/q3data.$(EXE): \
@@ -512,7 +608,6 @@ $(INSTALLDIR)/q3data.$(EXE): \
        tools/quake3/common/md4.o \
        tools/quake3/common/scriplib.o \
        tools/quake3/common/trilib.o \
-       tools/quake3/common/unzip.o \
        tools/quake3/common/vfs.o \
        tools/quake3/q3data/3dslib.o \
        tools/quake3/q3data/compress.o \
@@ -524,13 +619,15 @@ $(INSTALLDIR)/q3data.$(EXE): \
        tools/quake3/q3data/q3data.o \
        tools/quake3/q3data/stripper.o \
        tools/quake3/q3data/video.o \
+       libfilematch.$(A) \
+       libetclib.$(A) \
        libl_net.$(A) \
        libmathlib.$(A) \
        $(if $(findstring $(OS),Win32),icons/q3data.o,) \
 
 $(INSTALLDIR)/radiant.$(EXE): LDFLAGS_EXTRA := $(MWINDOWS)
-$(INSTALLDIR)/radiant.$(EXE): LIBS_EXTRA := $(LIBS_GL) $(LIBS_DL) $(LIBS_XML) $(LIBS_GLIB) $(LIBS_GTK) $(LIBS_GTKGLEXT) $(LIBS_ZLIB)
-$(INSTALLDIR)/radiant.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_GL) $(CPPFLAGS_DL) $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) $(CPPFLAGS_GTKGLEXT) -Ilibs -Iinclude
+$(INSTALLDIR)/radiant.$(EXE): LIBS_EXTRA := $(LIBS_GL) $(LIBS_DL) $(LIBS_XML) $(LIBS_GLIB) $(LIBS_GTK) $(LIBS_GTKGLEXT) $(LIBS_ZLIB) $(LIBS_PANGOFT2)
+$(INSTALLDIR)/radiant.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_GL) $(CPPFLAGS_DL) $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) $(CPPFLAGS_GTKGLEXT) $(CPPFLAGS_PANGOFT2) -Ilibs -Iinclude
 $(INSTALLDIR)/radiant.$(EXE): \
        radiant/autosave.o \
        radiant/brushmanip.o \
@@ -601,6 +698,7 @@ $(INSTALLDIR)/radiant.$(EXE): \
        radiant/stacktrace.o \
        radiant/surfacedialog.o \
        radiant/texmanip.o \
+       radiant/textureentry.o \
        radiant/textures.o \
        radiant/texwindow.o \
        radiant/timer.o \
@@ -615,12 +713,17 @@ $(INSTALLDIR)/radiant.$(EXE): \
        radiant/xywindow.o \
        libcmdlib.$(A) \
        libgtkutil.$(A) \
+       libuilib.$(A) \
        libl_net.$(A) \
        libmathlib.$(A) \
        libprofile.$(A) \
        libxmllib.$(A) \
        $(if $(findstring $(OS),Win32),icons/radiant.o,) \
 
+libfilematch.$(A): CPPFLAGS_EXTRA := -Ilibs
+libfilematch.$(A): \
+       libs/filematch.o \
+
 libcmdlib.$(A): CPPFLAGS_EXTRA := -Ilibs
 libcmdlib.$(A): \
        libs/cmdlib/cmdlib.o \
@@ -630,13 +733,11 @@ libprofile.$(A): \
        libs/profile/file.o \
        libs/profile/profile.o \
 
-libgtkutil.$(A): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) $(CPPFLAGS_GTKGLEXT) -Ilibs -Iinclude
+libgtkutil.$(A): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) $(CPPFLAGS_GTKGLEXT) $(CPPFLAGS_PANGOFT2) -Ilibs -Iinclude
 libgtkutil.$(A): \
        libs/gtkutil/accelerator.o \
        libs/gtkutil/button.o \
        libs/gtkutil/clipboard.o \
-       libs/gtkutil/closure.o \
-       libs/gtkutil/container.o \
        libs/gtkutil/cursor.o \
        libs/gtkutil/dialog.o \
        libs/gtkutil/entry.o \
@@ -644,51 +745,42 @@ libgtkutil.$(A): \
        libs/gtkutil/frame.o \
        libs/gtkutil/glfont.o \
        libs/gtkutil/glwidget.o \
-       libs/gtkutil/idledraw.o \
        libs/gtkutil/image.o \
        libs/gtkutil/menu.o \
        libs/gtkutil/messagebox.o \
        libs/gtkutil/nonmodal.o \
        libs/gtkutil/paned.o \
-       libs/gtkutil/pointer.o \
        libs/gtkutil/toolbar.o \
        libs/gtkutil/widget.o \
        libs/gtkutil/window.o \
        libs/gtkutil/xorrectangle.o \
 
+libuilib.$(A): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) $(CPPFLAGS_GTKGLEXT) -Ilibs -Iinclude
+libuilib.$(A): \
+       libs/uilib/uilib.o \
+
 libxmllib.$(A): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) -Ilibs -Iinclude
 libxmllib.$(A): \
-       libs/xml/ixml.o \
-       libs/xml/xmlelement.o \
-       libs/xml/xmlparser.o \
        libs/xml/xmltextags.o \
-       libs/xml/xmlwriter.o \
 
 $(INSTALLDIR)/modules/archivezip.$(DLL): LIBS_EXTRA := $(LIBS_ZLIB)
 $(INSTALLDIR)/modules/archivezip.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_ZLIB) -Ilibs -Iinclude
 $(INSTALLDIR)/modules/archivezip.$(DLL): \
        plugins/archivezip/archive.o \
-       plugins/archivezip/pkzip.o \
        plugins/archivezip/plugin.o \
-       plugins/archivezip/zlibstream.o \
 
 $(INSTALLDIR)/modules/archivewad.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
 $(INSTALLDIR)/modules/archivewad.$(DLL): \
        plugins/archivewad/archive.o \
        plugins/archivewad/plugin.o \
-       plugins/archivewad/wad.o \
 
 $(INSTALLDIR)/modules/archivepak.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
 $(INSTALLDIR)/modules/archivepak.$(DLL): \
        plugins/archivepak/archive.o \
-       plugins/archivepak/pak.o \
        plugins/archivepak/plugin.o \
 
-$(INSTALLDIR)/modules/entity.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
+$(INSTALLDIR)/modules/entity.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) -Ilibs -Iinclude
 $(INSTALLDIR)/modules/entity.$(DLL): \
-       plugins/entity/angle.o \
-       plugins/entity/angles.o \
-       plugins/entity/colour.o \
        plugins/entity/doom3group.o \
        plugins/entity/eclassmodel.o \
        plugins/entity/entity.o \
@@ -697,26 +789,22 @@ $(INSTALLDIR)/modules/entity.$(DLL): \
        plugins/entity/group.o \
        plugins/entity/light.o \
        plugins/entity/miscmodel.o \
-       plugins/entity/model.o \
-       plugins/entity/modelskinkey.o \
-       plugins/entity/namedentity.o \
-       plugins/entity/origin.o \
        plugins/entity/plugin.o \
-       plugins/entity/rotation.o \
-       plugins/entity/scale.o \
        plugins/entity/skincache.o \
        plugins/entity/targetable.o \
 
-$(INSTALLDIR)/modules/image.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
+$(INSTALLDIR)/modules/image.$(DLL): LIBS_EXTRA := $(LIBS_JPEG)
+$(INSTALLDIR)/modules/image.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_JPEG) -Ilibs -Iinclude
 $(INSTALLDIR)/modules/image.$(DLL): \
        plugins/image/bmp.o \
        plugins/image/dds.o \
        plugins/image/image.o \
        plugins/image/jpeg.o \
+       plugins/image/ktx.o \
        plugins/image/pcx.o \
        plugins/image/tga.o \
        libddslib.$(A) \
-       libjpeg6.$(A) \
+       libetclib.$(A) \
 
 $(INSTALLDIR)/modules/imageq2.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
 $(INSTALLDIR)/modules/imageq2.$(DLL): \
@@ -736,7 +824,7 @@ $(INSTALLDIR)/modules/imagepng.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_PNG) -Ilibs
 $(INSTALLDIR)/modules/imagepng.$(DLL): \
        plugins/imagepng/plugin.o \
 
-$(INSTALLDIR)/modules/mapq3.$(DLL): CPPFLAGS_EXTRA := -Ilibs -Iinclude
+$(INSTALLDIR)/modules/mapq3.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) -Ilibs -Iinclude
 $(INSTALLDIR)/modules/mapq3.$(DLL): \
        plugins/mapq3/parse.o \
        plugins/mapq3/plugin.o \
@@ -777,6 +865,7 @@ $(INSTALLDIR)/modules/vfspk3.$(DLL): \
        plugins/vfspk3/archive.o \
        plugins/vfspk3/vfs.o \
        plugins/vfspk3/vfspk3.o \
+       libfilematch.$(A) \
 
 $(INSTALLDIR)/plugins/bobtoolz.$(DLL): LIBS_EXTRA := $(LIBS_GLIB) $(LIBS_GTK)
 $(INSTALLDIR)/plugins/bobtoolz.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) -Ilibs -Iinclude
@@ -955,34 +1044,43 @@ $(INSTALLDIR)/heretic2/h2data.$(EXE): \
 install-data: binaries
        $(MKDIR) $(INSTALLDIR)/games
        $(FIND) $(INSTALLDIR_BASE)/ -name .svn -exec $(RM_R) {} \; -prune
-       [ "$(OS)" != "Darwin" ] || $(CP_R) setup/data/osx/NetRadiant.app/* $(INSTALLDIR_BASE)/NetRadiant.app/
-       set -ex; \
-       for GAME in games/*; do \
-               if [ "$$GAME" = "games/*" ]; then \
-                       $(ECHO) "Game packs not found, please run"; \
-                       $(ECHO) "  ./download-gamepacks.sh"; \
-                       $(ECHO) "and then try again!"; \
-               else \
-                       CP="$(CP)" CP_R="$(CP_R)" $(SH) install-gamepack.sh "$$GAME" "$(INSTALLDIR)"; \
-               fi; \
-       done
-       $(ECHO) $(RADIANT_MINOR_VERSION) > $(INSTALLDIR)/RADIANT_MINOR
+       DOWNLOAD_GAMEPACKS="$(DOWNLOAD_GAMEPACKS)" GIT="$(GIT)" SVN="$(SVN)" WGET="$(WGET)" RM_R="$(RM_R)" MV="$(MV)" UNZIPPER="$(UNZIPPER)" ECHO="$(ECHO)" SH="$(SH)" CP="$(CP)" CP_R="$(CP_R)" $(SH) install-gamepacks.sh "$(INSTALLDIR)"
        $(ECHO) $(RADIANT_MAJOR_VERSION) > $(INSTALLDIR)/RADIANT_MAJOR
+       $(ECHO) $(RADIANT_MINOR_VERSION) > $(INSTALLDIR)/RADIANT_MINOR
+       $(ECHO) $(RADIANT_PATCH_VERSION) > $(INSTALLDIR)/RADIANT_PATCH
        $(CP_R) setup/data/tools/* $(INSTALLDIR)/
+       $(MKDIR) $(INSTALLDIR)/docs
+       $(CP_R) docs/* $(INSTALLDIR)/docs/
        $(FIND) $(INSTALLDIR_BASE)/ -name .svn -exec $(RM_R) {} \; -prune
 
 .PHONY: install-dll
 ifeq ($(OS),Win32)
 install-dll: binaries
-       MKDIR="$(MKDIR)" CP="$(CP)" CAT="$(CAT)" GTKDIR="$(GTKDIR)" WHICHDLL="$(WHICHDLL)" INSTALLDIR="$(INSTALLDIR)" $(SH) install-dlls.sh
-else
-ifeq ($(OS),Darwin)
-install-dll: binaries
-       EXE="$(EXE)" MACLIBDIR="$(MACLIBDIR)" CP="$(CP)" OTOOL="$(OTOOL)" INSTALLDIR="$(INSTALLDIR)" $(SH) install-dylibs.sh
+       MKDIR="$(MKDIR)" CP="$(CP)" CAT="$(CAT)" GTKDIR="$(GTKDIR)" WHICHDLL="$(WHICHDLL)" INSTALLDIR="$(INSTALLDIR)" $(SH) $(DLLINSTALL) 
 else
 install-dll: binaries
        @$(ECHO) No DLL inclusion implemented for this target.
 endif
-endif
 
+# release building... NOT for general users
+# these may use tools not in the list that is checked by the build system
+release-src: BUILD_DATE := $(shell date +%Y%m%d)
+release-src: INSTALLDIR := netradiant-$(RADIANT_VERSION_NUMBER)-$(BUILD_DATE)
+release-src:
+       $(GIT) archive --format=tar --prefix=$(INSTALLDIR)/ HEAD | bzip2 > ../$(INSTALLDIR).tar.bz2
+
+release-win32: BUILD_DATE := $(shell date +%Y%m%d)
+release-win32: INSTALLDIR := netradiant-$(RADIANT_VERSION_NUMBER)-$(BUILD_DATE)
+release-win32:
+       $(MAKE) all INSTALLDIR=$(INSTALLDIR) MAKEFILE_CONF=cross-Makefile.conf RADIANT_ABOUTMSG="Official release build" BUILD=release
+       7za a -sfx../../../../../../../../../../$(HOME)/7z.sfx ../$(INSTALLDIR)-win32-7z.exe $(INSTALLDIR)/
+       chmod 644 ../$(INSTALLDIR)-win32-7z.exe # 7zip is evil
+       $(MAKE) clean INSTALLDIR=$(INSTALLDIR) MAKEFILE_CONF=cross-Makefile.conf RADIANT_ABOUTMSG="Official release build" BUILD=release
+
+release-all:
+       $(GIT) clean -xdf
+       $(MAKE) release-src
+       $(MAKE) release-win32
+
+# load dependency files
 -include $(shell find . -name \*.d)