Skip to content

Commit

Permalink
build: no more recursion for lib 'subdir'
Browse files Browse the repository at this point in the history
* Makefile.am (SUBDIRS): Drop 'lib'.
(edit): New, shared among the recipes in 'lib/local.mk' and
'bin/local.mk'.
(CLEANFILES): New, will be updated later in included files.
($(srcdir)/lib/local.mk): Include it.
($(srcdir)/lib/freeze.mk): Likewise.
* lib/Makefile.am: Rename ...
* lib/local.mk: .. like this, with several adjustments.  In
particular ...
(edit): Drop this definition, subsumed by the one in the
top-level Makefile.am.
* bin/local.mk (edit): Drop definition, that is already present
in the top-level Makefile.am now.
($(srcdir)/lib/freeze.mk): Drop inclusion; that is already done
in the top-level Makefile.am now.
* doc/local.mk (CLEANFILES): Adjust: append to it, do not define
it.
* lib/freeze.mk ($(AUTOM4TE_CFG)): Adjust recipe.
* configure.ac (AC_CONFIG_FILES): Drop 'lib/Makefile'.

Signed-off-by: Stefano Lattarini <[email protected]>
  • Loading branch information
slattarini committed May 6, 2013
1 parent f8ac780 commit a2af455
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 108 deletions.
25 changes: 24 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

# autom4te uses autotest.m4f to generate 'testsuite', so build tests last.
# Rules in man/ use scripts from both bin/ and tests/, so *it* goes last.
SUBDIRS = . lib tests man
SUBDIRS = . tests man

ACLOCAL_AMFLAGS = -I m4

MOSTLYCLEANFILES =
CLEANFILES =

EXTRA_DIST = ChangeLog.0 ChangeLog.1 ChangeLog.2 ChangeLog.3 \
BUGS COPYINGv3 COPYING.EXCEPTION \
Expand All @@ -32,6 +33,27 @@ EXTRA_DIST = ChangeLog.0 ChangeLog.1 ChangeLog.2 ChangeLog.3 \
build-aux/gitlog-to-changelog \
.prev-version .version

edit = sed \
-e 's|@SHELL[@]|$(SHELL)|g' \
-e 's|@PERL[@]|$(PERL)|g' \
-e 's|@PERL_FLOCK[@]|$(PERL_FLOCK)|g' \
-e 's|@bindir[@]|$(bindir)|g' \
-e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \
-e 's|@prefix[@]|$(prefix)|g' \
-e 's|@autoconf-name[@]|'`echo autoconf | sed '$(transform)'`'|g' \
-e 's|@autoheader-name[@]|'`echo autoheader | sed '$(transform)'`'|g' \
-e 's|@autom4te-name[@]|'`echo autom4te | sed '$(transform)'`'|g' \
-e 's|@M4[@]|$(M4)|g' \
-e 's|@M4_DEBUGFILE[@]|$(M4_DEBUGFILE)|g' \
-e 's|@M4_GNU[@]|$(M4_GNU)|g' \
-e 's|@AWK[@]|$(AWK)|g' \
-e 's|@RELEASE_YEAR[@]|$(RELEASE_YEAR)|g' \
-e 's|@VERSION[@]|$(VERSION)|g' \
-e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \
-e 's|@configure_input[@]|Generated from $@.in; do not edit by hand.|g'

include $(srcdir)/lib/freeze.mk

## --------- ##
## INSTALL. ##
## --------- ##
Expand Down Expand Up @@ -105,6 +127,7 @@ distclean-local:
include $(srcdir)/bin/local.mk
include $(srcdir)/doc/local.mk
include $(srcdir)/lib/local.mk
# Perl coverage statistics.
PERL_COVERAGE_DB = `pwd`/cover_db
Expand Down
21 changes: 0 additions & 21 deletions bin/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

include $(srcdir)/lib/freeze.mk

bin_SCRIPTS = \
bin/autoconf \
bin/autoheader \
Expand All @@ -42,25 +40,6 @@ MOSTLYCLEANFILES += $(bin_SCRIPTS) bin/autoconf.in bin/*.tmp
## The scripts. ##
## ------------- ##

edit = sed \
-e 's|@SHELL[@]|$(SHELL)|g' \
-e 's|@PERL[@]|$(PERL)|g' \
-e 's|@PERL_FLOCK[@]|$(PERL_FLOCK)|g' \
-e 's|@bindir[@]|$(bindir)|g' \
-e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \
-e 's|@prefix[@]|$(prefix)|g' \
-e 's|@autoconf-name[@]|'`echo autoconf | sed '$(transform)'`'|g' \
-e 's|@autoheader-name[@]|'`echo autoheader | sed '$(transform)'`'|g' \
-e 's|@autom4te-name[@]|'`echo autom4te | sed '$(transform)'`'|g' \
-e 's|@M4[@]|$(M4)|g' \
-e 's|@M4_DEBUGFILE[@]|$(M4_DEBUGFILE)|g' \
-e 's|@M4_GNU[@]|$(M4_GNU)|g' \
-e 's|@AWK[@]|$(AWK)|g' \
-e 's|@RELEASE_YEAR[@]|$(RELEASE_YEAR)|g' \
-e 's|@VERSION[@]|$(VERSION)|g' \
-e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \
-e 's|@configure_input[@]|Generated from $@.in; do not edit by hand.|g'

# autoconf is written in M4sh.
# FIXME: this target should depend on the frozen files below lib/m4sugar,
# otherwise autom4te may pick up a frozen m4sh.m4f from an earlier
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ AC_PROG_MAKE_CASE_SENSITIVE
dnl Allow maintainer rules under GNU make even in VPATH builds.
AC_CONFIG_LINKS([GNUmakefile:GNUmakefile])

AC_CONFIG_FILES([Makefile lib/Makefile])
AC_CONFIG_FILES([Makefile])

AC_OUTPUT
# Report the state of this version of Autoconf if this is a beta.
Expand Down
2 changes: 1 addition & 1 deletion doc/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ EXTRA_DIST += doc/gendocs_template

# Files from texi2dvi that should be removed, but which Automake does
# not know.
CLEANFILES = \
CLEANFILES += \
autoconf.ACs \
autoconf.cvs \
autoconf.MSs \
Expand Down
12 changes: 8 additions & 4 deletions lib/freeze.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SUFFIXES = .m4 .m4f

AUTOM4TE_CFG = $(top_builddir)/lib/autom4te.cfg
$(AUTOM4TE_CFG): $(top_srcdir)/lib/autom4te.in
cd $(top_builddir)/lib && $(MAKE) $(AM_MAKEFLAGS) autom4te.cfg
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) lib/autom4te.cfg

# Do not use AUTOM4TE here, since maint.mk (my-distcheck)
# checks if we are independent of Autoconf by defining AUTOM4TE (and
Expand All @@ -43,9 +43,13 @@ MY_AUTOM4TE = \
# force an end of line when reporting errors.
.m4.m4f:
$(MKDIR_P) $(@D)
$(MY_AUTOM4TE) \
--language=$(*F) \
--freeze \
lang=`echo '$*' | sed 's,.*/,,'` \
&& if test $$lang = autoconf; then \
lang=autoconf-without-aclocal-m4; \
else :; fi \
&& $(MY_AUTOM4TE) \
--language=$$lang \
--freeze \
--output=$@

# Factor the dependencies between all the frozen files.
Expand Down
146 changes: 66 additions & 80 deletions lib/Makefile.am → lib/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@

TAGS_FILES = # Incrementally updated later.
ETAGS_ARGS = # Likewise.
EXTRA_DIST = # Likewise.

## Required by rules to build several m4 libraries.
include $(srcdir)/freeze.mk

## Checks.
# Additional checks.
check-local: check-forbidden-patterns
forbidden_patterns = -e '^_*EOF' -e ' cmp '
forbidden_patterns_files = # Incrementally updated later.
Expand All @@ -34,15 +30,15 @@ forbidden_patterns_files = # Incrementally updated later.
perllibdir = $(pkgdatadir)/Autom4te

dist_perllib_DATA = \
Autom4te/C4che.pm \
Autom4te/ChannelDefs.pm \
Autom4te/Channels.pm \
Autom4te/Configure_ac.pm \
Autom4te/FileUtils.pm \
Autom4te/General.pm \
Autom4te/Getopt.pm \
Autom4te/Request.pm \
Autom4te/XFile.pm
lib/Autom4te/C4che.pm \
lib/Autom4te/ChannelDefs.pm \
lib/Autom4te/Channels.pm \
lib/Autom4te/Configure_ac.pm \
lib/Autom4te/FileUtils.pm \
lib/Autom4te/General.pm \
lib/Autom4te/Getopt.pm \
lib/Autom4te/Request.pm \
lib/Autom4te/XFile.pm

TAGS_FILES += $(dist_perllib_DATA)
ETAGS_ARGS += --lang=perl
Expand All @@ -51,38 +47,25 @@ ETAGS_ARGS += --lang=perl
## Make Autom4te default configuration file. ##
## ------------------------------------------ ##

nodist_pkgdata_DATA = autom4te.cfg
EXTRA_DIST += autom4te.in

edit = sed \
-e 's|@SHELL[@]|$(SHELL)|g' \
-e 's|@PERL[@]|$(PERL)|g' \
-e 's|@bindir[@]|$(bindir)|g' \
-e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \
-e 's|@prefix[@]|$(prefix)|g' \
-e 's|@autoconf-name[@]|'`echo autoconf | sed '$(transform)'`'|g' \
-e 's|@autoheader-name[@]|'`echo autoheader | sed '$(transform)'`'|g' \
-e 's|@autom4te-name[@]|'`echo autom4te | sed '$(transform)'`'|g' \
-e 's|@M4[@]|$(M4)|g' \
-e 's|@AWK[@]|$(AWK)|g' \
-e 's|@VERSION[@]|$(VERSION)|g' \
-e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g'
nodist_pkgdata_DATA = lib/autom4te.cfg
EXTRA_DIST += lib/autom4te.in

# All the files below depend on Makefile so that they are rebuilt
# when the prefix, etc. changes. Unfortunately, suffix rules
# cannot have additional dependencies, so we have to use explicit rules.
CLEANFILES = autom4te.cfg
autom4te.cfg: $(srcdir)/autom4te.in Makefile
rm -f autom4te.cfg autom4te.tmp
$(edit) $(srcdir)/autom4te.in >autom4te.tmp
chmod a-w autom4te.tmp
mv autom4te.tmp autom4te.cfg
CLEANFILES += lib/autom4te.cfg
lib/autom4te.cfg: $(srcdir)/lib/autom4te.in Makefile
rm -f $@ $@-t
$(MKDIR_P) $(@D)
$(edit) $(srcdir)/lib/autom4te.in >$@-t
chmod a-w $@-t
mv -f $@-t $@

## ----------------------------- ##
## Make Autoconf Emacs library. ##
## ----------------------------- ##

dist_lisp_LISP = emacs/autoconf-mode.el emacs/autotest-mode.el
dist_lisp_LISP = lib/emacs/autoconf-mode.el lib/emacs/autotest-mode.el

# TODO: This is required to work around a limitation in older
# Automake. Remove once we can assume Automake 1.13 or later.
Expand All @@ -95,76 +78,79 @@ CLEANFILES += autoconf-mode.elc autotest-mode.elc
autoconflibdir = $(pkgdatadir)/autoconf

dist_autoconflib_DATA = \
autoconf/autoconf.m4 \
autoconf/general.m4 \
autoconf/status.m4 \
autoconf/oldnames.m4 \
autoconf/specific.m4 \
autoconf/autoheader.m4 \
autoconf/autoupdate.m4 \
autoconf/autotest.m4 \
autoconf/autoscan.m4 \
autoconf/lang.m4 \
autoconf/c.m4 \
autoconf/erlang.m4 \
autoconf/fortran.m4 \
autoconf/functions.m4 \
autoconf/go.m4 \
autoconf/headers.m4 \
autoconf/types.m4 \
autoconf/libs.m4 \
autoconf/programs.m4

nodist_autoconflib_DATA = autoconf/autoconf.m4f
lib/autoconf/autoconf.m4 \
lib/autoconf/general.m4 \
lib/autoconf/status.m4 \
lib/autoconf/oldnames.m4 \
lib/autoconf/specific.m4 \
lib/autoconf/autoheader.m4 \
lib/autoconf/autoupdate.m4 \
lib/autoconf/autotest.m4 \
lib/autoconf/autoscan.m4 \
lib/autoconf/lang.m4 \
lib/autoconf/c.m4 \
lib/autoconf/erlang.m4 \
lib/autoconf/fortran.m4 \
lib/autoconf/functions.m4 \
lib/autoconf/go.m4 \
lib/autoconf/headers.m4 \
lib/autoconf/types.m4 \
lib/autoconf/libs.m4 \
lib/autoconf/programs.m4

nodist_autoconflib_DATA = lib/autoconf/autoconf.m4f
CLEANFILES += $(nodist_autoconflib_DATA)

TAGS_FILES += $(dist_autoconflib_DATA)
ETAGS_ARGS += $(ETAGS_FOR_AUTOCONF)

forbidden_patterns_files += $(dist_autoconflib_DATA)

autoconf/autoconf.m4f: $(autoconf_m4f_dependencies)
lib/autoconf/autoconf.m4f: $(autoconf_m4f_dependencies)

## ------------------------ ##
## Make Autoscan library. ##
## ------------------------ ##

autoscanlibdir = $(pkgdatadir)/autoscan

EXTRA_DIST += autoscan/autoscan.pre
nodist_autoscanlib_DATA = autoscan/autoscan.list
CLEANFILES += autoscan/autoscan.list
EXTRA_DIST += lib/autoscan/autoscan.pre
nodist_autoscanlib_DATA = lib/autoscan/autoscan.list
CLEANFILES += lib/autoscan/autoscan.list

autoscan/autoscan.list: $(srcdir)/autoscan/autoscan.pre $(autoconf_m4f_dependencies) Makefile.am
lib/autoscan/autoscan.list: $(srcdir)/lib/autoscan/autoscan.pre
$(MKDIR_P) $(@D)
echo '# Automatically Generated: do not edit this file' >$@
sed '/^[#]/!q' $(srcdir)/autoscan/autoscan.pre >>$@
sed '/^[#]/!q' $(srcdir)/lib/autoscan/autoscan.pre >>$@
( \
sed -n '/^[^#]/p' $(srcdir)/autoscan/autoscan.pre; \
$(MY_AUTOM4TE) --cache '' -M -l autoconf -t'AN_OUTPUT:$$1: $$2 $$3' \
sed -n '/^[^#]/p' $(srcdir)/lib/autoscan/autoscan.pre; \
$(MY_AUTOM4TE) --cache '' -M -l autoconf-without-aclocal-m4 \
-t'AN_OUTPUT:$$1: $$2 $$3' \
) | LC_ALL=C sort >>$@

lib/autoscan/autoscan.list: $(autoconf_m4f_dependencies) Makefile

## ----------------------------------- ##
## Make Autoconf library for M4sugar. ##
## ----------------------------------- ##

m4sugarlibdir = $(pkgdatadir)/m4sugar

dist_m4sugarlib_DATA = \
m4sugar/m4sugar.m4 \
m4sugar/foreach.m4 \
m4sugar/m4sh.m4
lib/m4sugar/m4sugar.m4 \
lib/m4sugar/foreach.m4 \
lib/m4sugar/m4sh.m4

nodist_m4sugarlib_DATA = \
m4sugar/version.m4 \
m4sugar/m4sugar.m4f \
m4sugar/m4sh.m4f
lib/m4sugar/version.m4 \
lib/m4sugar/m4sugar.m4f \
lib/m4sugar/m4sh.m4f

CLEANFILES += $(nodist_m4sugarlib_DATA)

# The ':;' in the second line of the recipe works around a redirected
# compound command bash exit status bug.
m4sugar/version.m4: Makefile
lib/m4sugar/version.m4: Makefile
$(MKDIR_P) $(@D)
:;{ \
echo '# This file is part of -*- Autoconf -*-.' && \
Expand All @@ -187,8 +173,8 @@ ETAGS_ARGS += $(ETAGS_FOR_AUTOCONF)

forbidden_patterns_files += $(dist_m4sugarlib_DATA)

m4sugar/m4sugar.m4f: $(m4sugar_m4f_dependencies)
m4sugar/m4sh.m4f: $(m4sh_m4f_dependencies)
lib/m4sugar/m4sugar.m4f: $(m4sugar_m4f_dependencies)
lib/m4sugar/m4sh.m4f: $(m4sh_m4f_dependencies)

## ----------------------- ##
## Make Autotest library. ##
Expand All @@ -197,16 +183,16 @@ m4sugar/m4sh.m4f: $(m4sh_m4f_dependencies)
autotestlibdir = $(pkgdatadir)/autotest

dist_autotestlib_DATA = \
autotest/autotest.m4 \
autotest/general.m4 \
autotest/specific.m4
lib/autotest/autotest.m4 \
lib/autotest/general.m4 \
lib/autotest/specific.m4

nodist_autotestlib_DATA = autotest/autotest.m4f
nodist_autotestlib_DATA = lib/autotest/autotest.m4f
CLEANFILES += $(nodist_autotestlib_DATA)

TAGS_FILES += $(dist_autotestlib_DATA)
ETAGS_ARGS += $(ETAGS_FOR_AUTOCONF)

forbidden_patterns_files += $(dist_autotestlib_DATA)

autotest/autotest.m4f: $(autotest_m4f_dependencies)
lib/autotest/autotest.m4f: $(autotest_m4f_dependencies)

0 comments on commit a2af455

Please sign in to comment.