summaryrefslogtreecommitdiff
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
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.
-rw-r--r--INSTALL.android14
-rw-r--r--build-aux/ndk-build-helper-1.mk2
-rw-r--r--build-aux/ndk-build-helper-2.mk2
-rw-r--r--build-aux/ndk-build-helper-4.mk1
-rw-r--r--configure.ac35
-rw-r--r--cross/ndk-build/ndk-clear-vars.mk1
-rw-r--r--cross/ndk-build/ndk-resolve.mk51
-rw-r--r--src/Makefile.in3
8 files changed, 86 insertions, 23 deletions
diff --git a/INSTALL.android b/INSTALL.android
index 267a3910e30..d84d20b533b 100644
--- a/INSTALL.android
+++ b/INSTALL.android
@@ -187,6 +187,8 @@ Android systems:
gnutls, gmp - https://sourceforge.net/projects/android-ports-for-gnu-emacs
(Please see the section GNUTLS near the end of this file.)
+ libtiff - https://sourceforge.net/projects/android-ports-for-gnu-emacs
+ (Extract and point ``--with-ndk-path'' to tiff-4.5.0-emacs.tar.gz.)
We anticipate that most untested non-trivial ndk-build dependencies
will need adjustments in Emacs to work, as the Emacs build system
@@ -535,8 +537,16 @@ They have only been tested on arm64 Android systems running Android
5.0 or later, so your mileage may vary, especially if you are trying
to build Emacs for another kind of machine.
-To build Emacs with GnuTLS, you must unpack each tar archive in that
-site, and add the resulting folder to ``--with-ndk-path''.
+To build Emacs with GnuTLS, you must unpack each of the following tar
+archives in that site:
+
+ gmp-6.2.1-emacs.tgz
+ gnutls-3.7.8-emacs.tar.gz
+ libtasn1-4.19.0-emacs.tar.gz
+ p11-kit-0.24.1-emacs.tar.gz
+ nettle-3.8-emacs.tar.gz
+
+and add the resulting folders to ``--with-ndk-path''.
diff --git a/build-aux/ndk-build-helper-1.mk b/build-aux/ndk-build-helper-1.mk
index 50def5f1c2d..898edf3a137 100644
--- a/build-aux/ndk-build-helper-1.mk
+++ b/build-aux/ndk-build-helper-1.mk
@@ -59,7 +59,7 @@ else
NDK_SO_NAME = lib$(1)_emacs.so
endif
-ifeq ($$(NDK_SO_NAMES:$$(NDK_SO_NAME)=),$$(NDK_SO_NAMES))
+ifeq ($$(findstring $$(NDK_SO_NAME),$$(NDK_SO_NAMES)),)
NDK_SO_NAMES := $$(NDK_SO_NAMES) $$(NDK_SO_NAME)
# Now recurse over this module's dependencies.
diff --git a/build-aux/ndk-build-helper-2.mk b/build-aux/ndk-build-helper-2.mk
index 3722437c53e..6be7f268fe7 100644
--- a/build-aux/ndk-build-helper-2.mk
+++ b/build-aux/ndk-build-helper-2.mk
@@ -48,7 +48,7 @@ else
NDK_A_NAME = lib$(1).a
endif
-ifeq ($$(NDK_A_NAMES:$$(NDK_A_NAME)=),$$(NDK_A_NAMES))
+ifeq ($$(findstring $$(NDK_A_NAME),$$(NDK_A_NAMES)),)
NDK_A_NAMES := $$(NDK_A_NAMES) $$(NDK_A_NAME)
# Now recurse over this module's dependencies.
diff --git a/build-aux/ndk-build-helper-4.mk b/build-aux/ndk-build-helper-4.mk
index e1024f0a243..a41679c53af 100644
--- a/build-aux/ndk-build-helper-4.mk
+++ b/build-aux/ndk-build-helper-4.mk
@@ -34,5 +34,6 @@ 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/configure.ac b/configure.ac
index 35e71ecb93c..0739c73703d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1062,6 +1062,7 @@ package will likely install on older systems but crash on startup.])
passthrough="$passthrough --with-xml2=$with_xml2"
passthrough="$passthrough --with-sqlite3=$with_sqlite3"
passthrough="$passthrough --with-gnutls=$with_gnutls"
+ passthrough="$passthrough --with-tiff=$with_tiff"
AS_IF([XCONFIGURE=android ANDROID_CC="$ANDROID_CC" \
ANDROID_SDK="$android_sdk" android_abi=$android_abi \
@@ -1120,7 +1121,6 @@ if test "$ANDROID" = "yes"; then
# disabled, both within the recursive invocation of configure and
# outside.
with_xpm=no
- with_tiff=no
# Some of these dependencies are now supported within Android, so
# they can be enabled.
@@ -1133,6 +1133,7 @@ if test "$ANDROID" = "yes"; then
with_xml2=no
with_sqlite3=no
with_gnutls=no
+ with_tiff=no
fi
with_rsvg=no
@@ -5028,6 +5029,7 @@ AC_SUBST([PNG_CFLAGS])
### mingw32 doesn't use -ltiff, since it loads the library dynamically.
HAVE_TIFF=no
LIBTIFF=
+TIFF_CFLAGS=
if test "${opsys}" = "mingw32"; then
if test "${with_tiff}" != "no"; then
AC_CHECK_HEADER([tiffio.h], [HAVE_TIFF=yes], [HAVE_TIFF=no])
@@ -5038,24 +5040,37 @@ if test "${opsys}" = "mingw32"; then
fi
elif test "${HAVE_X11}" = "yes" || test "${HAVE_W32}" = "yes" \
|| test "${HAVE_NS}" = "yes" || test "${HAVE_BE_APP}" = "yes" \
- || test "$window_system" = "pgtk"; then
+ || test "$window_system" = "pgtk" \
+ || test "${REALLY_ANDROID}" = "yes"; then
if test "${with_tiff}" != "no"; then
- AC_CHECK_HEADER([tiffio.h],
- [tifflibs="-lz -lm"
- # At least one tiff package requires the jpeg library.
- if test "${HAVE_JPEG}" = yes; then tifflibs="-ljpeg $tifflibs"; fi
- AC_CHECK_LIB([tiff], [TIFFGetVersion], [HAVE_TIFF=yes], [],
- [$tifflibs])])
+ if test "${REALLY_ANDROID}" != "yes"; then
+ AC_CHECK_HEADER([tiffio.h],
+ [tifflibs="-lz -lm"
+ # At least one tiff package requires the jpeg library.
+ if test "${HAVE_JPEG}" = yes; then tifflibs="-ljpeg $tifflibs"; fi
+ AC_CHECK_LIB([tiff], [TIFFGetVersion], [HAVE_TIFF=yes], [],
+ [$tifflibs])])
+ else
+ ndk_SEARCH_MODULE([libtiff], [TIFF], [HAVE_TIFF=yes])
+
+ if test "$HAVE_TIFF" = "yes"; then
+ LIBTIFF="$TIFF_LIBS"
+ fi
+ fi
fi
if test "${HAVE_TIFF}" = "yes"; then
AC_DEFINE([HAVE_TIFF], [1],
[Define to 1 if you have the tiff library (-ltiff).])
- dnl FIXME -lz -lm, as per libpng?
- LIBTIFF=-ltiff
+
+ if test "$REALLY_ANDROID" != "yes"; then
+ dnl FIXME -lz -lm, as per libpng?
+ LIBTIFF=-ltiff
+ fi
fi
fi
AC_SUBST([LIBTIFF])
+AC_SUBST([TIFF_CFLAGS])
### Use -lgif or -lungif if available, unless '--with-gif=no'.
### mingw32 doesn't use -lgif/-lungif, since it loads the library dynamically.
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,)))
diff --git a/src/Makefile.in b/src/Makefile.in
index 0921f6f1f96..f17e34be616 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -140,6 +140,7 @@ LIBIMAGE=@LIBTIFF@ @LIBJPEG@ @LIBPNG@ @LIBGIF@ @LIBXPM@ @WEBP_LIBS@
GIF_CFLAGS=@GIF_CFLAGS@
JPEG_CFLAGS=@JPEG_CFLAGS@
+TIFF_CFLAGS=@TIFF_CFLAGS@
XCB_LIBS=@XCB_LIBS@
XFT_LIBS=@XFT_LIBS@
@@ -436,7 +437,7 @@ EMACS_CFLAGS=-Demacs $(MYCPPFLAGS) -I. -I$(srcdir) \
$(LIBGNUTLS_CFLAGS) $(NOTIFY_CFLAGS) $(CAIRO_CFLAGS) \
$(WERROR_CFLAGS) $(HAIKU_CFLAGS) $(XCOMPOSITE_CFLAGS) $(XSHAPE_CFLAGS) \
$(ANDROID_CFLAGS) $(GIF_CFLAGS) $(JPEG_CFLAGS) $(SQLITE3_CFLAGS) \
- $(LIBGMP_CFLAGS)
+ $(LIBGMP_CFLAGS) $(TIFF_CFLAGS)
ALL_CFLAGS = $(EMACS_CFLAGS) $(WARN_CFLAGS) $(CFLAGS)
ALL_OBJC_CFLAGS = $(EMACS_CFLAGS) \
$(filter-out $(NON_OBJC_CFLAGS),$(WARN_CFLAGS)) $(CFLAGS) \