Home | History | Annotate | Download | only in build
      1 # GNU/Linux makefile for ProGuard.
      2 
      3 ANT_HOME = /usr/local/java/ant
      4 WTK_HOME = /usr/local/java/wtk
      5 
      6 PROGUARD_HOME := $(subst ./..,..,$(subst /build/..,/,$(dir $(MAKEFILE_LIST))..))
      7 SRC     = $(PROGUARD_HOME)/src
      8 CLASSES = $(PROGUARD_HOME)/classes
      9 LIB     = $(PROGUARD_HOME)/lib
     10 
     11 ANT_JAR = $(ANT_HOME)/lib/ant.jar
     12 WTK_JAR = $(WTK_HOME)/wtklib/kenv.zip
     13 
     14 CLASSPATH = $(ANT_JAR):$(WTK_JAR)
     15 
     16 PROGUARD     = proguard/ProGuard
     17 PROGUARD_GUI = proguard/gui/ProGuardGUI
     18 RETRACE      = proguard/retrace/ReTrace
     19 ANT_TASK     = proguard/ant/ProGuardTask
     20 WTK_PLUGIN   = proguard/wtk/ProGuardObfuscator
     21 
     22 TARGETS = $(PROGUARD) $(PROGUARD_GUI) $(RETRACE) $(ANT_TASK) $(WTK_PLUGIN)
     23 
     24 JAVAC_OPTIONS = -nowarn -Xlint:none -classpath $(CLASSPATH) -sourcepath $(SRC) -d $(CLASSES)
     25 
     26 # Command sequence definitions for creating jars.
     27 
     28 define createjar
     29   jar -cfm $(LIB)/$@.jar $(SRC)/$(dir $<)MANIFEST.MF \
     30     -C $(CLASSES) $(dir $<)
     31 endef
     32 
     33 define updatejar
     34   jar -uf $(LIB)/proguard.jar \
     35     -C $(CLASSES) $(dir $<)
     36 endef
     37 
     38 # The various targets.
     39 
     40 all:     basic options
     41 basic:   proguard proguardgui retrace
     42 options: anttask wtkplugin
     43 
     44 proguard: $(PROGUARD)
     45 	$(createjar)
     46 
     47 proguardgui: proguard
     48 proguardgui: $(PROGUARD_GUI)
     49 	$(createjar)
     50 
     51 retrace: $(RETRACE)
     52 	$(createjar)
     53 
     54 anttask: $(ANT_JAR)
     55 anttask: $(PROGUARD)
     56 anttask: $(ANT_TASK)
     57 	$(updatejar)
     58 
     59 wtkplugin: $(WTK_JAR)
     60 wtkplugin: $(PROGUARD)
     61 wtkplugin: $(WTK_PLUGIN)
     62 	$(updatejar)
     63 
     64 clean:
     65 	-rm -fr $(CLASSES) $(LIB)
     66 
     67 
     68 define RESOURCES
     69   $(shell find $(SRC)/$(dir $(1)) -maxdepth 1 \( -name \*.properties -o -name \*.png -o -name \*.gif -o -name \*.pro \) -printf $(CLASSES)/$(dir $(1))%P\\n)
     70 endef
     71 
     72 define TARGETRULE
     73   $(1): $(CLASSES) $(CLASSES)/$(1).class $(call RESOURCES,$(1)) $(LIB)
     74 endef
     75 
     76 $(foreach TARGET,$(TARGETS),$(eval $(call TARGETRULE,$(TARGET))))
     77 
     78 $(CLASSES) $(LIB):
     79 	-mkdir -p $@
     80 
     81 $(CLASSES)/%.class: $(SRC)/%.java
     82 	javac $(JAVAC_OPTIONS) $^
     83 
     84 $(CLASSES)/%.properties $(CLASSES)/%.png $(CLASSES)/%.gif $(CLASSES)/%.pro:
     85 	cp $(subst $(CLASSES),$(SRC),$@) $@
     86 
     87 %.jar %.zip:
     88 	echo "Please make sure the path to $@ is set"
     89 	echo "correctly in this $(strip $(MAKEFILE_LIST))."
     90 	echo "Alternatively, if you don't need the corresponding option,"
     91 	echo "you can run `make' with the option -k."
     92 	find $@
     93 
     94 .PHONY: all basic options proguard proguardgui retrace anttask wtkplugin clean $(TARGETS) $(OPTIONAL_TARGETS)
     95