automake
[Top][All Lists]
Advanced

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

Re: Bug byte-compiling lisp, automake 1.7.2


From: Alexandre Duret-Lutz
Subject: Re: Bug byte-compiling lisp, automake 1.7.2
Date: Wed, 08 Jan 2003 21:48:49 +0100
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu)

>>> "Ryan" == Ryan T Sammartino <address@hidden> writes:

[...]

 Ryan> I guess what I should have said was "this patch solves
 Ryan> the problem in my particular instance" :)

 Ryan> I see now a little more is needed.

 >> Wouldn't it be better to teach Automake to byte-compile all
 >> files at once rather than one at a time?

 Ryan> Yes.

Here is a proposal.  Could you check whether this solves the
problem in your particular instance ? :)   The patch is against 
CVS HEAD, I'll backport it to branch-1-7 if that's ok.

Aside from compiling all elisp sources at once, this also
updates elisp-comp to resist to ^C and propagate emacs's exit
code (this is needed so the elc-stamp rule doesn't create
elc-stamp on errors.)

I'd also appreciate if someone could review the elisp bits I've
written in the test case.  This looks fine to me, but as I don't
really know emacs-lisp I can't tell for sure.

2003-01-08  Alexandre Duret-Lutz  <address@hidden>

        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.
        (.el.elc): Rewrite to call elc-stamp.
        (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.

Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.199
diff -u -r1.199 NEWS
--- NEWS        5 Dec 2002 09:02:30 -0000       1.199
+++ NEWS        8 Jan 2003 20:37:10 -0000
@@ -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 @@
 
 -----
 
-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.
 
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1414
diff -u -r1.1414 automake.in
--- automake.in 5 Jan 2003 22:51:10 -0000       1.1414
+++ automake.in 8 Jan 2003 20:37:35 -0000
@@ -4969,8 +4969,14 @@
   # Generate .elc files.
   my @elcfiles = map { $_->[1] . 'c' } @elfiles;
   define_pretty_variable ('ELCFILES', TRUE, INTERNAL, @elcfiles);
+  define_pretty_variable ('am__ELFILES', TRUE, INTERNAL,
+                         map { $_->[1] } @elfiles);
 
-  push (@all, '$(ELCFILES)');
+  # 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');
Index: lib/elisp-comp
===================================================================
RCS file: /cvs/automake/automake/lib/elisp-comp,v
retrieving revision 1.5
diff -u -r1.5 elisp-comp
--- lib/elisp-comp      17 Jul 2001 06:00:37 -0000      1.5
+++ lib/elisp-comp      8 Jan 2003 20:37:36 -0000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright 1995 Free Software Foundation, Inc.
+# Copyright (C) 1995, 2000, 2003  Free Software Foundation, Inc.
 # François Pinard <address@hidden>, 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 ..
+  echo 1>&2 "No files given to $0"
+  exit 1
+fi
 
-   cd ..
-   rm -fr $tempdir
+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
Index: lib/am/lisp.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/lisp.am,v
retrieving revision 1.33
diff -u -r1.33 lisp.am
--- lib/am/lisp.am      8 Jul 2002 19:41:23 -0000       1.33
+++ lib/am/lisp.am      8 Jan 2003 20:37:36 -0000
@@ -21,10 +21,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 +105,7 @@
 
 .PHONY clean-am: clean-lisp
 clean-lisp:
-       -test -z "$(ELCFILES)" || rm -f $(ELCFILES)
+       -rm -f elc-stamp $(ELCFILES)
 
 
 ## -------------- ##
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.462
diff -u -r1.462 Makefile.am
--- tests/Makefile.am   3 Dec 2002 20:39:42 -0000       1.462
+++ tests/Makefile.am   8 Jan 2003 20:37:36 -0000
@@ -247,6 +247,7 @@
 link_f_only.test \
 lisp.test \
 lisp2.test \
+lisp3.test \
 listval.test \
 location.test \
 ltdeps.test \
Index: tests/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.in,v
retrieving revision 1.597
diff -u -r1.597 Makefile.in
--- tests/Makefile.in   12 Dec 2002 13:41:00 -0000      1.597
+++ tests/Makefile.in   8 Jan 2003 20:37:38 -0000
@@ -1,7 +1,7 @@
 # Makefile.in generated by automake 1.7a from Makefile.am.
 # @configure_input@
 
-# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
 # Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -340,6 +340,7 @@
 link_f_only.test \
 lisp.test \
 lisp2.test \
+lisp3.test \
 listval.test \
 location.test \
 ltdeps.test \
Index: tests/lisp3.test
===================================================================
RCS file: tests/lisp3.test
diff -N tests/lisp3.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/lisp3.test    8 Jan 2003 20:37:38 -0000
@@ -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

-- 
Alexandre Duret-Lutz





reply via email to

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