emacs/cross/Makefile.in
Po Lu 18f723faa8 Fix parallel compilation of Android port
* cross/Makefile.in ($(top_builddir)/lib/libgnu.a):
* java/Makefile.in (CROSS_LIBS): Explicitly depend on gnulib
to prevent it from being built at the same time from different
jobs.
2023-02-19 20:45:32 +08:00

198 lines
6.7 KiB
Makefile

### @configure_input@
# Copyright (C) 2023 Free Software Foundation, Inc.
# This file is part of GNU Emacs.
# GNU Emacs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# GNU Emacs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-include $(top_builddir)/src/verbose.mk
# Cross-compiling Emacs for Android.
# The cross compiled binaries are built by having ``variant''
# Makefiles generated at configure-time. First,
# $(top_builddir)/src/Makefile.android,
# $(top_builddir)/lib/Makefile.android,
# $(top_builddir)/lib/gnulib.mk.android and
# $(top_builddir)/lib-src/Makefile.android are copied to their usual
# locations in this directory.
# Finally, the following commands are executed in order, to produce
# libgnu.a, various binaries in lib-src, and src/aemacs:
# make -C lib libgnu.a
# make -C lib-src src/aemacs
# make -C src aemacs
# This is possibly the ugliest Makefile ever written!
LIB_SRCDIR = $(realpath ./lib)
LIB_TOP_SRCDIR = $(realpath $(top_srcdir))
SRC_SRCDIR = $(realpath $(top_srcdir)/src)
SRC_TOP_SRCDIR = $(realpath $(top_srcdir))
LIB_SRC_SRCDIR = $(realpath $(top_srcdir)/lib-src)
LIB_SRC_TOP_SRCDIR = $(realpath $(top_src))
# This is a list of binaries to build and install in lib-src.
LIBSRC_BINARIES = lib-src/etags lib-src/ctags lib-src/emacsclient \
lib-src/ebrowse lib-src/hexl lib-src/movemail
CLEAN_SUBDIRS=src lib-src
.PHONY: all
all: lib/libgnu.a src/libemacs.so src/android-emacs $(LIBSRC_BINARIES)
# This Makefile relies on builddir and top_builddir being relative
# paths in *.android.
# This file is used to tell lib/gnulib.mk when
# $(top_srcdir)/config.status changes.
config.status: $(top_srcdir)/config.status
$(AM_V_GEN) touch config.status
src/verbose.mk: verbose.mk.android
$(AM_V_GEN) mkdir -p src
$(AM_V_SILENT) cp -f verbose.mk.android src/verbose.mk
# Gnulib, make-fingerprint and make-docfile must be built before
# entering any of the rules below, or they will get the Android
# versions of many headers.
.PHONY: $(top_builddir)/lib/libgnu.a
$(top_builddir)/lib/libgnu.a:
$(MAKE) -C $(top_builddir)/lib libgnu.a
.PHONY: $(top_builddir)/lib-src/make-fingerprint
$(top_builddir)/lib-src/make-fingerprint: $(top_builddir)/lib/libgnu.a
$(MAKE) -C $(top_builddir)/lib-src make-fingerprint
.PHONY: $(top_builddir)/lib-src/make-docfile
$(top_builddir)/lib-src/make-docfile: $(top_builddir)/lib/libgnu.a
$(MAKE) -C $(top_builddir)/lib-src make-docfile
PRE_BUILD_DEPS=$(top_builddir)/lib/libgnu.a \
$(top_builddir)/lib-src/make-fingerprint \
$(top_builddir)/lib-src/make-docfile
lib/config.h: $(top_builddir)/src/config.h.android
$(AM_V_GEN) cp -f -p $(top_builddir)/src/config.h.android \
lib/config.h
lib/gnulib.mk: $(top_builddir)/lib/gnulib.mk.android
$(AM_V_GEN) cp -f -p $(top_builddir)/lib/gnulib.mk.android \
lib/gnulib.mk
$(AM_V_SILENT) \
sed -i 's/srcdir =.*$$/srcdir = $(subst /,\/,$(LIB_SRCDIR))/g' \
lib/gnulib.mk
lib/Makefile: $(top_builddir)/lib/Makefile.android
$(AM_V_GEN) cp -f -p $(top_builddir)/lib/Makefile.android \
lib/Makefile
$(AM_V_SILENT) \
sed -i 's/top_srcdir =.*$$/top_srcdir = $(subst /,\/,$(LIB_TOP_SRCDIR))/g' \
lib/Makefile
# What is needed to build gnulib.
LIB_DEPS = lib/config.h lib/gnulib.mk lib/Makefile
.PHONY: lib/libgnu.a
lib/libgnu.a: src/verbose.mk config.status $(LIB_DEPS) $(PRE_BUILD_DEPS)
mkdir -p lib/deps lib/deps/malloc
$(MAKE) -C lib libgnu.a
src/Makefile src/config.h &: $(top_builddir)/src/config.h.android \
$(top_builddir)/src/Makefile.android
$(AM_V_GEN)
$(AM_V_SILENT) mkdir -p src src/deps
# Copy config.h to src/
$(AM_V_SILENT) \
cp -f -p $(top_builddir)/src/config.h.android src/config.h
# And the Makefile.
$(AM_V_SILENT) \
cp -f -p $(top_builddir)/src/Makefile.android src/Makefile
# Next, edit srcdir and top_srcdir to the right location.
$(AM_V_SILENT) \
sed -i 's/srcdir =.*$$/srcdir = $(subst /,\/,$(SRC_SRCDIR))/g' src/Makefile
$(AM_V_SILENT) \
sed -i 's/top_srcdir =.*$$/top_srcdir = $(subst /,\/,$(LIB_TOP_SRCDIR))/g' \
src/Makefile
# Edit references to ../admin/unidata to read ../../admin/unidata.
$(AM_V_SILENT) \
sed -i 's/\.\.\/admin\/unidata/..\/..\/admin\/unidata/g' src/Makefile
$(AM_V_SILENT) \
sed -i 's/\.\.\/admin\/charsets/..\/..\/admin\/charsets/g' src/Makefile
# Next, edit libsrc to the location at top_srcdir! It is important
# that src/Makefile uses the binaries there, instead of any
# cross-compiled binaries at ./lib-src.
$(AM_V_SILENT) \
sed -i 's/libsrc =.*$$/libsrc = \.\.\/\.\.\/lib-src/g' src/Makefile
# Edit out anything saying -I($(top_srcdir)/lib); that should be
# covered by -I$(lib)
$(AM_V_SILENT) \
sed -i 's/-I\$$(top_srcdir)\/lib//g' src/Makefile
.PHONY: src/android-emacs src/libemacs.so
src/android-emacs src/libemacs.so &: src/Makefile src/config.h \
src/verbose.mk lib/libgnu.a $(PRE_BUILD_DEPS)
$(MAKE) -C src android-emacs libemacs.so
lib-src/Makefile: $(top_builddir)/lib-src/Makefile.android
$(AM_V_GEN) mkdir -p src lib-src
$(AM_V_SILENT) mkdir -p lib-src
$(AM_V_SILENT) cp -f -p $< $@
$(AM_V_SILENT) sed -i 's/-I\$${srcdir}\/\.\.\/lib//g' lib-src/Makefile
# Next, edit srcdir and top_srcdir to the right location.
$(AM_V_SILENT) \
sed -i 's/srcdir=.*$$/srcdir = $(subst /,\/,$(LIB_SRC_SRCDIR))/g' \
lib-src/Makefile
$(AM_V_SILENT) \
sed -i 's/top_srcdir=.*$$/top_srcdir = $(subst /,\/,$(LIB_SRC_TOP_SRCDIR))/g' \
lib-src/Makefile
# Edit out SCRIPTS, it interferes with the build.
$(AM_V_SILENT) \
sed -i 's/^SCRIPTS=.*$$/SCRIPTS=/g' lib-src/Makefile
.PHONY: $(LIBSRC_BINARIES)
$(LIBSRC_BINARIES) &: src/verbose.mk $(top_builddir)/$@ lib/libgnu.a \
src/config.h lib-src/Makefile $(PRE_BUILD_DEPS)
# Finally, go into lib-src and make everything being built
$(MAKE) -C lib-src $(foreach bin,$(LIBSRC_BINARIES),$(notdir $(bin)))
.PHONY: clean maintainer-clean distclean
clean:
rm -rf $(CLEAN_SUBDIRS) *.bak sys
if [ -e lib/Makefile ]; then \
make -C lib clean; \
fi
rm -rf lib/config.h
make -C ndk-build clean
distclean bootstrap-clean: clean
if [ -e lib/Makefile ]; then \
make -C lib distclean; \
fi
# Just in case.
rm -rf lib/Makefile lib/gnulib.mk ndk-build/Makefile
rm -rf ndk-build/ndk-build.mk Makefile
maintainer-clean: distclean bootstrap-clean
if [ -e lib/Makefile ]; then \
make -C lib maintainer-clean; \
fi