altosdroid: Update notebook to reflect current status
[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=$(SDK)/tools/zipalign
18
19 JAVA_SRC_DIR=src/org/altusmetrum/AltosDroid
20 EXT_LIBDIR=libs
21 DRAWABLE_DIR=res/drawable
22 ALTOSLIB_SRCDIR=../altoslib
23 ALTOSLIB_JAR=altoslib_$(ALTOSLIB_VERSION).jar
24
25 ALTOSLIB=$(EXT_LIBDIR)/$(ALTOSLIB_JAR)
26
27 SUPPORT_V4_SRCDIR=$(SDK)/extras/android/support/v4
28 SUPPORT_V4_JAR=android-support-v4.jar
29
30 SUPPORT_V4=$(EXT_LIBDIR)/$(SUPPORT_V4_JAR)
31
32 GOOGLE_PLAY_SERVICES_LIB_SRCDIR=$(SDK)/extras/google/google_play_services/libproject
33 GOOGLE_PLAY_SERVICES_LIB=google-play-services_lib
34
35 JAVA_SRC=$(JAVA_SRC_DIR)/*.java $(JAVA_SRC_DIR)/BuildInfo.java
36
37 DRAWABLES=\
38     $(DRAWABLE_DIR)/redled.png \
39     $(DRAWABLE_DIR)/greenled.png \
40     $(DRAWABLE_DIR)/grayled.png
41
42 SRC=$(JAVA_SRC) $(DRAWABLES)
43
44 all: $(all_target)
45
46 .NOTPARALLEL:
47
48 $(EXT_LIBDIR):
49         mkdir -p $(EXT_LIBDIR)
50
51 $(ALTOSLIB): $(EXT_LIBDIR) $(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR)
52         cd $(EXT_LIBDIR) && ln -sf $(shell echo $(EXT_LIBDIR) | sed 's|[^/]\+|..|g')/$(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR) .
53
54 $(SUPPORT_V4): $(EXT_LIBDIR) $(SUPPORT_V4_SRCDIR)/$(SUPPORT_V4_JAR)
55         cd $(EXT_LIBDIR) && ln -sf $(SUPPORT_V4_SRCDIR)/$(SUPPORT_V4_JAR) .
56
57 $(GOOGLE_PLAY_SERVICES_LIB): $(GOOGLE_PLAY_SERVICES_LIB_SRCDIR)/$(GOOGLE_PLAY_SERVICES_LIB)
58         cp -a $(GOOGLE_PLAY_SERVICES_LIB_SRCDIR)/$(GOOGLE_PLAY_SERVICES_LIB) .
59         cd $(GOOGLE_PLAY_SERVICES_LIB) && $(SDK)/tools/android update project --target $(SDK_TARGET) --path .
60
61 $(JAVA_SRC_DIR)/BuildInfo.java: $(filter-out $(JAVA_SRC_DIR)/BuildInfo.java,$(shell echo $(JAVA_SRC)))
62         ./buildinfo.sh
63
64 $(DRAWABLE_DIR)/%.png: ../icon/%.png
65         cd $(DRAWABLE_DIR) && ln -sf $(shell echo $(DRAWABLE_DIR) | sed 's|[^/]\+|..|g')/$< .
66
67 if ANDROID
68 install-release: bin/AltosDroid-release.apk
69         $(ADB) install -r bin/AltosDroid-release.apk
70
71 install-debug: bin/AltosDroid-debug.apk
72         $(ADB) install -r bin/AltosDroid-debug.apk
73
74 bin/AltosDroid-debug.apk: $(SRC) $(ALTOSLIB) $(SUPPORT_V4) $(GOOGLE_PLAY_SERVICES_LIB)
75         ant debug
76
77 bin/AltosDroid-release-unsigned.apk: $(SRC) $(ALTOSLIB) $(SUPPORT_V4) $(GOOGLE_PLAY_SERVICES_LIB)
78         ant release
79
80 bin/AltosDroid-release.apk: bin/AltosDroid-release-unsigned.apk
81         jarsigner -sigalg SHA1withDSA -digestalg SHA1 \
82            -keystore ~/altusmetrumllc/google-play-release.keystore \
83            -storepass:file ~/altusmetrumllc/google-play-passphrase \
84            -signedjar bin/AltosDroid-release-signed.apk \
85            bin/AltosDroid-release-unsigned.apk AltosDroid
86         $(ZIPALIGN) -f 4 \
87            bin/AltosDroid-release-signed.apk \
88            bin/AltosDroid-release.apk
89
90 release: bin/AltosDroid-release.apk
91
92 clean-local: $(GOOGLE_PLAY_SERVICES_LIB)
93         ant clean
94         rm -f $(JAVA_SRC_DIR)/BuildInfo.java
95         rm -f $(DRAWABLES)
96         rm -rf $(EXT_LIBDIR)
97         rm -rf $(GOOGLE_PLAY_SERVICES_LIB)
98
99 else
100
101 clean-local:
102
103 endif
104
105 clean: clean-local