aboutsummaryrefslogtreecommitdiffstats
path: root/java/Makefile.in
diff options
context:
space:
mode:
Diffstat (limited to 'java/Makefile.in')
-rw-r--r--java/Makefile.in337
1 files changed, 337 insertions, 0 deletions
diff --git a/java/Makefile.in b/java/Makefile.in
new file mode 100644
index 00000000000..804d4669c7a
--- /dev/null
+++ b/java/Makefile.in
@@ -0,0 +1,337 @@
1### @configure_input@
2
3# Copyright (C) 2023 Free Software Foundation, Inc.
4
5# This file is part of GNU Emacs.
6
7# GNU Emacs is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11
12# GNU Emacs is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16
17# You should have received a copy of the GNU General Public License
18# along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20top_builddir = @top_builddir@
21top_srcdir = @top_srcdir@
22srcdir = @srcdir@
23builddir = @builddir@
24version = @version@
25
26# Don't install movemail if mailutils are to be used.
27emacs_use_mailutils = @emacs_use_mailutils@
28
29# This is the host lib-src and lib, not the cross compiler's lib-src.
30libsrc = ../lib-src
31EXEEXT = @EXEEXT@
32
33-include ${top_builddir}/src/verbose.mk
34
35SHELL = @SHELL@
36JAVAC = @JAVAC@
37AAPT = @AAPT@
38D8 = @D8@
39ZIPALIGN = @ZIPALIGN@
40JARSIGNER = @JARSIGNER@
41APKSIGNER = @APKSIGNER@
42JARSIGNER_FLAGS =
43ANDROID_JAR = @ANDROID_JAR@
44ANDROID_ABI = @ANDROID_ABI@
45ANDROID_SDK_18_OR_EARLIER = @ANDROID_SDK_18_OR_EARLIER@
46ANDROID_SDK_8_OR_EARLIER = @ANDROID_SDK_8_OR_EARLIER@
47WARN_JAVAFLAGS = @WARN_JAVAFLAGS@
48JAVAFLAGS = $(WARN_JAVAFLAGS) -classpath "$(ANDROID_JAR):$(srcdir)"
49FIND_DELETE = @FIND_DELETE@
50
51# Android 4.3 and earlier require Emacs to be signed with a different
52# digital signature algorithm.
53
54ifneq (,$(ANDROID_SDK_18_OR_EARLIER))
55JARSIGNER_FLAGS = -sigalg MD5withRSA -digestalg SHA1
56else
57JARSIGNER_FLAGS =
58endif
59
60# When building Emacs for Android 2.2, assets must not be compressed.
61# Otherwise, the asset manager fails to extract files larger than 1
62# MB.
63
64ifneq (,$(ANDROID_SDK_8_OR_EARLIER))
65AAPT_ASSET_ARGS = -0 ""
66else
67AAPT_ASSET_ARGS =
68endif
69
70SIGN_EMACS = -keystore $(srcdir)/emacs.keystore -storepass \
71 emacs1 $(JARSIGNER_FLAGS)
72SIGN_EMACS_V2 = sign --v2-signing-enabled --ks \
73 $(srcdir)/emacs.keystore -debuggable-apk-permitted \
74 --ks-pass pass:emacs1
75
76JAVA_FILES := $(wildcard $(srcdir)/org/gnu/emacs/*.java)
77RESOURCE_FILES := $(foreach file,$(wildcard $(srcdir)/res/*), \
78 $(wildcard $(file)/*))
79
80# R.java is a file generated by the `aapt' utility containing
81# constants that can then be used to locate ``resource identifiers''.
82# It is not a regular file and should not be compiled as Java source
83# code. Instead, it is automatically included by the Java compiler.
84RESOURCE_FILE := $(srcdir)/org/gnu/emacs/R.java
85
86# CLASS_FILES is what should actually be built and included in the
87# resulting Emacs executable. The Java compiler might generate more
88# than one class file for each source file, so this only serves as a
89# list of dependencies for Make.
90CLASS_FILES := $(foreach file,$(JAVA_FILES),$(basename $(file)).class)
91
92# Remove RESOURCE_FILE from JAVA_FILES, if it is already present.
93JAVA_FILES := $(filter-out $(RESOURCE_FILE),$(JAVA_FILES))
94
95# Compute the name for the Emacs application package. This should be:
96# emacs-<version>-<min-sdk>-<abi>.apk
97
98ANDROID_MIN_SDK := @ANDROID_MIN_SDK@
99APK_NAME := emacs-$(version)-$(ANDROID_MIN_SDK)-$(ANDROID_ABI).apk
100
101# How this stuff works.
102
103# emacs.apk depends on emacs.apk-in, which is simply a ZIP archive
104# containing the following files:
105# lib/$(ANDROID_ABI)/libemacs.so
106# lib/$(ANDROID_ABI)/libandroid-emacs.so
107# lib/$(ANDROID_ABI)/libctags.so
108# lib/$(ANDROID_ABI)/libetags.so
109# lib/$(ANDROID_ABI)/libhexl.so
110# lib/$(ANDROID_ABI)/libmovemail.so
111# lib/$(ANDROID_ABI)/librcs2log.so
112# lib/$(ANDROID_ABI)/libebrowse.so
113# assets/info/
114# assets/etc/
115# assets/lisp/
116
117.PHONY: emacs.apk-in all
118all: $(APK_NAME)
119
120# Binaries to cross-compile.
121CROSS_SRC_BINS := $(top_builddir)/cross/src/android-emacs
122CROSS_LIBSRC_BINS := $(top_builddir)/cross/lib-src/ctags \
123 $(top_builddir)/cross/lib-src/hexl \
124 $(top_builddir)/cross/lib-src/ebrowse \
125 $(top_builddir)/cross/lib-src/emacsclient \
126 $(top_builddir)/cross/lib-src/etags
127CROSS_LIBSRC_BINS_MOVEMAIL := $(top_builddir)/cross/lib-src/movemail
128CROSS_EXEC_BINS := $(top_builddir)/exec/exec1 $(top_builddir)/exec/loader
129CROSS_BINS = $(CROSS_SRC_BINS) $(CROSS_LIBSRC_BINS) $(CROSS_EXEC_BINS)
130
131ifneq ($(emacs_use_mailutils),yes)
132CROSS_LIBSRC_BINS := $(CROSS_LIBSRC_BINS) $(CROSS_LIBSRC_BINS_MOVEMAIL)
133endif
134
135# Libraries to cross-compile.
136CROSS_LIBS = $(top_builddir)/cross/src/libemacs.so
137
138# Make sure gnulib is built first!
139# If not, then the recursive invocations of make below will try to
140# build gnulib at the same time.
141CROSS_ARCHIVES = $(top_builddir)/cross/lib/libgnu.a
142
143# Third party libraries to compile.
144-include $(top_builddir)/cross/ndk-build/ndk-build.mk
145
146.PHONY: $(CROSS_BINS) $(CROSS_LIBS) $(CROSS_ARCHIVES)
147
148# There should only be a single invocation of $(MAKE) -C
149# $(top_srcdir)/cross for each directory under $(top_srcdir)/cross.
150$(CROSS_SRC_BINS) $(CROSS_LIBS) &: $(CROSS_ARCHIVES)
151 $(MAKE) -C $(top_builddir)/cross $(foreach file, \
152 $(CROSS_SRC_BINS) \
153 $(CROSS_LIBS), \
154 src/$(notdir $(file)))
155
156$(CROSS_LIBSRC_BINS) &: $(CROSS_ARCHIVES)
157 $(MAKE) -C $(top_builddir)/cross $(foreach file, \
158 $(CROSS_LIBSRC_BINS), \
159 lib-src/$(notdir $(file)))
160
161$(CROSS_ARCHIVES):
162 $(MAKE) -C $(top_builddir)/cross lib/libgnu.a
163
164# These two binaries are helpers used to execute binaries on Android
165# 10 and later.
166
167$(CROSS_EXEC_BINS) &:
168 $(MAKE) -C $(top_builddir)/exec $(notdir $(CROSS_EXEC_BINS))
169
170# This is needed to generate the ``.directory-tree'' file used by the
171# Android emulations of readdir and faccessat.
172
173$(libsrc)/asset-directory-tool:
174 $(MAKE) -C $(libsrc) $(notdir $@)
175
176# install_tmp is a directory used to generate emacs.apk-in.
177# That is then packaged into $(APK_NAME).
178# There is no need to depend on NDK_BUILD_SHARED as libemacs.so
179# does already.
180
181.PHONY: install_temp install_temp/assets/directory-tree
182install_temp: $(CROSS_BINS) $(CROSS_LIBS) $(RESOURCE_FILES)
183 $(AM_V_GEN)
184# Make the working directory for this stuff
185 $(AM_V_SILENT) rm -rf install_temp
186 $(AM_V_SILENT) mkdir -p install_temp/lib/$(ANDROID_ABI)
187 $(AM_V_SILENT) mkdir -p install_temp/assets/etc
188 $(AM_V_SILENT) mkdir -p install_temp/assets/lisp
189 $(AM_V_SILENT) mkdir -p install_temp/assets/info
190# Install architecture independents to assets/etc and assets/lisp
191 $(AM_V_SILENT) cp -r $(top_srcdir)/lisp install_temp/assets
192 $(AM_V_SILENT) cp -r $(top_srcdir)/etc install_temp/assets
193 $(AM_V_SILENT) cp -r $(top_srcdir)/info install_temp/assets
194# Replace etc/DOC generated by compiling Emacs for the build machine
195# with etc/DOC from the cross-compiled Emacs.
196 $(AM_V_SILENT) test -f $(top_builddir)/cross/etc/DOC \
197 && cp -r $(top_builddir)/cross/etc/DOC \
198 install_temp/assets/etc
199# Remove undesirable files from those directories.
200 $(AM_V_SILENT) \
201 for subdir in `find install_temp -type d -print`; do \
202 chmod a+rx $${subdir} ; \
203 rm -rf $${subdir}/.gitignore ; \
204 rm -rf $${subdir}/.DS_Store ; \
205 rm -rf $${subdir}/#* ; \
206 rm -rf $${subdir}/.#* ; \
207 rm -rf $${subdir}/*~ ; \
208 rm -rf $${subdir}/*.orig ; \
209 rm -rf $${subdir}/ChangeLog* ; \
210 rm -rf $${subdir}/[mM]akefile*[.-]in ; \
211 rm -rf $${subdir}/Makefile; \
212 done
213# Generate the directory tree for those directories.
214# Install architecture dependents to lib/$(ANDROID_ABI). This
215# perculiar naming scheme is required to make Android preserve these
216# binaries upon installation.
217 $(AM_V_SILENT) \
218 for file in $(CROSS_BINS); do \
219 if [ -x $$file ]; then \
220 filename=`basename $$file`; \
221 cp -f $$file install_temp/lib/$(ANDROID_ABI)/lib$${filename}.so; \
222 fi \
223 done
224 $(AM_V_SILENT) \
225 for file in $(CROSS_LIBS); do \
226 if [ -x $$file ]; then \
227 cp -f $$file install_temp/lib/$(ANDROID_ABI); \
228 fi \
229 done
230ifneq ($(NDK_BUILD_SHARED),)
231 $(AM_V_SILENT) cp -f $(NDK_BUILD_SHARED) \
232 install_temp/lib/$(ANDROID_ABI)
233endif
234
235install_temp/assets/directory-tree: $(libsrc)/asset-directory-tool \
236 install_temp install_temp/assets/version \
237 install_temp/assets/build_info
238 $(AM_V_GEN) $(libsrc)/asset-directory-tool install_temp/assets \
239 install_temp/assets/directory-tree
240
241install_temp/assets/version: install_temp
242 $(AM_V_GEN) { (cd $(top_srcdir) \
243 && git rev-parse HEAD || echo "Unknown") \
244 && (git rev-parse --abbrev-ref HEAD \
245 || echo "Unknown") } 2> /dev/null > $@
246
247install_temp/assets/build_info: install_temp
248 $(AM_V_GEN) { hostname; date +%s; } > $@
249
250emacs.apk-in: install_temp install_temp/assets/directory-tree \
251 AndroidManifest.xml install_temp/assets/version \
252 install_temp/assets/build_info
253# Package everything. Specifying the assets on this command line is
254# necessary for AAssetManager_getNextFileName to work on old versions
255# of Android. Make sure not to generate R.java, as it's already been
256# generated.
257 $(AM_V_AAPT) $(AAPT) p -I "$(ANDROID_JAR)" -F $@ \
258 -f -M AndroidManifest.xml $(AAPT_ASSET_ARGS) \
259 -A install_temp/assets \
260 -S $(top_srcdir)/java/res -J install_temp
261 $(AM_V_SILENT) pushd install_temp &> /dev/null; \
262 $(AAPT) add ../$@ `find lib -type f`; \
263 popd &> /dev/null
264 $(AM_V_SILENT) rm -rf install_temp
265
266# Makefile itself.
267.PRECIOUS: $(top_srcdir)/config.status Makefile
268$(top_srcdir)/config.status: $(top_srcdir)/configure.ac $(top_srcdir)/m4/*.m4
269 $(MAKE) -C $(dir $@) $(notdir $@)
270Makefile: $(top_srcdir)/config.status $(top_srcdir)/java/Makefile.in
271 $(MAKE) -C .. java/$@
272
273# AndroidManifest.xml:
274AndroidManifest.xml: $(top_srcdir)/configure.ac $(top_srcdir)/m4/*.m4 \
275 $(srcdir)/AndroidManifest.xml.in
276 pushd ..; ./config.status java/AndroidManifest.xml; popd
277
278# R.java:
279$(RESOURCE_FILE): $(RESOURCE_FILES)
280 $(AM_V_GEN) $(AAPT) p -I "$(ANDROID_JAR)" -f \
281 -J $(dir $@) -M AndroidManifest.xml \
282 -S $(top_srcdir)/java/res
283
284# Make all class files depend on R.java being built.
285$(CLASS_FILES): $(RESOURCE_FILE)
286
287.SUFFIXES: .java .class
288$(CLASS_FILES) &: $(JAVA_FILES)
289 $(AM_V_JAVAC) $(JAVAC) $(JAVAFLAGS) $(JAVA_FILES)
290 $(AM_V_SILENT) touch $(CLASS_FILES)
291
292# N.B. that find must be called all over again in case javac generated
293# nested classes.
294
295classes.dex: $(CLASS_FILES)
296 $(AM_V_D8) $(D8) --classpath $(ANDROID_JAR) \
297 $(subst $$,\$$,$(shell find $(srcdir) -type f \
298 -name *.class)) --output $(builddir)
299
300# When emacs.keystore expires, regenerate it with:
301#
302# keytool -genkey -v -keystore emacs.keystore -alias "Emacs keystore" \
303# -keyalg RSA -sigalg SHA1withRSA -keysize 2048 -validity 100000
304
305.PHONY: clean maintainer-clean
306
307$(APK_NAME): classes.dex emacs.apk-in $(srcdir)/emacs.keystore
308 $(AM_V_GEN)
309 $(AM_V_SILENT) cp -f emacs.apk-in $@.unaligned
310 $(AM_V_SILENT) $(AAPT) add $@.unaligned classes.dex
311 $(AM_V_SILENT) $(JARSIGNER) $(SIGN_EMACS) $@.unaligned "Emacs keystore"
312 $(AM_V_SILENT) $(ZIPALIGN) -f 4 $@.unaligned $@
313# Signing must happen after alignment!
314 $(AM_V_SILENT) $(APKSIGNER) $(SIGN_EMACS_V2) $@
315 $(AM_V_SILENT) rm -f $@.unaligned *.idsig
316
317# TAGS generation.
318
319ETAGS = $(top_builddir)/lib-src/etags
320
321$(ETAGS): FORCE
322 $(MAKE) -C ../lib-src $(notdir $@)
323
324tagsfiles = $(JAVA_FILES) $(RESOURCE_FILE)
325
326.PHONY: tags FORCE
327tags: TAGS
328TAGS: $(ETAGS) $(tagsfiles)
329 $(AM_V_GEN) $(ETAGS) $(tagsfiles)
330
331clean:
332 rm -f *.apk emacs.apk-in *.dex *.unaligned *.class *.idsig
333 rm -rf install-temp $(RESOURCE_FILE) TAGS
334 find . -name '*.class' $(FIND_DELETE)
335
336maintainer-clean distclean bootstrap-clean: clean
337 rm -f Makefile ndk-build.mk