2 # Common Makefile pieces for building Java / Android apps.
6 # BOOTSTRAPDIR needs to be set to this directory before starting this
9 # Probably would be best to just stop fooling around with the possibilities to
10 # set various stuff with the -env command line parameters (and environment
11 # variables?) and in a plethora of rc files, and hardcode construction of
12 # *all* required pathnames based on the app installation location for Android
13 # (and iOS), etc. We don't really win anything by having so many layers of
14 # configurability on platforms like Android and iOS where apps based on LO
15 # code are very much self-contained pre-packaged thingies.
16 APP_DATA_PATH=/data/data/$(APP_PACKAGE)
18 SODEST=libs/$(ANDROID_APP_ABI)
19 OBJLOCAL=obj/local/$(ANDROID_APP_ABI)
21 APPCOMPATDIR=$(BOOTSTRAPDIR)/../AppCompat-v7
24 $(error COPYSO should not be used now with DISABLE_DYNLOADING)
28 mkdir -p libs && cp $(1) libs
36 # The Android SDK recommends you copy/paste some big -package-resources
37 # rule in order to not pack certain kinds of resources. Unfortunately this
38 # rule interacts with the rest of the ant code in horrible ways such that
39 # upgrading your SDK auto-breaks everything.
43 $(BOOTSTRAPDIR)/no-resource-compress.xml : $(ANDROID_SDK_HOME)/tools/ant/build.xml $(BOOTSTRAPDIR)/no-resource-compress-*.xml
45 android_sdk_ver=`grep 'Pkg.Revision' $(ANDROID_SDK_HOME)/tools/source.properties | sed 's/^.*=//' | sed 's/\..*//'` ; \
46 sed 's/@ANDROID_PACKAGE_NAME@/$(ANDROID_PACKAGE_NAME)/' < $(BOOTSTRAPDIR)/no-resource-compress-$$android_sdk_ver.xml > $@ ; \
47 if ! test -f $(BOOTSTRAPDIR)/no-resource-compress.xml; then \
48 echo "Unknown Android SDK version: $$android_sdk_ver"; \
53 android_version_setup : $(BOOTSTRAPDIR)/no-resource-compress.xml
56 mkdir $(APPCOMPATDIR) 2>/dev/null; true
57 cp -rf $(ANDROID_SDK_HOME)/extras/android/support/v7/appcompat/* $(APPCOMPATDIR)
58 $(ANDROID_SDK_HOME)/tools/android update lib-project --target android-21 --path $(APPCOMPATDIR)
61 echo sdk.dir=$(ANDROID_SDK_HOME) >local.properties
62 echo sdk.dir=$(ANDROID_SDK_HOME) >../../Bootstrap/local.properties
63 echo "# File needed by ndk-gdb" >jni/Application.mk
64 echo "APP_ABI := $(ANDROID_APP_ABI)" > jni/Application.mk
65 echo "APP_PLATFORM := android-21" >> jni/Application.mk
68 unset JAVA_HOME && $(ANT) $(if $(VERBOSE)$(verbose),,-quiet) debug install
70 @echo 'Run it with "make run"'
74 $(ANDROID_SDK_HOME)/platform-tools/adb uninstall $(APP_PACKAGE)
76 clean: android_version_setup properties
77 $(ANT) $(if $(VERBOSE)$(verbose),,-quiet) -keep-going clean
78 rm -rf assets libs $(SODEST) $(OBJLOCAL) $(BOOTSTRAPDIR)/no-resource-compress.xml
80 rm -rf $(APPCOMPATDIR)
83 # Build / link the single .so for this app
86 ALL_STATIC_LIBS := $(shell $(SRCDIR)/bin/lo-all-static-libs)
95 $(addprefix -l,$(strip \
98 -Wl,--no-whole-archive
101 $(OBJLOCAL)/liblo-native-code.so : native-code.cxx $(ALL_STATIC_LIBS)
103 $(CXX) -Wl,--gc-sections -Wl,--version-script=../../Bootstrap/version.map -Wl,--no-keep-files-mapped -Wl,--no-undefined -DANDROID -DDISABLE_DYNLOADING -shared -o $(OBJLOCAL)/liblo-native-code.so -I$(BUILDDIR)/config_host -I$(SRCDIR)/include native-code.cxx -L$(INSTDIR)/$(LIBO_LIB_FOLDER) $(WHOLELIBS) $(LIBS) -lgnustl_static -lGLESv2 -landroid -ljnigraphics -llog -lz
105 $(SODEST)/liblo-native-code.so : $(OBJLOCAL)/liblo-native-code.so
107 $(STRIP) -o $(SODEST)/liblo-native-code.so $(OBJLOCAL)/liblo-native-code.so
108 #to keep some symbols, eg.: $(STRIP) -o $(SODEST)/liblo-native-code.so $(OBJLOCAL)/liblo-native-code.so -w -K 'Java*'
110 # shrinkme $(STRIP) -o $(SODEST)/liblo-native-code.so $(OBJLOCAL)/liblo-native-code.so
112 link-so: $(SODEST)/liblo-native-code.so
114 # If you reinstall an app several times *on the emulator*, even if you
115 # uninstall it between, disk space seems to leak that won't get recycled until
116 # you stop and start... No idea if this holds for a device, too. (And you
117 # can't "stop" a device anyway.)
120 $(ANDROID_SDK_HOME)/platform-tools/adb shell stop && $(ANDROID_SDK_HOME)/platform-tools/adb shell start && sleep 10
123 # Then "assets". Let the directory structure under assets mimic
124 # that under solver for now.
126 # Please note that I have no idea what all of this is really necessary and for
127 # much of this stuff being copied, no idea whether it makes any sense at all.
128 # Much of this is copy-pasted from android/qa/sc/Makefile (where a couple of
129 # unit tests for sc are built, and those do seem to mostly work) and
130 # android/qa/desktop/Makefile (mmeeks's desktop demo, also works to some
133 mkdir -p assets/lib assets/program/services assets/gz.unpack/program
134 gzip -9 <$(INSTDIR)/$(LIBO_ETC_FOLDER)/types/offapi.rdb >assets/gz.unpack/program/offapi.rdb
135 gzip -9 <$(INSTDIR)/$(LIBO_ETC_FOLDER)/types/oovbaapi.rdb >assets/gz.unpack/program/oovbaapi.rdb
136 gzip -9 <$(INSTDIR)/$(LIBO_URE_MISC_FOLDER)/types.rdb >assets/gz.unpack/program/udkapi.rdb
137 # For some reason the vnd.sun.star.expand:$LO_LIB_DIR doesn't seem to work, it expands to empty!?
138 for F in program/services/services program/services; do \
139 sed -e 's!uri="vnd.sun.star.expand:$$LO_LIB_DIR/!uri="file://$$APP_DATA_DIR/lib/!g' <$(INSTDIR)/$$F.rdb >assets/$$F.rdb; \
141 cp $(if $(exampleDocument),$(exampleDocument),$(SRC_ROOT)/android/default-document/example.odt) assets/example.odt
142 cp $(SRC_ROOT)/readlicense_oo/license/LICENSE assets/license.txt
143 cp $(SRC_ROOT)/readlicense_oo/license/NOTICE assets/notice.txt
145 rm -Rf assets/share # pre-clean it
146 mkdir -p assets/share/config
147 cp -R $(INSTDIR)/share/registry assets/share
148 # Filter data is needed by e.g. the drawingML preset shape import.
149 cp -R $(INSTDIR)/share/filter assets/share
150 # Make sure the soffice.cfg directory is always created, it's not possible to hit any keys without it.
151 if ! test z$(DISABLE_UI) = zTRUE; then \
152 echo "Copying UI files into the apk"; \
153 cp -R $(INSTDIR)/share/config/soffice.cfg assets/share/config; \
155 echo "Skipping UI files"; \
156 mkdir -p assets/share/config/soffice.cfg; \
157 echo > assets/share/config/soffice.cfg/empty; \
158 for F in main.xcd res/registry_en-US.xcd; do \
159 $(SRC_ROOT)/android/mobile-config.py assets/share/registry/$$F assets/share/registry/$$F.new && mv assets/share/registry/$$F.new assets/share/registry/$$F; \
163 mkdir -p assets/unpack/program
164 echo '[Bootstrap]' > assets/unpack/program/sofficerc
165 echo 'Logo=1' >> assets/unpack/program/sofficerc
166 echo 'NativeProgress=1' >> assets/unpack/program/sofficerc
167 echo 'URE_BOOTSTRAP=file:///assets/program/fundamentalrc' >> assets/unpack/program/sofficerc
168 echo 'HOME=$$APP_DATA_DIR/cache' >> assets/unpack/program/sofficerc
169 echo 'OSL_SOCKET_PATH=$$APP_DATA_DIR/cache' >> assets/unpack/program/sofficerc
171 # Set up fundamentalrc
172 echo '[Bootstrap]' > assets/program/fundamentalrc
173 echo 'LO_LIB_DIR=file://$$APP_DATA_DIR/lib/' >> assets/program/fundamentalrc
174 echo 'BRAND_BASE_DIR=file:///assets' >> assets/program/fundamentalrc
175 echo 'CONFIGURATION_LAYERS=xcsxcu:$${BRAND_BASE_DIR}/share/registry res:$${BRAND_BASE_DIR}/share/registry' >> assets/program/fundamentalrc
176 echo 'URE_BIN_DIR=file:///assets/ure/bin/dir/nothing-here/we-can/exec-anyway' >> assets/program/fundamentalrc
179 echo '[Bootstrap]' > assets/program/unorc
180 echo 'URE_INTERNAL_LIB_DIR=file://$$APP_DATA_DIR/lib/' >> assets/program/unorc
181 echo 'UNO_TYPES=file://$$APP_DATA_DIR/program/udkapi.rdb file://$$APP_DATA_DIR/program/offapi.rdb file://$$APP_DATA_DIR/program/oovbaapi.rdb' >> assets/program/unorc
182 echo 'UNO_SERVICES=file:///assets/program/services.rdb file:///assets/program/services/services.rdb' >> assets/program/unorc
185 echo '[Bootstrap]' > assets/program/bootstraprc
186 echo 'InstallMode=<installmode>' >> assets/program/bootstraprc
187 echo 'ProductKey=LibreOffice $(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR)' >> assets/program/bootstraprc
188 echo 'UserInstallation=file://$$APP_DATA_DIR' >> assets/program/bootstraprc
191 echo '[Version]' > assets/program/versionrc
192 echo 'AllLanguages=en-US' >> assets/program/versionrc
193 echo 'BuildVersion=' >> assets/program/versionrc
194 echo 'buildid=$(shell cd $(SRCDIR) && git log -1 --format=%H)' >> assets/program/versionrc
195 echo 'ReferenceOOoMajorMinor=4.1' >> assets/program/versionrc
196 sed -e 's|@ANDROID_DEBUGGABLE@|$(if $(ENABLE_DEBUG),android:debuggable="true",)|' \
197 -e 's|@ANDROID_INSTALL_LOCATION@|$(if $(ENABLE_DEBUG),internalOnly,preferExternal)|' \
198 -e 's|@ANDROID_VERSION_NAME@|$(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR).$(LIBO_VERSION_MICRO).$(LIBO_VERSION_PATCH)$(LIBO_VERSION_SUFFIX)$(LIBO_VERSION_SUFFIX_SUFFIX)/$(shell cd $(SRCDIR) && git log -1 --format=%h)/$(OOO_VENDOR)|' \
199 -e 's|@ANDROID_VERSION_NUMBER@|$(if $(versionCode),$(versionCode),1)|' \
200 < AndroidManifest.xml.in > AndroidManifest.xml
203 mkdir -p assets/program/resource
204 cp $(INSTDIR)/$(LIBO_SHARE_RESOURCE_FOLDER)/*en-US.res assets/program/resource
206 # Assets that are unpacked at run-time into the app's data directory. These
207 # are files read by non-LO code, fontconfig and freetype for now, that doesn't
208 # understand "/assets" paths.
209 mkdir -p assets/unpack/etc/fonts
210 cp fonts.conf assets/unpack/etc/fonts
211 # $UserInstallation/user/fonts is added to the fontconfig path in
212 # vcl/generic/fontmanager/helper.cxx: psp::getFontPath(). UserInstallation is
213 # set to the app's data dir above.
214 mkdir -p assets/gz.unpack/user/fonts
215 for F in $(INSTDIR)/share/fonts/truetype/Liberation*.ttf \
216 $(INSTDIR)/share/fonts/truetype/Caladea-*.ttf \
217 $(INSTDIR)/share/fonts/truetype/Carlito-*.ttf \
218 $(INSTDIR)/share/fonts/truetype/Gen*.ttf \
219 $(INSTDIR)/share/fonts/truetype/opens___.ttf; do \
220 gzip -9 <$$F >assets/gz.unpack/user/fonts/`basename $$F`; \
223 # Then gdbserver and gdb.setup so that we can debug with ndk-gdb.
226 cp $(ANDROID_NDK_GDBSERVER) $(SODEST)
227 echo set solib-search-path ./obj/local/$(ANDROID_APP_ABI) >$(SODEST)/gdb.setup