Fix compilation on Android 35 and on Termux

* configure.ac (gl_cv_onwards_func_tzalloc): Define to "future
OS version" on Android API 35 and later.
Detect posix_spawn* by means of gl_CHECK_FUNCS_ANDROID.

* src/conf_post.h (tzalloc, tzfree): Define to non-conflicting
names on Android 35 and later.
This commit is contained in:
Po Lu 2025-05-06 22:29:46 +08:00
parent 852d50ecfc
commit fa05cfd445
2 changed files with 20 additions and 4 deletions

View file

@ -49,6 +49,11 @@ if test "$XCONFIGURE" = "android"; then
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=32"
enable_largefile=no
enable_year2038=no])
# Gnulib should not attempt not to reimplement tzalloc, as strftime
# attempts to link with symbols that are only present in the Gnulib
# replacement.
AS_IF([test "$ANDROID_SDK" -ge "35"],
[gl_cv_onwards_func_tzalloc="future OS version"])
fi
dnl Set emacs_config_options to the options of 'configure', quoted for the shell,
@ -6341,10 +6346,10 @@ dnl posix_spawn. The chdir and setsid functionality is relatively
dnl recent, so we check for it specifically.
AC_CHECK_HEADERS([spawn.h])
AC_SUBST([HAVE_SPAWN_H])
AC_CHECK_FUNCS([posix_spawn \
posix_spawn_file_actions_addchdir \
posix_spawn_file_actions_addchdir_np \
posix_spawnattr_setflags])
gl_CHECK_FUNCS_ANDROID([posix_spawn], [#include <spawn.h>])
gl_CHECK_FUNCS_ANDROID([posix_spawn_file_actions_addchdir], [#include <spawn.h>])
gl_CHECK_FUNCS_ANDROID([posix_spawn_file_actions_addchdir_np], [#include <spawn.h>])
gl_CHECK_FUNCS_ANDROID([posix_spawnattr_setflags], [#include <spawn.h>])
AC_SUBST([HAVE_POSIX_SPAWN])
AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP])

View file

@ -395,3 +395,14 @@ extern int emacs_setenv_TZ (char const *);
: S_ISCHR (mode) ? DT_CHR : S_ISFIFO (mode) ? DT_FIFO \
: S_ISSOCK (mode) ? DT_SOCK : DT_UNKNOWN)
#endif /* MSDOS */
#if defined __ANDROID__ && __ANDROID_API__ >= 35
#define _GL_TIME_H
#include <time.h>
#undef _GL_TIME_H
/* Redefine tzalloc and tzfree so as not to conflict with their
system-provided versions, which are incompatible. */
#define tzalloc rpl_tzalloc
#define tzfree rpl_tzfree
#endif /* defined __ANDROID__ && __ANDROID_API__ >= 35 */