emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/android 28a9baccd4 2/7: Improve reliability of Android build sys


From: Po Lu
Subject: feature/android 28a9baccd4 2/7: Improve reliability of Android build system
Date: Sat, 14 Jan 2023 09:48:54 -0500 (EST)

branch: feature/android
commit 28a9baccd4c8e997895d3adb3cfce4a11fa29896
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Improve reliability of Android build system
    
    * .gitignore: Add new files.
    * INSTALL.android: New file.
    * Makefile.in (clean_dirs): Clean xcompile as well.
    * admin/merge-gnulib (avoided_flags): Import gnulib into Android
    directory as well.
    * doc/emacs/android.texi (Android):
    * doc/emacs/emacs.texi (Top): New node `Android'.
    * java/org/gnu/emacs/EmacsThread.java (run): Use right
    executable name.
    * lib/Makefile.in (ANDROID_CFLAGS): Use better way to refer to
    /src.
    (vpath): Delete ugly block of vpath statements.
    (mostlyclean): Remove Makefile.android.
    * lib/fpending.c (__fpending):
    * lib/open.c:
    * lib/unistd.c (_GL_UNISTD_INLINE): Revert changes to gnulib in
    lib/.
    * src/android.h:
    * src/androidterm.c: Fix build.
    * xcompile/Makefile.in (LIB_SRCDIR):
    (LIBSRC_BINARIES, src/verbose.mk):
    (PRE_BUILD_DEPS, PHONY): Use gnulib in xcompile/lib/ as opposed
    to lib/.
    * xcompile/README: Adjust README.
---
 .gitignore                          |  27 +++-
 INSTALL.android                     |  76 +++++++++
 Makefile.in                         |   3 +-
 admin/merge-gnulib                  |  11 +-
 doc/emacs/android.texi              | 297 ++++++++++++++++++++++++++++++++++++
 doc/emacs/emacs.texi                |   8 +
 java/org/gnu/emacs/EmacsThread.java |   2 +-
 lib/Makefile.in                     | 121 +--------------
 lib/fpending.c                      |   6 +-
 lib/open.c                          |   4 -
 lib/unistd.c                        |   2 +-
 src/android.h                       |   1 +
 src/androidterm.c                   |   2 +-
 xcompile/Makefile.in                |  96 ++++--------
 xcompile/README                     |   8 +-
 15 files changed, 458 insertions(+), 206 deletions(-)

diff --git a/.gitignore b/.gitignore
index 19eb587673..cf73995840 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,6 +54,7 @@ src/emacs-module.h
 
 # Built by recursive call to `configure'.
 *.android
+!INSTALL.android
 
 # Built by `java'.
 java/install_temp/*
@@ -94,7 +95,31 @@ src/lisp.mk
 src/verbose.mk
 
 # Stuff built during cross compilation
-xcompile/lib/*
+xcompile/lib/alloca.h
+xcompile/lib/assert.h
+xcompile/lib/byteswap.h
+xcompile/lib/dirent.h
+xcompile/lib/errno.h
+xcompile/lib/execinfo.h
+xcompile/lib/fcntl.h
+xcompile/lib/getopt.h
+xcompile/lib/getopt-cdefs.h
+xcompile/lib/gmp.h
+xcompile/lib/ieee754.h
+xcompile/lib/inttypes.h
+xcompile/lib/libgnu.a
+xcompile/lib/limits.h
+xcompile/lib/malloc/*.gl.h
+xcompile/lib/signal.h
+xcompile/lib/std*.h
+xcompile/!lib/std*.in.h
+xcompile/!lib/stdio-impl.h
+xcompile/lib/string.h
+xcompile/lib/sys/
+xcompile/lib/time.h
+xcompile/lib/unistd.h
+xcompile/lib/config.h
+xcompile/lib/gnulib.mk
 xcompile/src/*
 xcompile/lib-src/*
 xcompile/sys/*
diff --git a/INSTALL.android b/INSTALL.android
new file mode 100644
index 0000000000..ee54b053a9
--- /dev/null
+++ b/INSTALL.android
@@ -0,0 +1,76 @@
+Installation instructions for Android
+Copyright (C) 2023 Free Software Foundation, Inc.
+See the end of the file for license conditions.
+
+Please read the entirety of this file before attempting to build Emacs
+as an application package which can run on Android devices.
+
+When building from the source repository, make sure to read
+INSTALL.REPO as well.
+
+
+
+Android is an unusual operating system in that program binaries cannot
+be produced on computers running Android themselves.  Instead, they
+must be built on some other computer using a set of tools known as the
+``Android SDK'' (Software Development Kit) and the ``Android NDK''
+(Native Development Kit).  Appropriate versions of both must be
+obtained to build GNU Emacs; after being built, the generated binaries
+will work on almost all Android devices.  This document does not
+elaborate on how both sets of tools can be obtained.  However, for
+your freedom's sake, you should use the Android SDK provided by the
+Debian project.
+
+In addition to the Android SDK and Android NDK, Emacs also requires
+the Java compiler from OpenJDK 1.7.0 to be installed on your system.
+
+Once all of those tools are obtained, you may invoke the `configure'
+script like so:
+
+  ./configure --with-android=/path/to/android.jar \
+             ANDROID_CC=/path/to/android/ndk/cc  \
+             SDK_BUILD_TOOLS=/path/to/sdk/build/tools
+
+Replacing the paths in the command line above with:
+
+  - the path to the `android.jar' headers which come with the Android
+    SDK.  They must correspond to Android version 13 or later.
+
+  - the path to the C compiler in the Android NDK, for the machine you
+    are building Emacs to run on.
+
+  - the path to the directory in the Android SDK containing binaries
+    such as `aapt' and `d8'.  These are used to build the application
+    package.
+
+After the configuration process completes, you may run:
+
+  make all
+
+Once `make' finishes, there should be a file in the `java' directory
+named along the lines of:
+
+  emacs-<version>-<api-version>-<abi>.apk
+
+where <api-version> is the oldest version of Android that the package
+will run on, and <abi> is the type of Android machine the package was
+built for.
+
+The generated package can be uploaded onto an SD card (or similar
+medium) and installed on-device.
+
+
+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/>.
diff --git a/Makefile.in b/Makefile.in
index 6cf2781a6a..0090b85822 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1012,7 +1012,8 @@ mostlyclean: $(mostlyclean_dirs:=_mostlyclean)
 ###      with them.
 ###
 ###      Delete '.dvi' files here if they are not part of the distribution.
-clean_dirs = $(mostlyclean_dirs) java nextstep admin/charsets admin/unidata
+clean_dirs = $(mostlyclean_dirs) java xcompile nextstep admin/charsets \
+  admin/unidata
 
 $(foreach dir,$(clean_dirs),$(eval $(call submake_template,$(dir),clean)))
 
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index e17ecd95ac..b99e38672a 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -114,6 +114,11 @@ for module in $AVOIDED_MODULES; do
   avoided_flags="$avoided_flags --avoid=$module"
 done
 
+# Clean the lib directory as well.
+if [ -e "$src"/lib/Makefile ]; then
+   make -C "$src"/lib maintainer-clean
+fi
+
 "$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS \
        $avoided_flags $GNULIB_MODULES &&
 rm -- "$src"lib/gl_openssl.h \
@@ -135,4 +140,8 @@ cp -- "$gnulib_srcdir"/lib/af_alg.h \
 { test -z "$src" || cd "$src"; } &&
 ./autogen.sh
 
-echo "Please update the block of vpath statements in lib/Makefile.in"
+# Finally, update the files in lib/ to xcompile/lib.
+rsync "$src"/lib "$src"/xcompile
+
+# Remove unnecessary files.
+rm -f "$src"/xcompile/lib/*.mk.in "$src"/xcompile/lib/Makefile.in
diff --git a/doc/emacs/android.texi b/doc/emacs/android.texi
new file mode 100644
index 0000000000..57ef10de9f
--- /dev/null
+++ b/doc/emacs/android.texi
@@ -0,0 +1,297 @@
+@c This is part of the Emacs manual.
+@c Copyright (C) 2021--2023 Free Software Foundation, Inc.
+@c See file emacs.texi for copying conditions.
+@node Android
+@appendix Emacs and Android
+@cindex Android
+
+  Android is a mobile operating system developed by the Open Handset
+Alliance.  This section describes the peculiarities of using Emacs on
+an Android device running Android 2.2 or later.
+
+@menu
+* What is Android?::   Preamble.
+* Android Startup::     Starting up Emacs on Android.
+* Android File System:: The Android file system.
+* Android Environment:: Running Emacs under Android.
+@end menu
+
+@node What is Android?
+@section Android history
+
+  Android is an operating system for mobile devices developed by the
+Open Handset Alliance, a group of companies interested in developing
+handsets that can run a common set of software.  It is supposedly free
+software.
+
+  Like the X Consortium of times past, the Open Handset Alliance
+believes that ``openness'' (namely, the regular release of the Android
+source code) is simply a tool to increase the popularity of the
+Android platform.  Computer companies normally produce proprietary
+software.  The companies in the Open Handset Alliance are no different
+-- most versions of Android installed on devices are proprietary, by
+virtue of containing proprietary components, that often cannot even be
+replaced by the user.
+
+  Android is not designed to respect users' freedom.  Almost all
+versions of Android (including some which are supposedly free
+software) include support for Digital Restrictions Management,
+technology that is designed to limit users' ability to copy media to
+and from their own devices.  Most Android devices also come with
+proprietary Google applications which are required to run the system,
+and many other Android applications.
+
+  Thus, it must be necessary to consider Android proprietary software
+from a practical standpoint.  That is an injustice.  If you use
+Android, we urge you to switch to a free operating system, if only for
+your freedom's sake.
+
+  We support GNU Emacs on proprietary operating systems because we
+hope this taste of freedom will inspire users to escape from them.
+
+@node Android Startup
+@section Starting up Emacs on Android
+
+  Emacs is not installed on Android devices from source code, or by a
+package manager.  Instead, Emacs is compiled for Android on a
+different operating system, with the resulting binaries packaged into
+an archive, that is then transferred to the device and unpacked.
+
+After being unpacked, Emacs instructs the system to display an
+application icon on the desktop.  Emacs then starts up once the
+application icon is clicked.
+
+@cindex ``adb logcat''
+
+During startup, Emacs will display messages in the system log buffer;
+reading that buffer requires the Android Debug Bridge (@code{adb})
+utility to be installed on another computer; it cannot be read on the
+computer running Android itself.
+
+After enabling the ``USB Debugging'' feature on the Android system,
+and connecting it via USB to another system with the @code{adb}
+utility installed, the log can be viewed by running the following
+command on that other system:
+
+@example
+$ adb logcat | grep -E "(android_run_debug_thread|[Ee]macs)"
+@end example
+
+@node Android File System
+@section What files Emacs can access under Android
+@cindex /assets directory, android
+
+  Emacs exposes a special directory on Android systems: the name of
+the directory is @file{/assets}, and it contains the @file{etc},
+@file{lisp} and @file{info} directories which are normally installed
+in @file{/usr/share/emacs} directory on GNU and Unix systems.
+
+@cindex limitations of the /assets directory
+
+This directory exists because Android does not extract the contents of
+application packages on to the file system while unpacking them, but
+instead requires programs like Emacs to access its contents using a
+special ``asset manager'' interface.  Here are the peculiarities that
+result from such an implementation:
+
+@itemize @bullet
+@item
+Subprocesses (such as @command{ls}) can not run from the
+@file{/assets} directory, so Dired, and functions such as
+@code{list-directory} do not work.
+
+@item
+There are no @file{.} and @file{..} directories inside the
+@file{/assets} directory.
+
+@item
+Files in the @file{/assets} directory are always read only, and have
+to be completely read in to memory each time they are opened.
+
+@item
+@code{directory-files} does not return a useful value on the
+@file{/assets} directory itself, and does not return subdirectories
+inside subdirectories of the @file{/assets} directory.
+@end itemize
+
+  Aside from the @file{/assets} directory, Android programs normally
+have access to three other directories.  They are:
+
+@itemize @bullet
+@item
+The @dfn{app data} directory.  This also serves as the home directory
+for Emacs, and is always accessible read-write.
+
+@item
+The @dfn{app library} directory.  This is automatically appended to
+@code{exec-path} upon startup.
+
+@item
+The @dfn{external storage} directory.  This is accessible to Emacs
+when the user grants the @code{Files and media} permission to Emacs
+via system settings.
+@end itemize
+
+The external storage directory is found at @file{/sdcard}; the other
+directories are not found at any fixed location.
+
+@node Android Environment
+@section Running Emacs under Android
+
+  From the perspective of users, Android is mostly a single user
+operating system; however, from the perspective of applications and
+Emacs, the system has an overwhelming number of users!
+
+  Each application runs in its own user, with his own home directory,
+which is the app data directory (@pxref{Android File System}.)
+
+  Each application is also prohibited from accessing system
+directories, and the app data directories of other applications.  In
+recent versions of Android, the system also prohibits, for security
+reasons, even Emacs itself from running executables inside the app
+data directory!
+
+  Emacs comes with several binaries.  While being executable files,
+they are packaged as libraries in the library directory, because
+otherwise the system will not unpack them while Emacs is being
+installed.  This means, instead of specifying @code{ctags} or
+@code{emacsclient} in a subprocess, Lisp code must specify
+@code{libctags.so} or @code{libemacsclient.so} on the commnd line
+instead when starting either of those programs in a subprocess.
+
+@c TODO: remove this limitation.
+  In addition, the @file{/assets} directory containing Emacs start-up
+files is inaccessible to processes not directly created by
+@code{zygote}, the system service responsible for starting
+applications.  This makes it impossible to run Emacs in a subprocess
+within itself.
+
+@section Running Emacs in the background
+@cindex emacs killed, android
+@cindex emacs in the background, android
+
+  Application processes are treated as disposable entities by the
+system.  When all Emacs frames move to the background, Emacs is liable
+to be killed by the system at any time, for the purpose of saving
+resources.  There is currently no easy way to bypass these
+restrictions, aside from keeping Emacs constantly running in the
+foreground.
+
+@section Android permissions
+@cindex external storage, android
+
+  Android also defines a permissions system that determines what
+system services Emacs is allowed to access.  Programs must specify
+what permissions they want; what then happens depends on the version
+of Android being used:
+
+@itemize @bullet
+@item
+On Android 5.1 and earlier, Emacs automatically receives the following
+permissions it has requested upon being installed:
+
+@itemize @minus
+@item
+@code{android.permission.READ_CONTACTS}
+@item
+@code{android.permission.WRITE_CONTACTS}
+@item
+@code{android.permission.VIBRATE}
+@item
+@code{android.permission.ACCESS_COARSE_LOCATION}
+@item
+@code{android.permission.INTERNET}
+@item
+@code{android.permission.SET_WALLPAPER}
+@item
+@code{android.permission.WRITE_EXTERNAL_STORAGE}
+@item
+@code{android.permission.SEND_SMS}
+@item
+@code{android.permission.RECEIVE_SMS}
+@item
+@code{android.permission.RECEIVE_MMS}
+@item
+@code{android.permission.WRITE_SMS}
+@item
+@code{android.permission.READ_SMS}
+@item
+@code{android.permission.NFC}
+@item
+@code{android.permission.TRANSMIT_IR}
+@item
+@code{android.permission.READ_PHONE_STATE}
+@item
+@code{android.permission.WAKE_LOCK}
+@item
+@code{android.permission.FOREGROUND_SEVICE}
+@item
+@code{android.permission.REQUEST_INSTALL_PACKAGES}
+@item
+@code{android.permission.REQUEST_DELETE_PACKAGES}
+@item
+@code{android.permission.SYSTEM_ALERT_WINDOW}
+@item
+@code{android.permission.RECORD_AUDIO}
+@item
+@code{android.permission.CAMERA}
+@end itemize
+
+While most of these permissions are left unused by Emacs itself, they
+are declared by Emacs as they could be useful for other programs; for
+example, the permission to access contacts may be useful for EUDC.
+
+@item
+On Android 6.0 and later, Emacs only receives the following
+permissions upon installation:
+
+@itemize @minus
+@item
+@code{android.permission.VIBRATE}
+@item
+@code{android.permission.INTERNET}
+@item
+@code{android.permission.SET_WALLPAPER}
+@item
+@code{android.permission.NFC}
+@item
+@code{android.permission.TRANSMIT_IR}
+@item
+@code{android.permission.WAKE_LOCK}
+@end itemize
+
+Other permissions must be granted by the user through the system
+settings application.  Consult the manufacturer of your device for
+more details, as how to do this varies by device.
+@end itemize
+
+@section Android windowing
+
+  Android has an unusual window system; there, all windows are
+maximized or full-screen, and only one window can be displayed at a
+time.  On larger devices, the system allows up to four windows to be
+tiled on the screen at any time.
+
+Windows on Android do not continue to exist indefinitely after they
+are created.  Instead, the system may choose to terminate windows that
+are not on screen in order to save memory, with the assumption that
+the program will save its contents to disk and restore them later,
+when the user asks to open it again.  As this is obvious not possible
+with Emacs, Emacs separates a frame from a system window.
+
+Each system window created (including the initial window created
+during Emacs startup) is appended to a list of windows that do not
+have associated frames.  When a frame is created, Emacs looks up any
+window within that list, and displays the contents of the frame
+within; if there is no window at all, then one is created.  Likewise,
+when a new window is created by the system, Emacs places the contents
+of any frame that is not already displayed within a window inside.
+When a frame is closed, the corresponding system window is also
+closed.
+
+This strategy works as long as one window is in the foreground.
+Otherwise, Emacs can only run in the background for a limited amount
+of time before the process is killed completely.
+
+@c TODO: write more documentation here about what is supported and
+@c what is not, and fonts.
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index b6d149eb3e..19a99d1deb 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -1256,6 +1256,13 @@ Emacs and Haiku
 * Haiku Basics::        Basic Emacs usage and installation under Haiku.
 * Haiku Fonts::         The various options for displaying fonts on Haiku.
 
+Emacs and Android
+
+* What is Android?::   Preamble.
+* Android Startup::     Starting up Emacs on Android.
+* Android File System:: The Android file system.
+* Android Environment:: Running Emacs under Android.
+
 Emacs and Microsoft Windows/MS-DOS
 
 * Windows Startup::     How to start Emacs on Windows.
@@ -1626,6 +1633,7 @@ Lisp programming.
 @include anti.texi
 @include macos.texi
 @include haiku.texi
+@include android.texi
 @c Includes msdos-xtra.
 @include msdos.texi
 @include gnu.texi
diff --git a/java/org/gnu/emacs/EmacsThread.java 
b/java/org/gnu/emacs/EmacsThread.java
index e9281a1339..0882753747 100644
--- a/java/org/gnu/emacs/EmacsThread.java
+++ b/java/org/gnu/emacs/EmacsThread.java
@@ -36,7 +36,7 @@ public class EmacsThread extends Thread
   {
     String args[];
 
-    args = new String[] { "android-emacs", };
+    args = new String[] { "libandroid-emacs.so", };
 
     /* Run the native code now.  */
     EmacsNative.initEmacs (args);
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 87c1349996..fd730b554e 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -29,121 +29,6 @@ XCONFIGURE = @XCONFIGURE@
 # counterparts.
 ANDROID_CFLAGS = @ANDROID_CFLAGS@
 
-ifneq ($(XCONFIGURE),)
-
-# Set vpath.  Only look for C files and some headers in srcdir:
-# Headers that are generated by gnulib must be spared, or otherwise
-# the versions previously built on the host will be used, if builddir
-# is the same as srcdir.  Following this is a list of files in lib/
-# that are not generated during the gnulib build process.  Please keep
-# it up to date!
-
-vpath _Noreturn.h $(srcdir)
-vpath acl-internal.h $(srcdir)
-vpath acl.h $(srcdir)
-vpath af_alg.h $(srcdir)
-vpath alloca.in.h $(srcdir)
-vpath allocator.h $(srcdir)
-vpath arg-nonnull.h $(srcdir)
-vpath assert.in.h $(srcdir)
-vpath attribute.h $(srcdir)
-vpath binary-io.h $(srcdir)
-vpath byteswap.in.h $(srcdir)
-vpath c++defs.h $(srcdir)
-vpath c-ctype.h $(srcdir)
-vpath c-strcase.h $(srcdir)
-vpath careadlinkat.h $(srcdir)
-vpath cdefs.h $(srcdir)
-vpath cloexec.h $(srcdir)
-vpath close-stream.h $(srcdir)
-vpath count-leading-zeros.h $(srcdir)
-vpath count-one-bits.h $(srcdir)
-vpath count-trailing-zeros.h $(srcdir)
-vpath diffseq.h $(srcdir)
-vpath dirent.h $(srcdir)
-vpath dirent.in.h $(srcdir)
-vpath dynarray.h $(srcdir)
-vpath eloop-threshold.h $(srcdir)
-vpath errno.in.h $(srcdir)
-vpath execinfo.in.h $(srcdir)
-vpath fcntl.in.h $(srcdir)
-vpath filemode.h $(srcdir)
-vpath filename.h $(srcdir)
-vpath filevercmp.h $(srcdir)
-vpath fingerprint.h $(srcdir)
-vpath flexmember.h $(srcdir)
-vpath fpending.h $(srcdir)
-vpath fsusage.h $(srcdir)
-vpath ftoastr.h $(srcdir)
-vpath getopt-cdefs.in.h $(srcdir)
-vpath getopt-core.h $(srcdir)
-vpath getopt-ext.h $(srcdir)
-vpath getopt-pfx-core.h $(srcdir)
-vpath getopt-pfx-ext.h $(srcdir)
-vpath getopt.in.h $(srcdir)
-vpath getopt_int.h $(srcdir)
-vpath gettext.h $(srcdir)
-vpath idx.h $(srcdir)
-vpath ieee754.in.h $(srcdir)
-vpath ignore-value.h $(srcdir)
-vpath intprops-internal.h $(srcdir)
-vpath intprops.h $(srcdir)
-vpath inttypes.in.h $(srcdir)
-vpath libc-config.h $(srcdir)
-vpath limits.in.h $(srcdir)
-vpath malloc/dynarray.h $(srcdir)
-vpath malloc/scratch_buffer.h $(srcdir)
-vpath md5.h $(srcdir)
-vpath min-max.h $(srcdir)
-vpath mini-gmp.h $(srcdir)
-vpath minmax.h $(srcdir)
-vpath mktime-internal.h $(srcdir)
-vpath nproc.h $(srcdir)
-vpath openat-priv.h $(srcdir)
-vpath openat.h $(srcdir)
-vpath pathmax.h $(srcdir)
-vpath regex.h $(srcdir)
-vpath regex_internal.h $(srcdir)
-vpath root-uid.h $(srcdir)
-vpath save-cwd.h $(srcdir)
-vpath scratch_buffer.h $(srcdir)
-vpath sha1.h $(srcdir)
-vpath sha256.h $(srcdir)
-vpath sha512.h $(srcdir)
-vpath sig2str.h $(srcdir)
-vpath signal.in.h $(srcdir)
-vpath stat-time.h $(srcdir)
-vpath stdalign.in.h $(srcdir)
-vpath stdckdint.in.h $(srcdir)
-vpath stddef.in.h $(srcdir)
-vpath stdint.in.h $(srcdir)
-vpath stdio-impl.h $(srcdir)
-vpath stdio.h $(srcdir)
-vpath stdio.in.h $(srcdir)
-vpath stdlib.in.h $(srcdir)
-vpath str-two-way.h $(srcdir)
-vpath strftime.h $(srcdir)
-vpath string.in.h $(srcdir)
-vpath sys_random.in.h $(srcdir)
-vpath sys_select.in.h $(srcdir)
-vpath sys_stat.in.h $(srcdir)
-vpath sys_time.in.h $(srcdir)
-vpath sys_types.in.h $(srcdir)
-vpath tempname.h $(srcdir)
-vpath time-internal.h $(srcdir)
-vpath time.in.h $(srcdir)
-vpath timespec.h $(srcdir)
-vpath u64.h $(srcdir)
-vpath unistd.in.h $(srcdir)
-vpath unlocked-io.h $(srcdir)
-vpath utimens.h $(srcdir)
-vpath verify.h $(srcdir)
-vpath vla.h $(srcdir)
-vpath warn-on-use.h $(srcdir)
-vpath xalloc-oversized.h $(srcdir)
-vpath %.c $(srcdir)
-endif
-
 # Variables substituted by 'configure', and not autogenerated in gnulib.mk,
 # or needed before gnulib.mk is included.
 abs_top_srcdir = @abs_top_srcdir@
@@ -160,7 +45,7 @@ HAVE_NATIVE_COMP = @HAVE_NATIVE_COMP@
 ALL_CFLAGS = \
   $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) $(DEPFLAGS) \
   $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS) $(PROFILING_CFLAGS) $(CFLAGS) \
-  -I. -I../src -I$(srcdir) -I$(srcdir)/../src \
+  -I. -I../src -I$(srcdir) -I$(top_srcdir)/src \
   $(if $(patsubst e-%,,$(notdir $<)),,-Demacs) $(ANDROID_CFLAGS)
 
 ifeq ($(HAVE_NATIVE_COMP),yes)
@@ -244,10 +129,10 @@ clean:
 mostlyclean: clean
        rm -f $(filter-out %-t,$(MOSTLYCLEANFILES))
 distclean bootstrap-clean: mostlyclean
-       rm -f Makefile
+       rm -f Makefile Makefile.android
        rm -fr $(DEPDIR)
 maintainer-clean: distclean
-       rm -f TAGS gnulib.mk
+       rm -f TAGS gnulib.mk gnulib.mk.android
        -rmdir malloc sys 2>/dev/null || true
 
 .PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean
diff --git a/lib/fpending.c b/lib/fpending.c
index 62716b9096..afa840b851 100644
--- a/lib/fpending.c
+++ b/lib/fpending.c
@@ -33,15 +33,13 @@
 size_t
 __fpending (FILE *fp)
 {
-#if defined __ANDROID__
-  return 0;
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-#elif defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
+#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
   /* GNU libc, BeOS, Haiku, Linux libc5 */
   return fp->_IO_write_ptr - fp->_IO_write_base;
-#elif defined __sferror || defined __DragonFly__
+#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, 
Android */
   return fp->_p - fp->_bf._base;
 #elif defined __EMX__                /* emx+gcc */
diff --git a/lib/open.c b/lib/open.c
index 5c95d2b8c3..7ec8fdc35d 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -40,11 +40,7 @@ orig_open (const char *filename, int flags, mode_t mode)
 /* Specification.  */
 /* Write "fcntl.h" here, not <fcntl.h>, otherwise OSF/1 5.1 DTK cc eliminates
    this include because of the preliminary #include <fcntl.h> above.  */
-#ifdef __ANDROID__
-#include <fnctl.h>
-#else
 #include "fcntl.h"
-#endif
 
 #include "cloexec.h"
 
diff --git a/lib/unistd.c b/lib/unistd.c
index 98bdb4e265..be7a825503 100644
--- a/lib/unistd.c
+++ b/lib/unistd.c
@@ -18,5 +18,5 @@
 #include <config.h>
 
 #define _GL_UNISTD_INLINE _GL_EXTERN_INLINE
-#include <unistd.h>
+#include "unistd.h"
 typedef int dummy;
diff --git a/src/android.h b/src/android.h
index cddd315b9a..af1e42ec37 100644
--- a/src/android.h
+++ b/src/android.h
@@ -30,6 +30,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <sys/stat.h>
 #include <dirent.h>
+#include <stdio.h>
 
 #include <android/bitmap.h>
 
diff --git a/src/androidterm.c b/src/androidterm.c
index 220858c0fe..a832531249 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -270,7 +270,7 @@ android_flush_dirty_back_buffer_on (struct frame *f)
       /* If the frame is not already up to date, do not flush buffers
         on input, as that will result in flicker.  */
       || !FRAME_ANDROID_COMPLETE_P (f)
-      && FRAME_ANDROID_NEED_BUFFER_FLIP (f))
+      || !FRAME_ANDROID_NEED_BUFFER_FLIP (f))
     return;
 
   show_back_buffer (f);
diff --git a/xcompile/Makefile.in b/xcompile/Makefile.in
index a63dbc2bb8..ed2b10b91a 100644
--- a/xcompile/Makefile.in
+++ b/xcompile/Makefile.in
@@ -38,7 +38,7 @@ top_builddir = @top_builddir@
 
 # This is possibly the ugliest Makefile ever written!
 
-LIB_SRCDIR = $(realpath $(top_srcdir)/lib)
+LIB_SRCDIR = $(realpath ./lib)
 LIB_TOP_SRCDIR = $(realpath $(top_srcdir))
 
 SRC_SRCDIR = $(realpath $(top_srcdir)/src)
@@ -52,7 +52,7 @@ LIB_SRC_TOP_SRCDIR = $(realpath $(top_src))
 LIBSRC_BINARIES = lib-src/etags lib-src/ctags lib-src/emacsclient \
                  lib-src/ebrowse lib-src/hexl lib-src/movemail
 
-CLEAN_SUBDIRS=lib src lib-src
+CLEAN_SUBDIRS=src lib-src
 
 .PHONY: all
 all: lib/libgnu.a src/libemacs.so src/android-emacs $(LIBSRC_BINARIES)
@@ -68,12 +68,6 @@ src/verbose.mk: verbose.mk.android
        mkdir -p src
        cp -f verbose.mk.android src/verbose.mk
 
-UGLY_HOST_HEADERS = dirent.h stdlib.h sys/random.h limits.h            \
-                   string.h signal.h time.h inttypes.h assert.h        \
-                   stdint.h unistd.h stdlib.h sys/types.h sys/time.h   \
-                   sys/stat.h getopt.h fcntl.h sys/select.h alloca.h   \
-                   stdio.h sys/random.h
-
 # Gnulib, make-fingerprint and make-docfile must be built before
 # entering any of the rules below, or they will get the Android
 # versions of many headers.
@@ -94,38 +88,26 @@ PRE_BUILD_DEPS=$(top_builddir)/lib/libgnu.a         \
               $(top_builddir)/lib-src/make-fingerprint \
               $(top_builddir)/lib-src/make-docfile
 
-.PHONY: lib/libgnu.a
-lib/libgnu.a: src/verbose.mk config.status $(PRE_BUILD_DEPS)
-       mkdir -p lib/deps lib/deps/malloc
-# Temporarily move config.h to config.h.bak and config.h.android to
-# config.h
+lib/config.h: $(top_builddir)/src/config.h.android
        cp -f -p $(top_builddir)/src/config.h.android lib/config.h
-# And the Makefiles.
+
+lib/gnulib.mk: $(top_builddir)/lib/gnulib.mk.android
        cp -f -p $(top_builddir)/lib/gnulib.mk.android lib/gnulib.mk
+       sed -i 's/srcdir =.*$$/srcdir = $(subst /,\/,$(LIB_SRCDIR))/g' \
+         lib/gnulib.mk
+
+lib/Makefile: $(top_builddir)/lib/Makefile.android
        cp -f -p $(top_builddir)/lib/Makefile.android lib/Makefile
-# Next, move srcdir and top_srcdir in the Makefiles copied.
-       sed -i 's/srcdir =.*$$/srcdir = $(subst /,\/,$(LIB_SRCDIR))/g' 
lib/Makefile
        sed -i 's/top_srcdir =.*$$/top_srcdir = $(subst 
/,\/,$(LIB_TOP_SRCDIR))/g' \
          lib/Makefile
-       sed -i 's/srcdir =.*$$/srcdir = $(subst /,\/,$(LIB_SRCDIR))/g' 
lib/gnulib.mk
-# Ugly hack: hide some troublesome headers in $(top_builddir)/lib
-# while building lib.  Otherwise, they will end up overriding the
-# system headers used on Android through #include_next and cause
-# trouble.
-       mkdir -p sys
-       for ugly_header in $(UGLY_HOST_HEADERS); do                     \
-         if [ -e "$(top_builddir)/lib/$$ugly_header" ]; then           \
-           mv -f $(top_builddir)/lib/$$ugly_header $$ugly_header.bak;  \
-         fi                                                            \
-       done
-# And make libgnu.a.  Restore config.h if it fails.
-       -make -C lib libgnu.a
-# Move the hiden headers back
-       for ugly_header in $(UGLY_HOST_HEADERS); do                     \
-         if [ -e "$$ugly_header.bak" ]; then                           \
-           mv -f $$ugly_header.bak $(top_builddir)/lib/$$ugly_header;  \
-         fi                                                            \
-       done
+
+# What is needed to build gnulib.
+LIB_DEPS = lib/config.h lib/gnulib.mk lib/Makefile
+
+.PHONY: lib/libgnu.a
+lib/libgnu.a: src/verbose.mk config.status $(LIB_DEPS) $(PRE_BUILD_DEPS)
+       mkdir -p lib/deps lib/deps/malloc
+       +make -C lib libgnu.a
 
 src/Makefile src/config.h &: $(top_builddir)/src/config.h.android      \
   $(top_builddir)/src/Makefile.android $(PRE_BUILD_DEPS)
@@ -145,32 +127,19 @@ src/Makefile src/config.h &: 
$(top_builddir)/src/config.h.android \
 # that src/Makefile uses the binaries there, instead of any
 # cross-compiled binaries at ./lib-src.
        sed -i 's/libsrc =.*$$/libsrc = \.\.\/\.\.\/lib-src/g' src/Makefile
+# Edit out anything saying -I($(top_srcdir)/lib); that should be
+# covered by -I$(lib)
+       sed -i 's/-I\$$(top_srcdir)\/lib//g' src/Makefile
 
 .PHONY: src/android-emacs src/libemacs.so
 src/android-emacs src/libemacs.so &: src/Makefile src/config.h \
   src/verbose.mk lib/libgnu.a $(PRE_BUILD_DEPS)
-# Ugly hack: hide some troublesome headers in $(top_builddir)/lib
-# while building lib.  Otherwise, they will end up overriding the
-# system headers used on Android through #include_next and cause
-# trouble.
-       mkdir -p sys
-       for ugly_header in $(UGLY_HOST_HEADERS); do                     \
-         if [ -e "$(top_builddir)/lib/$$ugly_header" ]; then           \
-           mv -f $(top_builddir)/lib/$$ugly_header $$ugly_header.bak;  \
-         fi                                                            \
-       done
-# Finally, go into src and make
        +make -C src android-emacs libemacs.so
-# Move the hidden headers back
-       for ugly_header in $(UGLY_HOST_HEADERS); do                     \
-         if [ -e "$$ugly_header.bak" ]; then                           \
-           mv -f $$ugly_header.bak $(top_builddir)/lib/$$ugly_header;  \
-         fi                                                            \
-       done
 
 lib-src/Makefile: $(top_builddir)/lib-src/Makefile.android
        mkdir -p lib-src
        cp -f -p $< $@
+       sed -i 's/-I\$${srcdir}\/\.\.\/lib//g' lib-src/Makefile
 
 .PHONY: $(LIBSRC_BINARIES)
 $(LIBSRC_BINARIES) &: src/verbose.mk $(top_builddir)/$@ lib/libgnu.a   \
@@ -183,27 +152,18 @@ $(LIBSRC_BINARIES) &: src/verbose.mk $(top_builddir)/$@ 
lib/libgnu.a      \
          lib-src/Makefile
 # Edit out SCRIPTS, it interferes with the build.
        sed -i 's/^SCRIPTS=.*$$/SCRIPTS=/g' lib-src/Makefile
-# Ugly hack: hide some troublesome headers in $(top_builddir)/lib
-# while building lib.  Otherwise, they will end up overriding the
-# system headers used on Android through #include_next and cause
-# trouble.
-       mkdir -p sys
-       for ugly_header in $(UGLY_HOST_HEADERS); do                     \
-         if [ -e "$(top_builddir)/lib/$$ugly_header" ]; then           \
-           mv -f $(top_builddir)/lib/$$ugly_header $$ugly_header.bak;  \
-         fi                                                            \
-       done
 # Finally, go into lib-src and make everything being built
        +make -C lib-src $(foreach bin,$(LIBSRC_BINARIES),$(notdir $(bin)))
-# Move the hidden headers back
-       for ugly_header in $(UGLY_HOST_HEADERS); do                     \
-         if [ -e "$$ugly_header.bak" ]; then                           \
-           mv -f $$ugly_header.bak $(top_builddir)/lib/$$ugly_header;  \
-         fi                                                            \
-       done
 
 .PHONY: clean maintainer-clean
 clean:
        rm -rf $(CLEAN_SUBDIRS) *.bak sys
+       if [ -e lib/Makefile ]; then    \
+         make -C lib clean;            \
+       fi
+       rm -rf lib/gnulib.mk lib/Makefile lib/config.h
 
 maintainer-clean: clean
+       if [ -e lib/Makefile ]; then            \
+         make -C lib maintainer-clean;         \
+       fi
diff --git a/xcompile/README b/xcompile/README
index a631b978da..d5282212b7 100644
--- a/xcompile/README
+++ b/xcompile/README
@@ -1,7 +1,3 @@
 This directory holds Makefiles and other required assets to build an
-Emacs binary independently for another toolchain, which is currently
-required when building for Android.
-
-The files here are extremely ugly, and contain rules that cannot be
-interrupted without leaving the build tree in an unsafe state.  At
-some point that should be fixed!
+Emacs binary independently for another toolchain.  It also holds
+another copy of gnulib that may be modified to work on Android.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]