1 # This Makefile fragment builds the Android package (XCSoar.apk).
2 # We're not using NDK's Makefiles because our Makefile is so big and
3 # complex, we don't want to duplicate that for another platform.
5 ifeq ($(TARGET
),ANDROID
)
7 # When enabled, the package org.xcsoar.testing is created, with a red
8 # Activity icon, to allow simultaneous installation of "stable" and
10 # In the stable branch, this should default to "n".
16 ANDROID_KEYSTORE
= $(HOME
)/.android
/mk.keystore
17 ANDROID_KEY_ALIAS
= mk
18 ANDROID_BUILD
= $(TARGET_OUTPUT_DIR
)/build
19 ANDROID_BIN
= $(TARGET_BIN_DIR
)
21 ifeq ($(HOST_IS_DARWIN
),y
)
22 ANDROID_SDK ?
= $(HOME
)/opt
/android-sdk-macosx
24 ANDROID_SDK ?
= $(HOME
)/opt
/android-sdk-linux_x86
26 ANDROID_SDK_PLATFORM_DIR
= $(ANDROID_SDK
)/platforms
/$(ANDROID_SDK_PLATFORM
)
27 ANDROID_ABI_DIR
= $(ANDROID_BUILD
)/libs
/$(ANDROID_ABI3
)
29 ANDROID_LIB_NAMES
= xcsoar
33 ANDROID_TOOL_OPTIONS
= --silent
36 ANDROID_TOOL_OPTIONS
= --verbose
39 JARSIGNER
+= -digestalg SHA1
-sigalg MD5withRSA
41 # The environment variable ANDROID_KEYSTORE_PASS may be used to
42 # specify the keystore password; if you don't set it, you will be
44 ifeq ($(origin ANDROID_KEYSTORE_PASS
),environment
)
45 JARSIGNER
+= -storepass
:env ANDROID_KEYSTORE_PASS
48 JAVA_PACKAGE
= org.xcsoar
49 CLASS_NAME
= $(JAVA_PACKAGE
).NativeView
50 CLASS_SOURCE
= $(subst .
,/,$(CLASS_NAME
)).java
51 CLASS_CLASS
= $(patsubst %.java
,%.class
,$(CLASS_SOURCE
))
53 NATIVE_CLASSES
= NativeView EventBridge Timer InternalGPS NonGPSSensors NativeInputListener DownloadUtil
54 ifneq ($(IOIOLIB_DIR
),)
55 NATIVE_CLASSES
+= NativeBMP085Listener
56 NATIVE_CLASSES
+= NativeI2CbaroListener
57 NATIVE_CLASSES
+= NativeNunchuckListener
58 NATIVE_CLASSES
+= NativeVoltageListener
60 NATIVE_SOURCES
= $(patsubst %,android
/src
/%.java
,$(NATIVE_CLASSES
))
61 NATIVE_PREFIX
= $(TARGET_OUTPUT_DIR
)/include/$(subst .
,_
,$(JAVA_PACKAGE
))_
62 NATIVE_HEADERS
= $(patsubst %,$(NATIVE_PREFIX
)%.h
,$(NATIVE_CLASSES
))
64 ANDROID_JAVA_SOURCES
:= $(wildcard android
/src
/*.java
)
65 ifeq ($(IOIOLIB_DIR
),)
66 ANDROID_JAVA_SOURCES
:= $(filter-out $(wildcard android
/src
/*IOIO
*.java
),$(ANDROID_JAVA_SOURCES
))
67 ANDROID_JAVA_SOURCES
:= $(filter-out $(wildcard android
/src
/*BMP085
*.java
),$(ANDROID_JAVA_SOURCES
))
68 ANDROID_JAVA_SOURCES
:= $(filter-out $(wildcard android
/src
/*I2Cbaro
*.java
),$(ANDROID_JAVA_SOURCES
))
69 ANDROID_JAVA_SOURCES
:= $(filter-out $(wildcard android
/src
/*Nunchuck
*.java
),$(ANDROID_JAVA_SOURCES
))
70 ANDROID_JAVA_SOURCES
:= $(filter-out $(wildcard android
/src
/*Voltage
*.java
),$(ANDROID_JAVA_SOURCES
))
73 DRAWABLE_DIR
= $(ANDROID_BUILD
)/res
/drawable
74 RAW_DIR
= $(ANDROID_BUILD
)/res
/raw
77 ICON_SVG
= $(topdir
)/Data
/graphics
/logo_red.svg
79 ICON_SVG
= $(topdir
)/Data
/graphics
/logo.svg
82 $(ANDROID_BUILD
)/res
/drawable-ldpi
/icon.png
: $(ICON_SVG
) |
$(ANDROID_BUILD
)/res
/drawable-ldpi
/dirstamp
83 $(Q
)rsvg-convert
--width
=36 $< -o
$@
85 $(ANDROID_BUILD
)/res
/drawable
/icon.png
: $(ICON_SVG
) |
$(ANDROID_BUILD
)/res
/drawable
/dirstamp
86 $(Q
)rsvg-convert
--width
=48 $< -o
$@
88 $(ANDROID_BUILD
)/res
/drawable-hdpi
/icon.png
: $(ICON_SVG
) |
$(ANDROID_BUILD
)/res
/drawable-hdpi
/dirstamp
89 $(Q
)rsvg-convert
--width
=72 $< -o
$@
91 $(ANDROID_BUILD
)/res
/drawable-xhdpi
/icon.png
: $(ICON_SVG
) |
$(ANDROID_BUILD
)/res
/drawable-xhdpi
/dirstamp
92 $(Q
)rsvg-convert
--width
=96 $< -o
$@
94 OGGENC
= oggenc
--quiet
--quality
1
96 SOUNDS
= fail insert remove beep_bweep beep_clear beep_drip
97 SOUND_FILES
= $(patsubst %,$(RAW_DIR
)/%.ogg
,$(SOUNDS
))
99 $(SOUND_FILES
): $(RAW_DIR
)/%.ogg
: Data
/sound
/%.wav |
$(RAW_DIR
)/dirstamp
100 @
$(NQ
)echo
" OGGENC $@"
101 $(Q
)$(OGGENC
) -o
$@
$<
103 PNG1
:= $(patsubst Data
/bitmaps
/%.bmp
,$(DRAWABLE_DIR
)/%.png
,$(BMP_BITMAPS
))
105 # workaround for an ImageMagick bug (observed with the Debian package
106 # 8:6.7.7.10-2): it corrupts 4-bit gray-scale images when converting
107 # BMP to PNG (TRAC #2220)
108 PNG1b
:= $(filter $(DRAWABLE_DIR
)/vario_scale_
%.png
,$(PNG1
))
109 PNG1
:= $(filter-out $(DRAWABLE_DIR
)/vario_scale_
%.png
,$(PNG1
))
110 $(DRAWABLE_DIR
)/vario_scale_
%.png
: Data
/bitmaps
/vario_scale_
%.bmp |
$(DRAWABLE_DIR
)/dirstamp
111 $(Q
)$(IM_PREFIX
)convert
-depth
8 $< $@
113 $(PNG1
): $(DRAWABLE_DIR
)/%.png
: Data
/bitmaps
/%.bmp |
$(DRAWABLE_DIR
)/dirstamp
114 $(Q
)$(IM_PREFIX
)convert
$< $@
116 PNG2
:= $(patsubst $(DATA
)/graphics
/%.bmp
,$(DRAWABLE_DIR
)/%.png
,$(BMP_LAUNCH_ALL
))
117 $(PNG2
): $(DRAWABLE_DIR
)/%.png
: $(DATA
)/graphics
/%.bmp |
$(DRAWABLE_DIR
)/dirstamp
118 $(Q
)$(IM_PREFIX
)convert
$< $@
120 PNG3
:= $(patsubst $(DATA
)/graphics
/%.bmp
,$(DRAWABLE_DIR
)/%.png
,$(BMP_SPLASH_80
) $(BMP_SPLASH_160
) $(BMP_TITLE_110
) $(BMP_TITLE_320
))
121 $(PNG3
): $(DRAWABLE_DIR
)/%.png
: $(DATA
)/graphics
/%.bmp |
$(DRAWABLE_DIR
)/dirstamp
122 $(Q
)$(IM_PREFIX
)convert
$< $@
124 PNG4
:= $(patsubst $(DATA
)/icons
/%.bmp
,$(DRAWABLE_DIR
)/%.png
,$(BMP_ICONS
) $(BMP_ICONS_160
))
125 $(PNG4
): $(DRAWABLE_DIR
)/%.png
: $(DATA
)/icons
/%.bmp |
$(DRAWABLE_DIR
)/dirstamp
126 $(Q
)$(IM_PREFIX
)convert
$< $@
128 PNG5
:= $(patsubst $(DATA
)/graphics
/%.bmp
,$(DRAWABLE_DIR
)/%.png
,$(BMP_DIALOG_TITLE
) $(BMP_PROGRESS_BORDER
))
129 $(PNG5
): $(DRAWABLE_DIR
)/%.png
: $(DATA
)/graphics
/%.bmp |
$(DRAWABLE_DIR
)/dirstamp
130 $(Q
)$(IM_PREFIX
)convert
$< $@
132 PNG_FILES
= $(PNG1
) $(PNG1b
) $(PNG2
) $(PNG3
) $(PNG4
) $(PNG5
) \
133 $(ANDROID_BUILD
)/res
/drawable-ldpi
/icon.png \
134 $(ANDROID_BUILD
)/res
/drawable
/icon.png \
135 $(ANDROID_BUILD
)/res
/drawable-hdpi
/icon.png \
136 $(ANDROID_BUILD
)/res
/drawable-xhdpi
/icon.png
139 MANIFEST
= android
/testing
/AndroidManifest.xml
141 MANIFEST
= android
/AndroidManifest.xml
144 # symlink some important files to $(ANDROID_BUILD) and let the Android
145 # SDK generate build.xml
146 $(ANDROID_BUILD
)/build.xml
: $(MANIFEST
) $(PNG_FILES
) |
$(TARGET_BIN_DIR
)/dirstamp
147 @
$(NQ
)echo
" ANDROID $@"
148 $(Q
)rm -r
-f
$@
$(@D
)/*_rules.xml
$(@D
)/AndroidManifest.xml
$(@D
)/src
$(@D
)/bin
$(@D
)/res
/values
149 $(Q
)mkdir
-p
$(ANDROID_BUILD
)/res
$(ANDROID_BUILD
)/src
/org
/xcsoar
150 $(Q
)ln
-s ..
/..
/..
/$(MANIFEST
) $(@D
)/AndroidManifest.xml
151 $(Q
)ln
-s ..
/bin
$(@D
)/bin
152 $(Q
)ln
-s
$(addprefix ..
/..
/..
/..
/..
/..
/,$(ANDROID_JAVA_SOURCES
)) $(@D
)/src
/org
/xcsoar
153 ifneq ($(IOIOLIB_DIR
),)
154 $(Q
)mkdir
-p
$(ANDROID_BUILD
)/src
/ioio
/lib
155 $(Q
)ln
-s
$(abspath
$(IOIOLIB_DIR
)/src
/ioio
/lib
/api
) $(ANDROID_BUILD
)/src
/ioio
/lib
/api
156 $(Q
)ln
-s
$(abspath
$(IOIOLIB_DIR
)/src
/ioio
/lib
/spi
) $(ANDROID_BUILD
)/src
/ioio
/lib
/spi
157 $(Q
)ln
-s
$(abspath
$(IOIOLIB_DIR
)/src
/ioio
/lib
/util
) $(ANDROID_BUILD
)/src
/ioio
/lib
/util
158 $(Q
)ln
-s
$(abspath
$(IOIOLIB_DIR
)/src
/ioio
/lib
/impl
) $(ANDROID_BUILD
)/src
/ioio
/lib
/impl
160 $(Q
)ln
-s ..
/..
/..
/..
/android
/res
/values
$(@D
)/res
/values
162 echo
"now run your android build followed by exit. For example:"
163 echo
"c:\opt\android-sdk\tools\android.bat update project --path c:\xcsoar\output\android\build --target $(ANDROID_SDK_PLATFORM)"
166 $(Q
)$(ANDROID_SDK
)/tools
/android
$(ANDROID_TOOL_OPTIONS
) update project
--path
$(@D
) --target
$(ANDROID_SDK_PLATFORM
)
167 $(Q
)ln
-s ..
/..
/..
/android
/custom_rules.xml
$(@D
)/
170 $(Q
)ln
-s ..
/..
/..
/..
/..
/..
/android
/src
/testing
$(@D
)/src
/org
/xcsoar
171 $(Q
)ln
-s ..
/..
/..
/android
/testing
/testing_rules.xml
$(@D
)/
175 ifeq ($(FAT_BINARY
),y
)
177 # generate a "fat" APK file with binaries for all ABIs
181 # Example: $(eval $(call generate-abi,xcsoar,armeabi-v7a,ANDROID7))
184 ANDROID_LIB_BUILD
+= $$(ANDROID_BUILD
)/libs
/$(2)/lib
$(1).so
186 $$(ANDROID_BUILD
)/libs
/$(2)/lib
$(1).so
: $$(OUT
)/$(3)/bin
/lib
$(1).so |
$$(ANDROID_BUILD
)/libs
/$(2)/dirstamp
189 $$(OUT
)/$(3)/bin
/lib
$(1).so
:
190 $$(Q
)$$(MAKE
) TARGET
=$(3) DEBUG
=$$(DEBUG
) IOIOLIB_DIR
=$$(IOIOLIB_DIR
) $$@
194 # Example: $(eval $(call generate-abi,xcsoar))
195 define generate-all-abis
196 $(eval
$(call generate-abi
,$(1),armeabi
,ANDROID
))
197 $(eval
$(call generate-abi
,$(1),armeabi-v7a
,ANDROID7
))
198 $(eval
$(call generate-abi
,$(1),x86
,ANDROID86
))
199 $(eval
$(call generate-abi
,$(1),mips
,ANDROIDMIPS
))
202 $(foreach NAME
,$(ANDROID_LIB_NAMES
),$(eval
$(call generate-all-abis
,$(NAME
))))
206 # add dependency to this source file
207 $(call SRC_TO_OBJ
,$(SRC
)/Android
/Main.
cpp): $(NATIVE_HEADERS
)
208 $(call SRC_TO_OBJ
,$(SRC
)/Android
/EventBridge.
cpp): $(NATIVE_HEADERS
)
209 $(call SRC_TO_OBJ
,$(SRC
)/Android
/Timer.
cpp): $(NATIVE_HEADERS
)
210 $(call SRC_TO_OBJ
,$(SRC
)/Android
/InternalSensors.
cpp): $(NATIVE_HEADERS
)
211 $(call SRC_TO_OBJ
,$(SRC
)/Android
/Battery.
cpp): $(NATIVE_HEADERS
)
212 $(call SRC_TO_OBJ
,$(SRC
)/Android
/NativeInputListener.
cpp): $(NATIVE_HEADERS
)
213 $(call SRC_TO_OBJ
,$(SRC
)/Android
/DownloadManager.
cpp): $(NATIVE_HEADERS
)
214 $(call SRC_TO_OBJ
,$(SRC
)/Android
/NativeBMP085Listener.
cpp): $(NATIVE_HEADERS
)
215 $(call SRC_TO_OBJ
,$(SRC
)/Android
/NativeI2CbaroListener.
cpp): $(NATIVE_HEADERS
)
216 $(call SRC_TO_OBJ
,$(SRC
)/Android
/NativeNunchuckListener.
cpp): $(NATIVE_HEADERS
)
217 $(call SRC_TO_OBJ
,$(SRC
)/Android
/NativeVoltageListener.
cpp): $(NATIVE_HEADERS
)
219 ANDROID_LIB_BUILD
= $(patsubst %,$(ANDROID_ABI_DIR
)/lib
%.so
,$(ANDROID_LIB_NAMES
))
220 $(ANDROID_LIB_BUILD
): $(ANDROID_ABI_DIR
)/lib
%.so
: $(TARGET_BIN_DIR
)/lib
%.so
$(ANDROID_ABI_DIR
)/dirstamp
223 $(ANDROID_BUILD
)/bin
/classes
/$(CLASS_CLASS
): $(NATIVE_SOURCES
) $(ANDROID_BUILD
)/build.xml
$(ANDROID_BUILD
)/res
/drawable
/icon.png
$(SOUND_FILES
)
225 $(Q
)cd
$(ANDROID_BUILD
) && $(ANT
) nodeps compile-jni-classes
228 $(patsubst %,$(NATIVE_PREFIX
)%.h
,$(NATIVE_CLASSES
)): $(NATIVE_PREFIX
)%.h
: android
/src
/%.java
$(ANDROID_BUILD
)/bin
/classes
/$(CLASS_CLASS
)
229 @
$(NQ
)echo
" JAVAH $@"
230 $(Q
)javah
-classpath
$(ANDROID_SDK_PLATFORM_DIR
)/android.jar
:$(ANDROID_BUILD
)/bin
/classes
-d
$(@D
) $(subst _
,.
,$(patsubst $(patsubst .
/%,%,$(TARGET_OUTPUT_DIR
))/include/%.h
,%,$@
))
235 $(ANDROID_BIN
)/XCSoar-debug.apk
: $(ANDROID_LIB_BUILD
) $(ANDROID_BUILD
)/build.xml
$(ANDROID_BUILD
)/res
/drawable
/icon.png
$(SOUND_FILES
) $(ANDROID_JAVA_SOURCES
)
237 @
rm -f
$@
$(patsubst %.apk
,%-unaligned.apk
,$@
) $(@D
)/classes.dex
238 $(Q
)cd
$(ANDROID_BUILD
) && $(ANT
) nodeps debug
240 $(ANDROID_BIN
)/XCSoar-release-unsigned.apk
: $(ANDROID_LIB_BUILD
) $(ANDROID_BUILD
)/build.xml
$(ANDROID_BUILD
)/res
/drawable
/icon.png
$(SOUND_FILES
) $(ANDROID_JAVA_SOURCES
)
242 @
rm -f
$@
$(@D
)/classes.dex
243 $(Q
)cd
$(ANDROID_BUILD
) && $(ANT
) nodeps release
245 $(ANDROID_BIN
)/XCSoar-release-unaligned.apk
: $(ANDROID_BIN
)/XCSoar-release-unsigned.apk
246 @
$(NQ
)echo
" SIGN $@"
247 $(Q
)$(JARSIGNER
) -keystore
$(ANDROID_KEYSTORE
) -signedjar
$@
$< $(ANDROID_KEY_ALIAS
)
249 $(ANDROID_BIN
)/XCSoar.apk
: $(ANDROID_BIN
)/XCSoar-release-unaligned.apk
250 @
$(NQ
)echo
" ALIGN $@"
251 $(Q
)$(ANDROID_SDK
)/tools
/zipalign
-f
4 $< $@