Skip to content

Commit

Permalink
Generate nt/gnulib.mk from lib/gnulib.mk
Browse files Browse the repository at this point in the history
This was proposed by Paul Eggert <eggert@cs.ucla.edu>,
with the purpose of avoiding manual maintenance of
nt/gnulib.mk.

* nt/gnulib-modules-to-delete.cfg: New file.
* nt/Makefile.in (AM_V_GEN, am__v_GEN_, am__v_GEN_0)
(am__v_GEN_1): New variables.
(${srcdir}/gnulib.mk): Rules to generate gnulib.mk from
lib/gnulib.mk and list of modules in gnulib-modules-to-delete.cfg.

* make-dist (nt): Add gnulib-modules-to-delete.cfg to the list of
files to link.
* configure.ac (GNULIB_MK): Compute the value according to $opsys.
* autogen.sh: Create nt/gnulib.mk if it doesn't exist, before
running autoreconf.
* Makefile.in (gnulib_mk): New variable.
($(srcdir)/nt/gnulib.mk): Rule to produce it.
(AUTOMAKE_INPUTS): Use $(gnulib_mk) instead of a literal file
name.
* .gitignore: Add nt/gnulib.mk.

* src/w32.c (acl_errno_valid): Implement it here, as we no longer
build the acl-permissions module from Gnulib.
  • Loading branch information
Eli-Zaretskii committed Jan 3, 2017
1 parent 134e86b commit 10444dc
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 1,154 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -288,5 +288,6 @@ lib/SYS/
/site-lisp/
nt/emacs.rc
nt/emacsclient.rc
nt/gnulib.mk
src/gdb.ini
/var/
8 changes: 7 additions & 1 deletion Makefile.in
Expand Up @@ -98,6 +98,9 @@ configuration=@configuration@
### The nt/ subdirectory gets built only for MinGW
NTDIR=@NTDIR@

### $(srcdir)/nt/gnulib.mk for MinGW, else $(srcdir)/lib/gnulib.mk
gnulib_mk=@GNULIB_MK@

# 'make' verbosity.
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@

Expand Down Expand Up @@ -451,10 +454,13 @@ $(srcdir)/aclocal.m4: $(ACLOCAL_INPUTS)
cd $(srcdir) && ACLOCAL_PATH='$(ACLOCAL_PATH)' $(ACLOCAL) -I m4

AUTOMAKE_INPUTS = $(srcdir)/aclocal.m4 $(srcdir)/lib/Makefile.am \
$(srcdir)/lib/gnulib.mk
$(gnulib_mk)
$(srcdir)/lib/Makefile.in: $(AUTOMAKE_INPUTS)
cd $(srcdir) && $(AUTOMAKE) --gnu -a -c lib/Makefile

$(srcdir)/nt/gnulib.mk: $(srcdir)/lib/Makefile.in
$(MAKE) -C $(srcdir)/nt gnulib.mk

# Regenerate files that this makefile would have made, if this makefile
# had been built by Automake. The name 'am--refresh' is for
# compatibility with subsidiary Automake-generated makefiles.
Expand Down
7 changes: 6 additions & 1 deletion autogen.sh
Expand Up @@ -220,8 +220,13 @@ Please report any problems with this script to bug-gnu-emacs@gnu.org .'
fi

echo 'Your system has the required tools.'
echo "Running 'autoreconf -fi -I m4' ..."

## Create nt/gnulib.mk if it doesn't exist, as autoreconf will need it.
if test ! -f nt/gnulib.mk; then
sed '/^[^#]/s|^.*$|/^## begin *gnulib module &/,/^## end *gnulib module &/c ## gnulib module & removed|' nt/gnulib-modules-to-delete.cfg | sed -f- lib/gnulib.mk > nt/gnulib.mk
fi

echo "Running 'autoreconf -fi -I m4' ..."

## Let autoreconf figure out what, if anything, needs doing.
## Use autoreconf's -f option in case autoreconf itself has changed.
Expand Down
11 changes: 11 additions & 0 deletions configure.ac
Expand Up @@ -774,6 +774,17 @@ fi
dnl This is used in lib/Makefile.am to use nt/gnulib.mk, the
dnl alternative to lib/gnulib.mk, so as to avoid generating header files
dnl that clash with MinGW.
case $opsys in
mingw32 )
GNULIB_MK='$(srcdir)/nt/gnulib.mk'
;;
* )
GNULIB_MK='$(srcdir)/lib/gnulib.mk'
;;

esac
AC_SUBST([GNULIB_MK])

AM_CONDITIONAL([BUILDING_FOR_WINDOWSNT], [test "x$opsys" = "xmingw32"])

# Avoid gnulib's tests for -lcrypto, so that there's no static dependency on it.
Expand Down
2 changes: 1 addition & 1 deletion make-dist
Expand Up @@ -482,7 +482,7 @@ echo "Making links to 'nt'"
(cd nt
ln emacs-x86.manifest emacs-x64.manifest ../${tempdir}/nt
ln [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt
ln *.in gnulib.mk ../${tempdir}/nt
ln *.in gnulib.mk gnulib-modules-to-delete.cfg ../${tempdir}/nt
ln mingw-cfg.site epaths.nt INSTALL.W64 ../${tempdir}/nt
ln ChangeLog.*[0-9] INSTALL README README.W32 ../${tempdir}/nt)

Expand Down
10 changes: 10 additions & 0 deletions nt/Makefile.in
Expand Up @@ -54,6 +54,11 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =

AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =

AM_V_RC = $(am__v_RC_@AM_V@)
am__v_RC_ = $(am__v_RC_@AM_DEFAULT_V@)
am__v_RC_0 = @echo " RC " $@;
Expand Down Expand Up @@ -255,3 +260,8 @@ runemacs${EXEEXT}: ${srcdir}/runemacs.c $(EMACSRES)
emacs.res ../src/emacs.res: emacs.rc ${srcdir}/icons/emacs.ico \
${srcdir}/icons/hand.cur ${srcdir}/$(EMACS_MANIFEST)
$(AM_V_RC)${WINDRES} -I ${srcdir} -O coff -o $@ $<

${srcdir}/gnulib.mk: ${srcdir}/gnulib-modules-to-delete.cfg ${srcdir}/../lib/gnulib.mk
$(AM_V_GEN)sed '/^[^#]/s|^.*$$|/^## begin *gnulib module &/,/^## end *gnulib module &/c ## gnulib module & removed|' < $< | \
sed -f- ${srcdir}/../lib/gnulib.mk > $@-t && \
${srcdir}/../build-aux/move-if-change $@-t $@
66 changes: 66 additions & 0 deletions nt/gnulib-modules-to-delete.cfg
@@ -0,0 +1,66 @@
# This is the list of modules to be deleted from ../lib/gnulib.mk.
#
# We delete them because they either conflict with MinGW headers or
# headers in nt/inc, or because those modules won't compile with
# MinGW, or because Emacs already has the corresponding facilities as
# part of Emacs sources, and their implementation is incompatible with
# Gnulib's.
#
# In general, do NOT remove anything from ../lib/gnulib.mk that
# doesn't need to be removed, to minimize the differences from
# upstream gnulib.mk and thus make the maintenance easier. Every
# header file whose generation is controlled by configure-time tests
# does NOT need to be removed; instead, force the configure script to
# accept whatever MinGW has to offer, by defining the appropriate
# Autoconf variable in the nt/mingw-cfg.site file. Headers that are
# generated conditionally have the tell-tale "if GL_GENERATE_foo_H"
# condition before their Makefile snippet in this file. Likewise, do
# NOT remove gnulib modules which introduce header files that don't
# exist in MinGW and in nt/inc/, since they cannot possibly clash
# with anything. Gnulib modules that introduce source *.c files also
# need not be removed; if they define functions that could clash with
# the w32 substitutes in Emacs, disable their compilation by defining
# suitable variables in nt/mingw-cfg.site.
# ----------------------------------------------------------------------
#
# Copyright (C) 2017 Free Software Foundation, Inc.
#
# This file 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.
#
# This file 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 this file. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License,
# this file may be distributed as part of a program that
# contains a configuration script generated by Autoconf, under
# the same distribution terms as the rest of that program.
#
acl-permissions
allocator
at-internal
careadlinkat
dirent
dirfd
fcntl
fcntl-h
inttypes-incomplete
mkostemp
pipe2
secure_getenv
signal-h
stdio
stdlib
sys_select
sys_stat
sys_time
sys_types
tempname
unistd

0 comments on commit 10444dc

Please sign in to comment.