Make sure Android builds are redumped upon changes to shortlisp

* build-aux/makecounter.sh: New script.
* src/Makefile.in (abs_top_builddir): New variable.
(BUILD_COUNTER_OBJ): Define to build-counter.o
if compiling for Android.
(build-counter.c): New target.  Generate this file using
makecounter.sh upon changes to lisp.mk or shortlisp.
(lisp.mk): Make and load relative to abs_top_builddir.
(emacs$(EXEEXT)): Adjust acordingly.
(mostlyclean): Remove build-counter.c.
This commit is contained in:
Po Lu 2023-07-19 09:53:58 +08:00
parent 5a3de76532
commit 69828fba28
2 changed files with 69 additions and 5 deletions

43
build-aux/makecounter.sh Executable file
View file

@ -0,0 +1,43 @@
#!/bin/sh
# Generate or update a C file containing an increasing counter
# variable.
#
# 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/>.
set -e
curcount=
if test -f "$1"; then
curcount=`cat "$1" | grep = | cut -d= -f2 \
| sed -e 's/;//' -e 's/ //'`
fi
curcount=`expr 1 + $curcount 2>/dev/null || echo 0`
cat > $1 <<EOF
/* Generated automatically by makecounter.sh. Do not edit! */
#include <config.h>
#ifdef HAVE_ANDROID
#define EXPORT __attribute__ ((visibility ("default")))
#endif /* HAVE_ANDROID */
#ifdef EXPORT
EXPORT
#endif /* EXPORT */
int counter = $curcount;
EOF

View file

@ -43,6 +43,10 @@ vpath %.c := $(srcdir)
vpath %.h := $(srcdir)
endif
# abs_top_builddir is the name of the toplevel build directory under
# cross-compiled builds.
abs_top_builddir = @abs_top_builddir@
CC = @CC@
CXX = @CXX@
CFLAGS = @CFLAGS@
@ -510,9 +514,22 @@ PRE_ALLOC_OBJ=@PRE_ALLOC_OBJ@
## lastfile.o on Cygwin and MinGW, empty elsewhere.
POST_ALLOC_OBJ=@POST_ALLOC_OBJ@
## Builds using libemacs.so (Android) don't dump Emacs within this
## Makefile, but on device. Make sure the library hash changes for
## each change in shortlisp by linking an object that changes
## accordingly to it.
BUILD_COUNTER_OBJ =
ifeq ($(XCONFIGURE),android)
BUILD_COUNTER_OBJ = build-counter.o
# This file is then compiled into build-counter.so
build-counter.c: $(abs_top_builddir)/src/lisp.mk $(shortlisp)
$(AM_V_GEN) $(top_srcdir)/build-aux/makecounter.sh $@
endif
## List of object files that make-docfile should not be told about.
otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \
$(POST_ALLOC_OBJ) $(WIDGET_OBJ) $(LIBOBJS)
$(POST_ALLOC_OBJ) $(WIDGET_OBJ) $(LIBOBJS) $(BUILD_COUNTER_OBJ)
## All object files linked into temacs. $(VMLIMIT_OBJ) should be first.
## (On MinGW, firstfile.o should be before vm-limit.o.)
@ -565,15 +582,19 @@ endif
## we need to remove leim-list, site-init, and site-load by hand.
## There's not much to choose between these two approaches,
## but the second one seems like it could be more future-proof.
##
## This list is placed in the toplevel build directory to prevent it
## from being unnecessarily regenerated by the successive use of this
## Makefile within cross/Makefile.
shortlisp =
lisp.mk: $(lispsource)/loadup.el
$(abs_top_builddir)/src/lisp.mk: $(lispsource)/loadup.el
${AM_V_GEN}( printf 'shortlisp = \\\n'; \
sed -n 's/^[ \t]*(load "\([^"]*\)".*/\1/p' $< | \
sed -e 's/$$/.elc \\/' -e 's/\.el\.elc/.el/'; \
echo "" ) > $@.tmp
$(AM_V_at)mv -f $@.tmp $@
-include lisp.mk
-include $(abs_top_builddir)/src/lisp.mk
shortlisp_filter = leim/leim-list.el site-load.elc site-init.elc
shortlisp := $(filter-out ${shortlisp_filter},${shortlisp})
## Place loaddefs.el first, so it gets generated first, since it is on
@ -640,7 +661,7 @@ SYSTEM_TYPE = @SYSTEM_TYPE@
## since not all pieces are used on all platforms. But DOC depends
## on all of $lisp, and emacs depends on DOC, so it is ok to use $lisp here.
emacs$(EXEEXT): temacs$(EXEEXT) \
lisp.mk $(etc)/DOC $(lisp) \
$(abs_top_builddir)/src/lisp.mk $(etc)/DOC $(lisp) \
$(lispsource)/international/charprop.el ${charsets}
ifeq ($(SYSTEM_TYPE),cygwin)
find ${top_builddir} -name '*.eln' | rebase -v -O -T -
@ -808,7 +829,7 @@ ns-app: emacs$(EXEEXT) $(pdmp)
mostlyclean:
rm -f android-emacs libemacs.so
rm -f temacs$(EXEEXT) core ./*.core \#* ./*.o
rm -f temacs$(EXEEXT) core ./*.core \#* ./*.o build-counter.c
rm -f dmpstruct.h
rm -f emacs.pdmp
rm -f ../etc/DOC