automatically find DLLs
authorrpolzer <rpolzer@61c419a2-8eb2-4b30-bcec-8cead039b335>
Tue, 16 Sep 2008 08:39:49 +0000 (08:39 +0000)
committerrpolzer <rpolzer@61c419a2-8eb2-4b30-bcec-8cead039b335>
Tue, 16 Sep 2008 08:39:49 +0000 (08:39 +0000)
git-svn-id: svn://svn.icculus.org/netradiant/trunk@57 61c419a2-8eb2-4b30-bcec-8cead039b335

Makefile

index 3dde780d6868828fbc889251c17b66296f501c3a..9df9c7c81190b19ba0fa1bb954d645d0d4648c38 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -99,6 +99,7 @@ LDD ?= ldd
 FIND ?= find
 RANLIB ?= ranlib
 AR ?= ar
+OBJDUMP ?= objdump
 MKDIR ?= mkdir -p
 CP ?= cp
 CP_R ?= $(CP) -r
@@ -147,6 +148,7 @@ all: \
        install/qdata3.$(EXE) \
        install/radiant.$(EXE) \
        install-data \
+       install-dll \
 
 .PHONY: clean
 clean:
@@ -767,7 +769,7 @@ makeversion:
 .PHONY: install-data
 install-data: makeversion
        $(MKDIR) install/games
-       $(FIND) install/ -name .svn -exec $(RM_R) {} \; -prune; \
+       $(FIND) install/ -name .svn -exec $(RM_R) {} \; -prune
        set -ex; \
        for GAME in games/*; do \
                if [ -d "$$GAME/tools" ]; then \
@@ -783,6 +785,36 @@ install-data: makeversion
        $(CP) include/RADIANT_MAJOR install/
        $(CP) include/RADIANT_MINOR install/
        $(CP_R) setup/data/tools/* install/
-       $(FIND) install/ -name .svn -exec $(RM_R) {} \; -prune; \
+       $(FIND) install/ -name .svn -exec $(RM_R) {} \; -prune
+
+.PHONY: install-dll
+ifeq ($(OS),Win32)
+install-dll:
+       set -e; \
+       dllfetch() \
+       { \
+               dll=$$1; \
+               [ -f "install/$$dll" ] && return; \
+               dllsource=`which $$dll`; \
+               echo "Fetching $$dll..."; \
+               $(CP) $$dllsource install/$$dll; \
+               dlldeps install/$$dll; \
+       }; \
+       dlldeps() \
+       { \
+               echo "Looking for dependencies of $$1..."; \
+               $(OBJDUMP) -p $$1 | grep "DLL Name" | grep -- '-' | while read -r DUMMY1 DUMMY2 dll; do \
+                       dllfetch $$dll; \
+               done; \
+       }; \
+       dllfetch zlib1.dll; \
+       dllfetch intl.dll; \
+       for obj in install/*.$(EXE) install/*/*.$(DLL); do \
+               dlldeps $$obj; \
+       done
+else
+install-dll:
+       echo No DLL inclusion required for this target.
+endif
 
 -include $(shell find . -name \*.d)