# You should have received a copy of the GNU General Public License
# along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
-# This file is included all over the place to build prerequisites.
+# This file is included all over the place to get and build
+# prerequisites.
NDK_BUILD_MODULES = @NDK_BUILD_MODULES@
NDK_BUILD_CXX_SHARED = @NDK_BUILD_CXX_SHARED@
# imports a module and also declares it in LOCAL_SHARED_LIBRARIES.
NDK_BUILD_MODULES := $(call uniqify,$(NDK_BUILD_MODULES))
+# Here are all of the files to build.
+NDK_BUILD_ALL_FILES := $(foreach file,$(NDK_BUILD_MODULES), \
+ $(top_builddir)/cross/ndk-build/$(file))
+
# The C++ standard library must be extracted from the Android NDK
# directories and included in the application package, if any module
# requires the C++ standard library.
endif
define subr-1
-
-$(top_builddir)/cross/ndk-build/$(1):
- $(MAKE) -C $(top_builddir)/cross/ndk-build $(1)
-
ifeq ($(suffix $(1)),.so)
NDK_BUILD_SHARED += $(top_builddir)/cross/ndk-build/$(1)
else
NDK_BUILD_STATIC += $(top_builddir)/cross/ndk-build/$(1)
endif
endif
-
endef
# Generate rules for each module.
$(foreach module,$(NDK_BUILD_MODULES),$(eval $(call subr-1,$(module))))
+
+# Generate rules to build everything now.
+# Make sure to use the top_builddir currently defined.
+
+NDK_TOP_BUILDDIR := $(top_builddir)
+$(NDK_BUILD_ALL_FILES) &:
+ $(MAKE) -C $(NDK_TOP_BUILDDIR)/cross/ndk-build $(NDK_BUILD_MODULES)
all: $(APK_NAME)
# Binaries to cross-compile.
-CROSS_BINS = ../cross/src/android-emacs ../cross/lib-src/ctags \
- ../cross/lib-src/hexl ../cross/lib-src/movemail \
- ../cross/lib-src/ebrowse ../cross/lib-src/emacsclient \
- ../cross/lib-src/etags
+CROSS_SRC_BINS = $(top_builddir)/cross/src/android-emacs
+CROSS_LIBSRC_BINS = $(top_builddir)/cross/lib-src/ctags \
+ $(top_builddir)/cross/lib-src/hexl \
+ $(top_builddir)/cross/lib-src/movemail \
+ $(top_builddir)/cross/lib-src/ebrowse \
+ $(top_builddir)/cross/lib-src/emacsclient \
+ $(top_builddir)/cross/lib-src/etags
+CROSS_BINS = $(CROSS_SRC_BINS) $(CROSS_LIBSRC_BINS)
# Libraries to cross-compile.
-CROSS_LIBS = ../cross/src/libemacs.so
+CROSS_LIBS = $(top_builddir)/cross/src/libemacs.so
# Make sure gnulib is built first!
# If not, then the recursive invocations of make below will try to
# build gnulib at the same time.
-CROSS_ARCHIVES = ../cross/lib/libgnu.a
+CROSS_ARCHIVES = $(top_builddir)/cross/lib/libgnu.a
# Third party libraries to compile.
include $(top_builddir)/cross/ndk-build/ndk-build.mk
.PHONY: $(CROSS_BINS) $(CROSS_LIBS) $(CROSS_ARCHIVES)
-../cross/src/android-emacs ../cross/src/libemacs.so: $(CROSS_ARCHIVES)
- $(MAKE) -C ../cross src/$(notdir $@)
-
-../cross/lib-src/hexl ../cross/lib-src/movemail \
-../cross/lib-src/ctags ../cross/lib-src/ebrowse &: $(CROSS_ARCHIVES)
- $(MAKE) -C ../cross lib-src/$(notdir $@)
-
-../cross/lib/libgnu.a:
- $(MAKE) -C ../cross lib/libgnu.a
+# There should only be a single invocation of $(MAKE) -C
+# $(top_srcdir)/cross for each directory under $(top_srcdir)/cross.
+$(CROSS_SRC_BINS) $(CROSS_LIBS) &: $(CROSS_ARCHIVES)
+ $(MAKE) -C $(top_builddir)/cross $(foreach file, \
+ $(CROSS_SRC_BINS) \
+ $(CROSS_LIBS), \
+ src/$(notdir $(file)))
+
+$(CROSS_LIBSRC_BINS) &: $(CROSS_ARCHIVES)
+ $(MAKE) -C $(top_builddir)/cross $(foreach file, \
+ $(CROSS_LIBSRC_BINS), \
+ lib-src/$(notdir $(file)))
+
+$(CROSS_ARCHIVES):
+ $(MAKE) -C $(top_builddir)/cross lib/libgnu.a
# This is needed to generate the ``.directory-tree'' file used by the
# Android emulations of readdir and faccessat.