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