emacs/build-aux/ndk-build-helper-1.mk
Po Lu 54836c47c7 Enable libjpeg on Android
* INSTALL.android: Update documentation.
* build-aux/ndk-build-helper-1.mk: When building shared
libraries, do not link libemacs.so with dependent archive files.
* build-aux/ndk-build-helper-2.mk: Add whole archive
dependencies as well.

* configure.ac (HAVE_JPEG): Enable on Android.

* cross/ndk-build/ndk-build-shared-library.mk: Link the shared
object with archive file dependencies.
* cross/ndk-build/ndk-build-static-library.mk: Build all code
position-independently.
* cross/ndk-build/ndk-resolve.mk: Separately resolve a names of
archive and whole archive dependencies.

* src/Makefile.in (JPEG_CFLAGS): New variable.
(EMACS_CFLAGS): Add it.
2023-01-24 19:10:58 +08:00

76 lines
2.8 KiB
Makefile

# ndk-build-helper-1.mk -- Helper for ndk-build.m4.
# 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/>.
# Print out information now defined. Important details include:
# - list of source files to compile.
# - module export include directories.
# - module export CFLAGS.
# - module export LDFLAGS.
# - module name.
build_kind = shared
NDK_SO_NAMES =
NDK_A_NAMES =
# Record this module's dependencies. This information is used later
# on to recurse over libraries.
NDK_$(LOCAL_MODULE)_STATIC_LIBRARIES := $(LOCAL_STATIC_LIBRARIES) $(LOCAL_WHOLE_STATIC_LIBRARIES)
NDK_$(LOCAL_MODULE)_SHARED_LIBRARIES := $(LOCAL_SHARED_LIBRARIES)
$(info Building $(build_kind))
$(info $(LOCAL_MODULE))
$(info $(addprefix $(ANDROID_MODULE_DIRECTORY)/,$(LOCAL_SRC_FILES) $(LOCAL_SRC_FILES$(EMACS_ABI))))
$(info $(foreach dir,$(LOCAL_EXPORT_C_INCLUDE_DIRS) $(LOCAL_EXPORT_C_INCLUDES),-I$(dir)))
$(info $(LOCAL_EXPORT_CFLAGS))
ifeq ($(LOCAL_MODULE_FILENAME),)
ifeq ($(findstring lib,$(LOCAL_MODULE)),lib)
NDK_SO_NAMES = $(LOCAL_MODULE)_emacs.so
else
NDK_SO_NAMES = lib$(LOCAL_MODULE)_emacs.so
endif
else
NDK_SO_NAMES = $(LOCAL_MODULE_FILENAME).so
endif
define add-so-name
ifeq ($(findstring lib,$(1)),lib)
NDK_SO_NAME = $(1)_emacs.so
else
NDK_SO_NAME = lib$(1)_emacs.so
endif
ifeq ($$(NDK_SO_NAMES:$$(NDK_SO_NAME)=),$$(NDK_SO_NAMES))
NDK_SO_NAMES := $$(NDK_SO_NAMES) $$(NDK_SO_NAME)
# Now recurse over this module's dependencies.
$$(foreach module,$$(filter-out $$(SYSTEM_LIBRARIES), $$(NDK_$(1)_SHARED_LIBRARIES)),$$(eval $$(call add-so-name,$$(module))))
endif
endef
# Resolve additional dependencies based on LOCAL_STATIC_LIBRARIES and
# LOCAL_SHARED_LIBRARIES. Static library dependencies can be ignored
# while building a shared library, as they will be linked in to the
# resulting shared object file later.
SYSTEM_LIBRARIES = z libz libc c
$(foreach module,$(filter-out $(SYSTEM_LIBRARIES), $(LOCAL_SHARED_LIBRARIES)),$(eval $(call add-so-name,$(module))))
$(info $(LOCAL_EXPORT_LDFLAGS) $(abspath $(addprefix $(NDK_BUILD_DIR)/,$(NDK_A_NAMES))) -L$(abspath $(NDK_BUILD_DIR)) $(foreach soname,$(NDK_SO_NAMES),-l:$(soname)))
$(info $(NDK_SO_NAMES))
$(info End)