summaryrefslogtreecommitdiff
path: root/cross
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-01-28 20:47:26 +0800
committerPo Lu <luangruo@yahoo.com>2023-01-28 20:47:26 +0800
commit22749d69e5892896f5ae9d26e7d6c43da67fa13d (patch)
tree848c857ec4fafc07fe921eebaef8bbf3dd6b1cca /cross
parent1ba1f277b6953f07b6449da6b7f074fb82f6f418 (diff)
downloademacs-22749d69e5892896f5ae9d26e7d6c43da67fa13d.tar.gz
Add libtiff support to Android port
* INSTALL.android: Document how to build with libtiff. * build-aux/ndk-build-helper-1.mk (NDK_SO_NAME): * build-aux/ndk-build-helper-2.mk (NDK_A_NAME): * build-aux/ndk-build-helper-4.mk: Decrease number of duplicate dependencies found. * configure.ac (ANDROID_SDK_18_OR_EARLIER, XCONFIGURE, PNG_CFLAGS) (HAVE_TIFF): Allow using libtiff on Android. * cross/ndk-build/ndk-clear-vars.mk: Undefine additional variables. * cross/ndk-build/ndk-resolve.mk: Split CFLAGS resolution from a-name resolution, and do not recursively add archive or shared object names for dependencies of shared libraries. * src/Makefile.in (TIFF_CFLAGS): New variable. (EMACS_CFLAGS): Use it.
Diffstat (limited to 'cross')
-rw-r--r--cross/ndk-build/ndk-clear-vars.mk1
-rw-r--r--cross/ndk-build/ndk-resolve.mk51
2 files changed, 44 insertions, 8 deletions
diff --git a/cross/ndk-build/ndk-clear-vars.mk b/cross/ndk-build/ndk-clear-vars.mk
index 6377f373512..bce5bc895be 100644
--- a/cross/ndk-build/ndk-clear-vars.mk
+++ b/cross/ndk-build/ndk-clear-vars.mk
@@ -39,6 +39,7 @@ undefine LOCAL_DISABLE_FORMAT_STRING_CHECKS
undefine LOCAL_EXPORT_CFLAGS
undefine LOCAL_EXPORT_CPPFLAGS
undefine LOCAL_EXPORT_C_INCLUDES
+undefine LOCAL_EXPORT_C_INCLUDE_DIRS
undefine LOCAL_EXPORT_LDFLAGS
undefine LOCAL_EXPORT_LDLIBS
diff --git a/cross/ndk-build/ndk-resolve.mk b/cross/ndk-build/ndk-resolve.mk
index e2252ebdf8c..b29a2c6dc39 100644
--- a/cross/ndk-build/ndk-resolve.mk
+++ b/cross/ndk-build/ndk-resolve.mk
@@ -36,14 +36,38 @@ NDK_SO_EXTRA_FLAGS_$(LOCAL_MODULE) :=
# List of all dependencies resolved for this module thus far.
# Used to avoid infinite recursion.
+# Separate the variable which lists modules for which CFLAGS
+# have been resolved from the variable which lists modules
+# for which library dependencies have been resolved, in order
+# to catch the case where a library dependency is skipped
+# despite its CFLAGS being added.
NDK_RESOLVED_$(LOCAL_MODULE) :=
+NDK_RESOLVED_CFLAGS_$(LOCAL_MODULE) :=
define ndk-resolve
-ifeq ($(patsubst $(1),,$(NDK_RESOLVED$(LOCAL_MODULE))),$(NDK_RESOLVED$(LOCAL_MODULE)))
-NDK_RESOLVED_$(LOCAL_MODULE) += $(1)
+ifeq ($$(filter $(1)$(and $(3),whole),$$(NDK_RESOLVED_CFLAGS_$(LOCAL_MODULE))),)
+# Always mark this module's cflags as having been resolved, even if
+# this is a whole library.
+NDK_RESOLVED_CFLAGS_$(LOCAL_MODULE) += $(1)
+
NDK_CFLAGS_$(LOCAL_MODULE) += $(NDK_LOCAL_EXPORT_CFLAGS_$(1))
NDK_CFLAGS_$(LOCAL_MODULE) += $(addprefix -I,$(NDK_LOCAL_EXPORT_C_INCLUDES_$(1)))
+endif
+
+ifeq ($$(filter $(1)$(and $(3),whole),$$(NDK_RESOLVED_$(LOCAL_MODULE))),)
+# Now append local libraries, as long as this library isn't a shared
+# library itself.
+ifeq ($(4),)
+
+# Mark this module's library dependencies as having been resolved.
+NDK_RESOLVED_$(LOCAL_MODULE) += $(1)
+
+# If this is a whole library, then mark this as resolved too, and
+# remove the library from the normal static library list.
+ifneq ($(3),)
+NDK_RESOLVED_$(LOCAL_MODULE) += $(1)whole
+endif
# If the module happens to be zlib, then add -lz to the shared library
# flags.
@@ -113,15 +137,26 @@ NDK_WHOLE_A_NAMES_$(LOCAL_MODULE) += $(1).a
else
NDK_WHOLE_A_NAMES_$(LOCAL_MODULE) += lib$(1).a
endif
+
+# Remove this archive from the regular archive list, should it already
+# exists. Any given archive should only appear once, and if an
+# archive has been specified as whole it should always be whole.
+NDK_LOCAL_A_NAMES_$(LOCAL_MODULE) := $$(filter-out lib$(1).a,$$(NDK_LOCAL_A_NAMES_$(LOCAL_MODULE)))
+NDK_LOCAL_A_NAMES_$(LOCAL_MODULE) := $$(filter-out $(1).a,$$(NDK_LOCAL_A_NAMES_$(LOCAL_MODULE)))
+endif
endif
-$$(foreach module,$$(NDK_LOCAL_STATIC_LIBRARIES_$(1)),$$(eval $$(call ndk-resolve,$$(module),1,)))
-$$(foreach module,$$(NDK_LOCAL_SHARED_LIBRARIES_$(1)),$$(eval $$(call ndk-resolve,$$(module),,)))
-$$(foreach module,$$(NDK_LOCAL_WHOLE_LIBRARIES_$(1)),$$(eval $$(call ndk-resolve,$$(module),,1)))
+$$(foreach module,$$(NDK_LOCAL_STATIC_LIBRARIES_$(1)),$$(eval $$(call ndk-resolve,$$(module),1,,$(or $(4),$(if $(2)$(3),,1)))))
+$$(foreach module,$$(NDK_LOCAL_SHARED_LIBRARIES_$(1)),$$(eval $$(call ndk-resolve,$$(module),,,$(or $(4),$(if $(2)$(3),,1)))))
+$$(foreach module,$$(NDK_LOCAL_WHOLE_LIBRARIES_$(1)),$$(eval $$(call ndk-resolve,$$(module),,1,$(or $(4),$(if $(2)$(3),,1)))))
endif
endef
-$(foreach module,$(LOCAL_SHARED_LIBRARIES),$(eval $(call ndk-resolve,$(module),,)))
-$(foreach module,$(LOCAL_STATIC_LIBRARIES),$(eval $(call ndk-resolve,$(module),1,)))
-$(foreach module,$(LOCAL_WHOLE_STATIC_LIBRARIES), $(eval $(call ndk-resolve,$(module),,1)))
+# Add shared libraries to the shared object names when they appear as
+# a top level dependency. However, do not recursively add the names
+# of this module's shared library dependencies, if it is just a shared
+# library, since it will link to those shared libraries itself.
+$(foreach module,$(LOCAL_SHARED_LIBRARIES),$(eval $(call ndk-resolve,$(module),,,)))
+$(foreach module,$(LOCAL_STATIC_LIBRARIES),$(eval $(call ndk-resolve,$(module),1,,)))
+$(foreach module,$(LOCAL_WHOLE_STATIC_LIBRARIES), $(eval $(call ndk-resolve,$(module),,1,)))