From a428de468529611c8d7761deb772f95d348a65bb Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 10 Jan 2003 17:25:33 +0000 Subject: [PATCH] Build elisp files all at once instead of one by one. * automake.in (handle_emacs_lisp): Define am__ELFILES. Add elc-stamp to all's dependencies. * lib/am/lisp.am (elc-stamp): New rule, build all *.elc files. (.el.elc): Rewrite to call elc-stamp if $@ doesn't exist. (clean-lisp): Clean elc-stamp. * lib/elisp-comp: Reindent. Erase the temporatry directory from a trap. Propagate Emacs's exit status. * tests/lisp3.test: New file. * tests/Makefile.am (TESTS): Add lisp3.test. Reported by Ryan T. Sammartino. --- ChangeLog | 14 +++++++++ NEWS | 6 ++-- automake.in | 10 +++++-- lib/am/lisp.am | 27 +++++++++++++++--- lib/elisp-comp | 48 +++++++++++++++++-------------- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/lisp3.test | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 151 insertions(+), 29 deletions(-) create mode 100755 tests/lisp3.test diff --git a/ChangeLog b/ChangeLog index 6e43089c..57dacf7c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2003-01-10 Alexandre Duret-Lutz + + Build elisp files all at once instead of one by one. + * automake.in (handle_emacs_lisp): Define am__ELFILES. Add + elc-stamp to all's dependencies. + * lib/am/lisp.am (elc-stamp): New rule, build all *.elc files. + (.el.elc): Rewrite to call elc-stamp if $@ doesn't exist. + (clean-lisp): Clean elc-stamp. + * lib/elisp-comp: Reindent. Erase the temporatry directory + from a trap. Propagate Emacs's exit status. + * tests/lisp3.test: New file. + * tests/Makefile.am (TESTS): Add lisp3.test. + Reported by Ryan T. Sammartino. + 2003-01-09 Akim Demaille * automake.texi: Prefer $(FOO) to @FOO@ in the documentation. diff --git a/NEWS b/NEWS index 43962a52..e1c9e2d0 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ New in 1.7a: +* elisp sources are compiled all at once, instead of one by one. + This allows interdependencies and speed up compilation. * AM_PROG_CC_STDC is now empty. The content of this macro was merged in AC_PROG_CC. If your code uses $am_cv_prog_cc_stdc, you should adjust it to use $ac_cv_prog_cc_stdc instead. @@ -288,8 +290,8 @@ New in 0.20: ----- -Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software -Foundation, Inc. +Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 +Free Software Foundation, Inc. This file is part of GNU Automake. diff --git a/automake.in b/automake.in index 961e887e..65294e3c 100755 --- a/automake.in +++ b/automake.in @@ -4969,8 +4969,14 @@ sub handle_emacs_lisp # Generate .elc files. my @elcfiles = map { $_->[1] . 'c' } @elfiles; define_pretty_variable ('ELCFILES', TRUE, INTERNAL, @elcfiles); - - push (@all, '$(ELCFILES)'); + define_pretty_variable ('am__ELFILES', TRUE, INTERNAL, + map { $_->[1] } @elfiles); + + # It's important that all depends on elc-stamp so that + # all .elc files get recompiled whenever a .el changes. + # It's important that all depends on $(ELCFILES) so that + # we can recover if any of them is deleted. + push (@all, 'elc-stamp', '$(ELCFILES)'); require_variables ($elfiles[0][0], "Emacs Lisp sources seen", TRUE, 'EMACS', 'lispdir'); diff --git a/lib/am/lisp.am b/lib/am/lisp.am index fa7ed030..e9e69458 100644 --- a/lib/am/lisp.am +++ b/lib/am/lisp.am @@ -1,5 +1,6 @@ ## automake - create Makefile.in from Makefile.am -## Copyright 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. +## Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003 +## Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -21,10 +22,28 @@ ## Building. ## ## ---------- ## -.el.elc: +elc-stamp: $(am__ELFILES) @echo 'WARNING: Warnings can be ignored. :-)' if test $(EMACS) != no; then \ - EMACS=$(EMACS) $(SHELL) $(elisp_comp) $<; \ +## Make sure "$@" isn't empty initialy. + set x; \ +## Populate "$@" whith elisp files (found in the current directory +## or in $srcdir). + list='$(am__ELFILES)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + set x "$$@" "$$d$$p"; shift; \ + done; \ +## Finally call elisp-comp for all files. + shift; \ + EMACS=$(EMACS) $(SHELL) $(elisp_comp) "$$@" || exit 1; \ + else : ; fi + touch $@ + +.el.elc: +## Recover from the removal of $@ + @if test ! -f $@; then \ + rm -f elc-stamp; \ + $(MAKE) $(AM_MAKEFLAGS) elc-stamp; \ else : ; fi ## ------------ ## @@ -87,7 +106,7 @@ endif %?INSTALL% .PHONY clean-am: clean-lisp clean-lisp: - -test -z "$(ELCFILES)" || rm -f $(ELCFILES) + -rm -f elc-stamp $(ELCFILES) ## -------------- ## diff --git a/lib/elisp-comp b/lib/elisp-comp index dc7d7ca6..031f00df 100755 --- a/lib/elisp-comp +++ b/lib/elisp-comp @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright 1995 Free Software Foundation, Inc. +# Copyright (C) 1995, 2000, 2003 Free Software Foundation, Inc. # François Pinard , 1995. # # This program is free software; you can redistribute it and/or modify @@ -31,24 +31,30 @@ # they require or load-library one another. if test $# = 0; then - echo 1>&2 "No files given to $0" - exit 1 -else - if test -z "$EMACS" || test "$EMACS" = "t"; then - # Value of "t" means we are running in a shell under Emacs. - # Just assume Emacs is called "emacs". - EMACS=emacs - fi - - tempdir=elc.$$ - mkdir $tempdir - cp $* $tempdir - cd $tempdir - - echo "(setq load-path (cons nil load-path))" > script - $EMACS -batch -q -l script -f batch-byte-compile *.el - mv *.elc .. - - cd .. - rm -fr $tempdir + echo 1>&2 "No files given to $0" + exit 1 fi + +if test -z "$EMACS" || test "$EMACS" = "t"; then + # Value of "t" means we are running in a shell under Emacs. + # Just assume Emacs is called "emacs". + EMACS=emacs +fi + +tempdir=elc.$$ + +# Cleanup the temporary directory on exit. +trap 'status=$?; rm -rf "$tempdir" && exit $status' 0 +trap '(exit $?); exit' 1 2 13 15 + +mkdir $tempdir +cp "$@" $tempdir + +( + cd $tempdir + echo "(setq load-path (cons nil load-path))" > script + $EMACS -batch -q -l script -f batch-byte-compile *.el || exit $? + mv *.elc .. +) || exit $? + +(exit 0); exit diff --git a/tests/Makefile.am b/tests/Makefile.am index 7199dfcc..065d1c37 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -247,6 +247,7 @@ link_f_cxx.test \ link_f_only.test \ lisp.test \ lisp2.test \ +lisp3.test \ listval.test \ location.test \ ltdeps.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 6a3823fe..15620a67 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -340,6 +340,7 @@ link_f_cxx.test \ link_f_only.test \ lisp.test \ lisp2.test \ +lisp3.test \ listval.test \ location.test \ ltdeps.test \ diff --git a/tests/lisp3.test b/tests/lisp3.test new file mode 100755 index 00000000..46e698df --- /dev/null +++ b/tests/lisp3.test @@ -0,0 +1,73 @@ +#! /bin/sh +# Copyright (C) 2003 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake 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 2, or (at your option) +# any later version. +# +# GNU Automake 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 Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# Test that compilings interdependent elisp files works. + +required=emacs +. ./defs || exit 1 + +set -e + +cat > Makefile.am << 'EOF' +lisp_LISP = am-one.el am-two.el am-three.el +EXTRA_DIST = am-one.el am-two.el +am-three.el: + echo "(provide 'am-three)" > $@ +CLEANFILES = am-three.el +EOF + +cat >> configure.in << 'EOF' +AM_PATH_LISPDIR +AC_OUTPUT +EOF + +echo "(require 'am-two)" > am-one.el +echo "(require 'am-three) (provide 'am-two)" > am-two.el +# am-tree.el is a built source + + +$ACLOCAL +$AUTOCONF +$AUTOMAKE --add-missing +./configure + +$MAKE + +test -f am-one.elc +test -f am-two.elc +test -f am-three.elc +test -f elc-stamp + +# Make sure we can recover from a deletion. +rm -f am-one.elc +$MAKE +test -f am-one.elc + +# Make sure we build all files when any of them change. +# (We grep a message to make sure the compilation happens.) +unique=0a3346e2af8a689b85002b53df09142a +sleep 2 +echo "(message \"$unique\")(provide 'am-three)" > am-three.el +$MAKE >output 2>&1 +cat output +grep $unique output + +# It should also work for VPATH-builds. +$MAKE distcheck -- 2.43.5