From: Po Lu Date: Sat, 4 Mar 2023 05:38:00 +0000 (+0800) Subject: Port to broken Android NDK version X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=39a7e6b79fdeafc539a36f6831d922a2622cb679;p=emacs.git Port to broken Android NDK version * configure.ac: Check for __ctype_get_mb_cur_max. Then see if MB_CUR_MAX is defined to it, and define REPLACEMENT_MB_CUR_MAX if so and it does not link. * java/INSTALL: Update documentation. * src/conf_post.h (MB_CUR_MAX): Define replacement if necessary. --- diff --git a/configure.ac b/configure.ac index e15d0c7ef39..3a9d2614c00 100644 --- a/configure.ac +++ b/configure.ac @@ -7383,6 +7383,35 @@ fi AC_SUBST([WINDOW_SYSTEM_OBJ]) +# Some systems have MB_CUR_MAX defined to a call to +# __ctype_get_mb_cur_max, but do not have __ctype_get_mb_cur_max in +# libc. Check for that situation and define MB_CUR_MAX to something +# sane. + +AC_CHECK_FUNC([__ctype_get_mb_cur_max]) + +AC_CACHE_CHECK([whether MB_CUR_MAX is defined to function that won't link], + [emacs_cv_broken_mb_cur_max], + [AC_EGREP_CPP(__ctype_get_mb_cur_max, [ +#include +#ifndef MB_CUR_MAX +#define MB_CUR_MAX -1 +#endif +static int foo = MB_CUR_MAX; +], [AS_IF([test "$ac_cv_func___ctype_get_mb_cur_max" = "yes"], + [emacs_cv_broken_mb_cur_max=no], + [emacs_cv_broken_mb_cur_max=yes])], + [emacs_cv_broken_mb_cur_max=no])]) + +AS_IF([test "$emacs_cv_broken_mb_cur_max" = "yes"], + # Define this to 4, which is right for Android. + [AS_CASE([$opsys], [android], + [AC_DEFINE([REPLACEMENT_MB_CUR_MAX], [4], + [Define to MB_CUR_MAX if stdlib.h is broken.])], + [AC_MSG_ERROR([MB_CUR_MAX does not work on your system. +Please modify configure.ac to set an appropriate value, then +send your change to bug-gnu-emacs@gnu.org])])]) + AH_TOP([/* GNU Emacs site configuration template file. Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2021 diff --git a/java/INSTALL b/java/INSTALL index b331d09d9ff..37f7048b89d 100644 --- a/java/INSTALL +++ b/java/INSTALL @@ -129,6 +129,15 @@ so: ./configure --with-ndk-cxx=/path/to/toolchain/bin/i686-linux-android-g++ +Some versions of the NDK have a bug, where GCC fails to locate +``stddef.h'' after being copied to a standalone toolchain. To work +around this problem (which normally exhibits itself when building C++ +code), add: + + -isystem /path/to/toolchain/include/c++/4.9.x + +to ANDROID_CFLAGS. + DEBUG AND RELEASE BUILDS diff --git a/src/conf_post.h b/src/conf_post.h index 0d5f90a6910..506ddc11270 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -461,3 +461,12 @@ extern int emacs_setenv_TZ (char const *); #else # define UNINIT /* empty */ #endif + +/* MB_CUR_MAX is often broken on systems which copy-paste LLVM + headers, so replace its definition with a working one if + necessary. */ + +#ifdef REPLACEMENT_MB_CUR_MAX +#include +#define MB_CUR_MAX REPLACEMENT_MB_CUR_MAX +#endif /* REPLACEMENT_MB_CUR_MAX */