Fix typo
[LibreOffice.git] / android / Bootstrap / Makefile.shared
blob0cd5ec6fcbda505e077c7ca6fe35d49125c0329b
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.
17 JNILIBSDIR=$(BUILDDIR)/android/jniLibs
18 SODEST=$(JNILIBSDIR)/$(ANDROID_APP_ABI)
19 OBJLOCAL=$(BUILDDIR)/android/obj/local/$(ANDROID_APP_ABI)
22 # Helpful rules ...
25 local.properties: $(BUILDDIR)/config_host.mk
26         echo sdk.dir=$(ANDROID_SDK_DIR) >local.properties
29 # Build / link the single .so for this app
32 ALL_STATIC_LIBS := $(shell $(SRCDIR)/bin/lo-all-static-libs)
34 LIBS = \
35   -Wl,--start-group \
36   $(ALL_STATIC_LIBS) \
37   -Wl,--end-group
39 NSSLIBS = freebl3 \
40         nspr4 \
41         nss3 \
42         nssckbi \
43         nssdbm3 \
44         nssutil3 \
45         plc4 \
46         plds4 \
47         smime3 \
48         softokn3 \
49         sqlite3 \
50         ssl3 \
52 WHOLELIBS = \
53   -Wl,--whole-archive \
54   $(addprefix -l,$(strip \
55         $(if $(ENABLE_JAVA),juh) \
56   )) \
57   -Wl,--no-whole-archive
60 $(OBJLOCAL)/liblo-native-code.so : native-code.cxx $(ALL_STATIC_LIBS)
61         @echo "Linking $@"
62         mkdir -p $(OBJLOCAL)
63         $(CXX) -Wl,--build-id=sha1 -Wl,--gc-sections -Wl,--version-script=../Bootstrap/version.map -Wl,--no-undefined -DANDROID -DDISABLE_DYNLOADING -shared -Wl,-soname,liblo-native-code.so -o $(OBJLOCAL)/liblo-native-code.so -I$(BUILDDIR)/config_host -I$(SRCDIR)/include native-code.cxx -L$(INSTDIR)/$(LIBO_LIB_FOLDER) $(WHOLELIBS) $(LIBS) -lc++_static -lc++abi $(if $(filter-out arm64-v8a x86_64,$(ANDROID_APP_ABI)),-landroid_support) $(if $(filter armeabi-v7a,$(ANDROID_APP_ABI)),-lunwind) $(addprefix -l,$(NSSLIBS)) -lGLESv2 -landroid -ljnigraphics -llog -lz
65 $(SODEST)/liblo-native-code.so : $(OBJLOCAL)/liblo-native-code.so
66         mkdir -p $(SODEST)
67         $(STRIP) -o $(SODEST)/liblo-native-code.so $(OBJLOCAL)/liblo-native-code.so
68         #to keep some symbols, eg.: $(STRIP) -o $(SODEST)/liblo-native-code.so $(OBJLOCAL)/liblo-native-code.so -w -K 'Java*'
70 $(SODEST)/nss-libraries :
71         mkdir -p $(SODEST)
72         $(foreach lib,$(NSSLIBS),$(STRIP) -o $(SODEST)/lib$(lib).so $(INSTDIR)/$(LIBO_LIB_FOLDER)/lib$(lib).so;)
74 $(SODEST)/libc++_shared.so : $(ANDROID_TOOLCHAIN)/sysroot/usr/lib/$(ANDROID_SYSROOT_PLATFORM)/libc++_shared.so
75         mkdir -p $(SODEST)
76         cp $< $@
78 link-so: $(SODEST)/liblo-native-code.so $(SODEST)/nss-libraries $(SODEST)/libc++_shared.so
80 # If you reinstall an app several times *on the emulator*, even if you
81 # uninstall it between, disk space seems to leak that won't get recycled until
82 # you stop and start... No idea if this holds for a device, too. (And you
83 # can't "stop" a device anyway.)
85 stop-start-cycle:
86         $(ANDROID_SDK_DIR)/platform-tools/adb shell stop && $(ANDROID_SDK_DIR)/platform-tools/adb shell start && sleep 10
88 # build-host specific stuff (build paths and the like) to keep build.gradle static
89 liboSettings.gradle: $(BUILDDIR)/config_build.mk $(BUILDDIR)/config_host.mk \
90                 $(wildcard $(INSTDIR)/program/version.ini $(INSTDIR)/program/versionrc) \
91                 $(SRCDIR)/android/Bootstrap/Makefile.shared
92         @echo "creating $@"
93         ( \
94                 echo "// created by Makefile.shared - your changes will be overridden" \
95                 && echo "ext {" \
96                 && echo "    liboSrcRoot         = '$(SRC_ROOT)'" \
97                 && echo "    liboJniLibsdir      = '$(JNILIBSDIR)'" \
98                 && echo "    liboWorkdir         = '$(WORKDIR)'" \
99                 && echo "    liboInstdir         = '$(INSTDIR)'" \
100                 && echo "    liboEtcFolder       = '$(LIBO_ETC_FOLDER)'" \
101                 && echo "    liboUreMiscFolder   = '$(LIBO_URE_MISC_FOLDER)'" \
102                 && echo "    liboSharedResFolder = '$(LIBO_SHARE_RESOURCE_FOLDER)'" \
103                 && echo "    liboUREJavaFolder   = '$(LIBO_URE_SHARE_JAVA_FOLDER)'" \
104                 && echo "    liboShareJavaFolder = '$(LIBO_SHARE_JAVA_FOLDER)'" \
105                 && echo "    liboVersionMajor    = '$(LIBO_VERSION_MAJOR)'" \
106                 && echo "    liboVersionMinor    = '$(LIBO_VERSION_MINOR)'" \
107                 && echo "    liboGitFullCommit   = '$(shell cd $(SRCDIR) && git log -1 --format=%H)'" \
108                 && echo "}" \
109                 && echo "android {" \
110                 && echo "    ndkPath '$(ANDROID_NDK_DIR)'" \
111                 && echo "}" \
112                 && echo "android.defaultConfig {" \
113                 && echo "    applicationId '$(ANDROID_PACKAGE_NAME)'" \
114                 && echo "    archivesBaseName = 'LibreOfficeViewer'" \
115                 && echo "    minSdkVersion = $(ANDROID_API_LEVEL)" \
116                 && echo "    versionCode project.hasProperty('cmdVersionCode') ? cmdVersionCode.toInteger() : $(if $(versionCode),$(versionCode),1)" \
117                 && echo "    versionName '$(LIBO_VERSION_MAJOR).$(LIBO_VERSION_MINOR).$(LIBO_VERSION_MICRO).$(LIBO_VERSION_PATCH)$(LIBO_VERSION_SUFFIX)$(LIBO_VERSION_SUFFIX_SUFFIX)'" \
118                 && echo "    buildConfigField('String', 'BUILD_ID_SHORT', '\"$(shell cd $(SRCDIR) && git log -1 --format=%h)\"')" \
119                 && echo "    buildConfigField('String', 'VENDOR', '\"$(OOO_VENDOR)\"')" \
120                 && echo "    buildConfigField('String', 'PRIVACY_POLICY_URL', '\"$(PRIVACY_POLICY_URL)\"')" \
121                 && echo "}" \
122         ) > $@