]> git.gag.com Git - fw/altos/blob - altosdroid/Makefile.am
altosuilib: Include device path in equals test of AltosUSBDevice
[fw/altos] / altosdroid / Makefile.am
1 if ANDROID
2 all_target=bin/AltosDroid-debug.apk
3 if ANDROID_RELEASE
4 all_target+=bin/AltosDroid-release.apk
5 endif
6 else
7 all_target=
8 endif
9
10 SDK=$(ANDROID_SDK)
11 SDK_TARGET=$(shell sed -ne 's/^target=//p' project.properties)
12
13 DX=$(SDK)/platform-tools/dx
14 ADB=$(SDK)/platform-tools/adb
15 AAPT=$(SDK)/platform-tools/aapt
16 APKBUILDER=$(SDK)/tools/apkbuilder
17 ZIPALIGN_A=$(SDK)/tools/zipalign
18 ZIPALIGN_B=$(shell ls $(SDK)/build-tools/*/zipalign | tail -1)
19
20 JAVA_SRC_DIR=src/org/altusmetrum/AltosDroid
21 EXT_LIBDIR=libs
22 DRAWABLE_DIR=res/drawable
23 LAYOUT_DIR=res/layout
24 MENU_DIR=res/menu
25 VALUES_DIR=res/values
26 XML_DIR=res/xml
27 ALTOSLIB_SRCDIR=../altoslib
28 ALTOSLIB_JAR=altoslib_$(ALTOSLIB_VERSION).jar
29
30 ALTOSLIB=$(EXT_LIBDIR)/$(ALTOSLIB_JAR)
31
32 SUPPORT_V4_SRCDIR=$(SDK)/extras/android/support/v4
33 SUPPORT_V4_JAR=android-support-v4.jar
34
35 SUPPORT_V4=$(EXT_LIBDIR)/$(SUPPORT_V4_JAR)
36
37 GOOGLE_PLAY_SERVICES_LIB_SRCDIR=$(SDK)/extras/google/google_play_services/libproject
38 GOOGLE_PLAY_SERVICES_LIB=google-play-services_lib
39
40 JAVA_SRC=$(JAVA_SRC_DIR)/*.java $(JAVA_SRC_DIR)/BuildInfo.java
41
42 DRAWABLES=\
43     $(DRAWABLE_DIR)/redled.png \
44     $(DRAWABLE_DIR)/greenled.png \
45     $(DRAWABLE_DIR)/grayled.png
46
47 LAYOUTS=$(LAYOUT_DIR)/*.xml
48 MENUS=$(MENU_DIR)/*.xml
49 VALUES=$(VALUES_DIR)/*.xml
50 XMLS=$(XML_DIR)/*.xml AndroidManifest.xml
51
52 RES=$(LAYOUTS) $(MENUS) $(VALUES) $(XMLS)
53
54 SRC=$(JAVA_SRC) $(DRAWABLES) $(RES)
55
56 all: $(all_target)
57
58 .NOTPARALLEL:
59
60 $(ALTOSLIB): $(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR)
61         mkdir -p $(EXT_LIBDIR)
62         cd $(EXT_LIBDIR) && ln -sf $(shell echo $(EXT_LIBDIR) | sed 's|[^/]\+|..|g')/$(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR) .
63
64 $(SUPPORT_V4): $(SUPPORT_V4_SRCDIR)/$(SUPPORT_V4_JAR)
65         mkdir -p $(EXT_LIBDIR)
66         cd $(EXT_LIBDIR) && ln -sf $(SUPPORT_V4_SRCDIR)/$(SUPPORT_V4_JAR) .
67
68 $(GOOGLE_PLAY_SERVICES_LIB): $(GOOGLE_PLAY_SERVICES_LIB_SRCDIR)/$(GOOGLE_PLAY_SERVICES_LIB)
69         cp -a $(GOOGLE_PLAY_SERVICES_LIB_SRCDIR)/$(GOOGLE_PLAY_SERVICES_LIB) .
70         cd $(GOOGLE_PLAY_SERVICES_LIB) && $(SDK)/tools/android update project --target $(SDK_TARGET) --path .
71
72 $(JAVA_SRC_DIR)/BuildInfo.java: $(filter-out $(JAVA_SRC_DIR)/BuildInfo.java,$(shell echo $(JAVA_SRC)))
73         ./buildinfo.sh
74
75 $(DRAWABLE_DIR)/%.png: ../icon/%.png
76         cd $(DRAWABLE_DIR) && ln -sf $(shell echo $(DRAWABLE_DIR) | sed 's|[^/]\+|..|g')/$< .
77
78 if ANDROID
79 install-release: bin/AltosDroid-release.apk
80         $(ADB) install -r bin/AltosDroid-release.apk
81
82 install-debug: bin/AltosDroid-debug.apk
83         $(ADB) install -r bin/AltosDroid-debug.apk
84
85 bin/AltosDroid-debug.apk: $(SRC) $(ALTOSLIB) $(SUPPORT_V4) $(GOOGLE_PLAY_SERVICES_LIB)
86         ant debug
87
88 bin/AltosDroid-release-unsigned.apk: $(SRC) $(ALTOSLIB) $(SUPPORT_V4) $(GOOGLE_PLAY_SERVICES_LIB)
89         ant release
90
91 bin/AltosDroid-release.apk: bin/AltosDroid-release-unsigned.apk
92         jarsigner -sigalg SHA1withDSA -digestalg SHA1 \
93            -keystore ~/altusmetrumllc/google-play-release.keystore \
94            -storepass:file ~/altusmetrumllc/google-play-passphrase \
95            -signedjar bin/AltosDroid-release-signed.apk \
96            bin/AltosDroid-release-unsigned.apk AltosDroid
97         if [ -f $(ZIPALIGN_A) ]; then \
98                 $(ZIPALIGN_A) -f 4 \
99                    bin/AltosDroid-release-signed.apk \
100                    bin/AltosDroid-release.apk; \
101         else \
102                 $(ZIPALIGN_B) -f 4 \
103                    bin/AltosDroid-release-signed.apk \
104                    bin/AltosDroid-release.apk; \
105         fi
106
107 release: bin/AltosDroid-release.apk
108
109 clean-local: $(GOOGLE_PLAY_SERVICES_LIB)
110         ant clean
111         rm -f $(JAVA_SRC_DIR)/BuildInfo.java
112         rm -f $(DRAWABLES)
113         rm -rf $(EXT_LIBDIR)
114         rm -rf $(GOOGLE_PLAY_SERVICES_LIB)
115
116 else
117
118 clean-local:
119
120 endif
121
122 clean: clean-local