summaryrefslogtreecommitdiff
path: root/android/Bootstrap/Makefile.shared
blob: 657e433e364746b2d4c02545add256a06c211066 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#
# Common Makefile pieces for building Java / Android apps.
#

#
# BOOTSTRAPDIR needs to be set to this directory before starting this
#

# Probably would be best to just stop fooling around with the possibilities to
# set various stuff with the -env command line parameters (and environment
# variables?) and in a plethora of rc files, and hardcode construction of
# *all* required pathnames based on the app installation location for Android
# (and iOS), etc. We don't really win anything by having so many layers of
# configurability on platforms like Android and iOS where apps based on LO
# code are very much self-contained pre-packaged thingies.
APP_DATA_PATH=/data/data/$(APP_PACKAGE)

SODEST=libs/$(ANDROID_APP_ABI)
OBJLOCAL=obj/local/$(ANDROID_APP_ABI)

define COPYSO
       $(error COPYSO should not be used now with DISABLE_DYNLOADING)
endef

define COPYJAR
mkdir -p libs && cp $(1) libs
endef

#
# Helpful rules ...
#

#
# The Android SDK recommends you copy/paste some big -package-resources
# rule in order to not pack certain kinds of resources. Unfortunately this
# rule interacts with the rest of the ant code in horrible ways such that
# upgrading your SDK auto-breaks everything.
#
# Horrors below:
#
$(BOOTSTRAPDIR)/no-resource-compress.xml : $(ANDROID_SDK_HOME)/tools/ant/build.xml
	( \
	android_sdk_ver=`grep 'Pkg.Revision' $(ANDROID_SDK_HOME)/tools/source.properties | sed 's/^.*=//' | sed 's/\..*//'` ; \
	cp $(BOOTSTRAPDIR)/no-resource-compress-$$android_sdk_ver.xml $(BOOTSTRAPDIR)/no-resource-compress.xml ; \
	if ! test -f $(BOOTSTRAPDIR)/no-resource-compress.xml; then \
	   echo "Unknown Android SDK version: $$android_sdk_ver"; \
	   exit 1; \
	fi \
	)

android_version_setup : $(BOOTSTRAPDIR)/no-resource-compress.xml

properties:
	echo sdk.dir=$(ANDROID_SDK_HOME) >local.properties
	echo sdk.dir=$(ANDROID_SDK_HOME) >../../Bootstrap/local.properties
	echo "# File needed by ndk-gdb" >jni/Application.mk
	echo "APP_ABI := $(ANDROID_APP_ABI)" > jni/Application.mk
	echo "APP_PLATFORM := android-14" >> jni/Application.mk

install: build-ant
	unset JAVA_HOME && $(ANT) -quiet debug install
	@echo
	@echo 'Run it with "make run"'
	@echo

uninstall:
	$(ANDROID_SDK_HOME)/platform-tools/adb uninstall $(APP_PACKAGE)

clean: android_version_setup properties
	$(ANT) -quiet -keep-going clean
	rm -rf assets libs $(SODEST) $(OBJLOCAL) $(BOOTSTRAPDIR)/no-resource-compress.xml

#
# Build / link the single .so for this app
#

# Sigh, it's sad that now with solver dying we have to list the
# locations of each needed bundled 3rd-party lib like this. Maybe we
# really should try to make these experimental Android apps (and the
# iOS one) buildable with gbuild.

LIBS = \
  -Wl,--start-group \
  $(wildcard $(INSTDIR)/$(LIBO_LIB_FOLDER)/lib*.a) \
  $(wildcard $(WORKDIR)/LinkTarget/StaticLibrary/lib*.a) \
  $(FREEHAND_LIBS) \
  $(HARFBUZZ_LIBS) \
  $(HUNSPELL_LIBS) \
  $(HYPHEN_LIB) \
  $(MYTHES_LIBS) \
  $(wildcard $(WORKDIR)/UnpackedTarball/curl/lib/.libs/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/fontconfig/src/.libs/libfontconfig.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/freetype/objs/.libs/libfreetype.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/icu/source/lib/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/lcms2/src/.libs/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/libcdr/src/lib/.libs/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/libmspub/src/lib/.libs/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/libmwaw/src/lib/.libs/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/libodfgen/src/.libs/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/liborcus/src/*/.libs/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/libvisio/src/lib/.libs/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/libwp?/src/lib/.libs/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/lpsolve/lpsolve55/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/openssl/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/raptor/src/.libs/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/rasqal/src/.libs/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/redland/src/.libs/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/xml2/.libs/*.a) \
  $(wildcard $(WORKDIR)/UnpackedTarball/xslt/libxslt/.libs/*.a) \
  -Wl,--end-group

WHOLELIBS = \
  -Wl,--whole-archive \
  $(addprefix -l,$(strip \
	juh \
  )) \
  -Wl,--no-whole-archive


$(OBJLOCAL)/liblo-native-code.so : native-code.cxx dummies.cxx
	mkdir -p $(OBJLOCAL)
	$(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 dummies.cxx -L$(INSTDIR)/$(LIBO_LIB_FOLDER) $(WHOLELIBS) $(LIBS) -lgnustl_static -landroid -ljnigraphics -llog -lz

$(SODEST)/liblo-native-code.so : $(OBJLOCAL)/liblo-native-code.so
	mkdir -p $(SODEST)
	$(STRIP) -o $(SODEST)/liblo-native-code.so $(OBJLOCAL)/liblo-native-code.so

# shrinkme $(STRIP) -o $(SODEST)/liblo-native-code.so $(OBJLOCAL)/liblo-native-code.so

link-so: $(SODEST)/liblo-native-code.so

# If you reinstall an app several times *on the emulator*, even if you
# uninstall it between, disk space seems to leak that won't get recycled until
# you stop and start... No idea if this holds for a device, too. (And you
# can't "stop" a device anyway.)

stop-start-cycle:
	$(ANDROID_SDK_HOME)/platform-tools/adb shell stop && $(ANDROID_SDK_HOME)/platform-tools/adb shell start && sleep 10