[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Automake-NG] [FYI] [ng] tags: rewrite to be included verbatim
From: |
Stefano Lattarini |
Subject: |
[Automake-NG] [FYI] [ng] tags: rewrite to be included verbatim |
Date: |
Fri, 10 Aug 2012 10:20:52 +0200 |
* lib/am/tags.am: Moved ...
* lib/am/tags.mk: ... here, rewrite to be included verbatim, reformatted,
and enhanced to take over the role of ...
* automake.in (handle_tags): ... this function as well, which has thus
been removed.
(generate_makefile): Call the removed function no more. Include 'tags.mk'
verbatim in the generated Makefile.
* Makefile.am (dist_am_DATA): Adjust.
* t/tags.sh: This weak grepping test is broken by the other changes done
here; so remove it, adding ...
* t/tags-id.sh: ... this in its place, which is more semantic, i.e.,
operated by actually running the 'ID' target.
* t/tags2.sh: Remove as obsolete.
* t/location.sh: Adjust to avoid spurious errors.
* t/targetclash.sh: Likewise.
Signed-off-by: Stefano Lattarini <address@hidden>
---
Makefile.am | 2 +-
automake.in | 32 +-----------
lib/am/{tags.am => tags.mk} | 122 +++++++++++++++++++++++---------------------
t/location.sh | 8 +--
t/{tags.sh => tags-id.sh} | 19 ++++++-
t/tags2.sh | 42 ---------------
t/targetclash.sh | 4 +-
7 files changed, 89 insertions(+), 140 deletions(-)
rename lib/am/{tags.am => tags.mk} (62%)
rename t/{tags.sh => tags-id.sh} (78%)
delete mode 100755 t/tags2.sh
diff --git a/Makefile.am b/Makefile.am
index f85663c..d2f014f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -193,6 +193,7 @@ dist_am_DATA = \
lib/am/check-typos.mk \
lib/am/clean.mk \
lib/am/header-vars.mk \
+ lib/am/tags.mk \
lib/am/compile.am \
lib/am/configure.am \
lib/am/data.am \
@@ -217,7 +218,6 @@ dist_am_DATA = \
lib/am/remake-hdr.am \
lib/am/scripts.am \
lib/am/subdirs.am \
- lib/am/tags.am \
lib/am/texi-vers.am \
lib/am/texi-spec.am \
lib/am/texinfos.am \
diff --git a/automake.in b/automake.in
index 5acd434..c50e0ad 100644
--- a/automake.in
+++ b/automake.in
@@ -3147,36 +3147,6 @@ sub handle_data
'pkgdata', 'lisp', 'noinst', 'check');
}
-# Handle TAGS.
-sub handle_tags
-{
- define_variable ('am.tags.files', INTERNAL,
- qw/$(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
- $(am.config-hdr.local.in)/);
-
- if (rvar('am.tags.files')->value_as_list_recursive
- || var ('ETAGS_ARGS') || var ('SUBDIRS'))
- {
- $output_rules .= &file_contents ('tags', new Automake::Location);
- set_seen 'TAGS_DEPENDENCIES';
- }
- else
- {
- reject_var ('TAGS_DEPENDENCIES',
- "it doesn't make sense to define 'TAGS_DEPENDENCIES'"
- . " without\nsources or 'ETAGS_ARGS'");
- # Every Makefile must define some sort of TAGS rule.
- # Otherwise, it would be possible for a top-level "make TAGS"
- # to fail because some subdirectory failed. Ditto ctags and
- # cscope.
- $output_rules .=
- "tags TAGS:\n\n" .
- "ctags CTAGS:\n\n" .
- "cscope cscopelist:\n\n";
- }
-}
-
-
# user_phony_rule ($NAME)
# -----------------------
# Return false if rule $NAME does not exist. Otherwise,
@@ -6788,9 +6758,9 @@ sub generate_makefile ($$)
handle_man_pages;
handle_data;
handle_headers;
+ verbatim ('tags');
handle_subdirs;
handle_user_recursion;
- handle_tags;
handle_minor_options;
# Must come after invocation of handle_programs, handle_libraries and
diff --git a/lib/am/tags.am b/lib/am/tags.mk
similarity index 62%
rename from lib/am/tags.am
rename to lib/am/tags.mk
index bd7e2c7..aebd8b6 100644
--- a/lib/am/tags.am
+++ b/lib/am/tags.mk
@@ -14,6 +14,22 @@
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
+# Every Makefile must define some sort of TAGS rule. Otherwise, it
+# would be possible for a top-level "make TAGS" to fail because some
+# subdirectory failed. Ditto for ctags and cscope.
+.PHONY: tags TAGS ctags CTAGS cscope cscopelist
+
+am.tags.files = \
+ $(call am.memoize,am.tags.files,$(strip \
+ $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) $(am.config-hdr.local.in)))
+
+# Let's see if we have to actually deal with tags creation.
+ifneq ($(or $(am.tags.files),$(ETAGS_ARGS),$(SUBDIRS)),)
+
+# ---------------------------------- #
+# Tags-related internal variables. #
+# ---------------------------------- #
+
# Use $(sort) rather than $(am.util.uniq) here, because the former is
# faster on long lists, and we don't care about the order of the list
# anyway.
@@ -37,75 +53,70 @@ am.tags.subfiles = \
$(call am.memoize,am.tags.subfiles,$(strip \
$(foreach d,$(filter-out .,$(SUBDIRS)),$(wildcard $d/TAGS))))
-## ---- ##
-## ID. ##
-## ---- ##
+
+# ---------------------------------- #
+# ID database (from GNU id-utils). #
+# ---------------------------------- #
ID: $(am.tags.files)
mkid -fID $(am.tags.files.unique)
+am.clean.dist.f += ID
-## ------ ##
-## TAGS. ##
-## ------ ##
+# -------------------------------- #
+# GNU Etags and Exuberant ctags. #
+# -------------------------------- #
+CTAGS = ctags
ETAGS = etags
-.PHONY: TAGS tags
-if %?SUBDIRS%
-AM_RECURSIVE_TARGETS += TAGS
-RECURSIVE_TARGETS += tags-recursive
+
+ifdef SUBDIRS
+AM_RECURSIVE_TARGETS += TAGS CTAGS
+RECURSIVE_TARGETS += tags-recursive ctags-recursive
+ctags: ctags-recursive
tags: tags-recursive
-else !%?SUBDIRS%
+else
tags: tags-am
-endif !%?SUBDIRS%
+ctags: ctags-am
+endif
+
TAGS: tags
+CTAGS: ctags
+.PHONY: TAGS tags CTAGS ctags
tags-am: $(TAGS_DEPENDENCIES) $(am.tags.files)
-## Make sure we have something to run etags on.
- test -z '$(ETAGS_ARGS)$(am.tags.subfiles)$(am.tags.files.unique)' || { \
- $(ETAGS) \
- $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $(foreach
f,$(am.tags.subfiles),'$(am.tags.include-option)=$(CURDIR)/$f') \
- $(am.tags.files.unique); \
- }
-
+ifneq ($(or $(ETAGS_ARGS),$(am.tags.subfiles),$(am.tags.files.unique)),)
+ $(ETAGS) \
+ $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $(foreach
f,$(am.tags.subfiles),'$(am.tags.include-option)=$(CURDIR)/$f') \
+ $(am.tags.files.unique)
+endif
-## --------------- ##
-## vi-style tags. ##
-## --------------- ##
-
-CTAGS = ctags
-.PHONY: CTAGS ctags
-if %?SUBDIRS%
-AM_RECURSIVE_TARGETS += CTAGS
-RECURSIVE_TARGETS += ctags-recursive
-ctags: ctags-recursive
-else !%?SUBDIRS%
-ctags: ctags-am
-endif !%?SUBDIRS%
-
-CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am.tags.files)
-## Make sure we have something to run ctags on.
- test -z "$(CTAGS_ARGS)$(am.tags.files.unique)" \
- || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $(am.tags.files.unique)
+ifneq ($(or $(CTAGS_ARGS),$(am.tags.files.unique)),)
+ $(CTAGS) \
+ $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $(am.tags.files.unique)
+endif
+am.clean.dist.f += TAGS tags
-## --------------- ##
-## "Global tags". ##
-## --------------- ##
+
+# -------------------- #
+# GNU "Global tags". #
+# -------------------- #
.PHONY: GTAGS
GTAGS:
cd $(top_srcdir) && gtags -i $(GTAGS_ARGS) '$(abs_top_builddir)'
+am.clean.dist.f += GTAGS GRTAGS GSYMS
-## ------- ##
-## cscope ##
-## ------- ##
+# --------- #
+# Cscope. #
+# --------- #
-if %?TOPDIR_P%
+ifdef am.conf.is-topdir
CSCOPE = cscope
.PHONY: cscope clean-cscope
AM_RECURSIVE_TARGETS += cscope
@@ -115,14 +126,15 @@ cscope: cscope.files
clean-cscope:
rm -f cscope.files
cscope.files: clean-cscope cscopelist
-endif %?TOPDIR_P%
+am.clean.dist.f += cscope.out cscope.in.out cscope.po.out cscope.files
+endif
-if %?SUBDIRS%
+ifdef SUBDIRS
RECURSIVE_TARGETS += cscopelist-recursive
cscopelist: cscopelist-recursive
-else !%?SUBDIRS%
+else
cscopelist: cscopelist-am
-endif !%?SUBDIRS%
+endif
cscopelist-am: $(am.tags.files)
list='$(am.tags.files)'; \
@@ -138,12 +150,4 @@ cscopelist-am: $(am.tags.files)
fi; \
done >> $(top_builddir)/cscope.files
-
-## ---------- ##
-## Cleaning. ##
-## ---------- ##
-
-am.clean.dist.f += TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-if %?TOPDIR_P%
-am.clean.dist.f += cscope.out cscope.in.out cscope.po.out cscope.files
-endif %?TOPDIR_P%
+endif # Dealing with tags.
diff --git a/t/location.sh b/t/location.sh
index dab1e33..424904b 100755
--- a/t/location.sh
+++ b/t/location.sh
@@ -32,7 +32,7 @@ if COND2
lib_LIBRARIES = libfoo.a
endif
if COND1
- bin_PROGRAMS += ctags
+ bin_PROGRAMS += distdir
endif
VAR = 1 \
2 \
@@ -77,9 +77,9 @@ sed 's/^> //' > expected << 'END'
> Makefile.am:1: while processing program 'libfoo.a'
> library.am: ... 'libfoo.a' previously defined here
> Makefile.am:3: while processing library 'libfoo.a'
-> tags.am: warning: redefinition of 'ctags' ...
-> program.am: ... 'ctags$(EXEEXT)' previously defined here
-> Makefile.am:6: while processing program 'ctags'
+> distdir.am: warning: redefinition of 'distdir' ...
+> program.am: ... 'distdir$(EXEEXT)' previously defined here
+> Makefile.am:6: while processing program 'distdir'
END
cat expected
diff --git a/t/tags.sh b/t/tags-id.sh
similarity index 78%
rename from t/tags.sh
rename to t/tags-id.sh
index 8f38e6b..9032125 100755
--- a/t/tags.sh
+++ b/t/tags-id.sh
@@ -17,13 +17,30 @@
# Test for bug reported by Harlan Stenn: the tags target doesn't work
# when there are only headers in a directory.
+required=mkid
. ./defs || exit 1
+echo AC_OUTPUT >> configure.ac
+
cat > Makefile.am << 'END'
noinst_HEADERS = iguana.h
+test-id: ID
+ test -f $(srcdir)/iguana.h
+ test -f ID
+check-local: test-id
+END
+
+cat > iguana.h << 'END'
+#define FOO "bar"
+int zap (int x, char y);
END
$ACLOCAL
+$AUTOCONF
$AUTOMAKE
-grep '^ID:' Makefile.in
+./configure
+$MAKE test-id
+$MAKE distcheck
+
+:
diff --git a/t/tags2.sh b/t/tags2.sh
deleted file mode 100755
index 521d2ef..0000000
--- a/t/tags2.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2010-2012 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
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program 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 program. If not, see <http://www.gnu.org/licenses/>.
-
-# TAGS_DEPENDENCIES only make sense if other tag-worthy things (such as
-# sources) exist.
-
-. ./defs || exit 1
-
-cat >> configure.ac << 'END'
-AC_PROG_CC
-AC_OUTPUT
-END
-
-cat >Makefile.am << 'END'
-TAGS_DEPENDENCIES = foo
-END
-
-$ACLOCAL
-AUTOMAKE_fails
-grep 'define.*TAGS_DEPENDENCIES.*without' stderr
-
-cat >>Makefile.am << 'END'
-bin_PROGRAMS = bar
-END
-
-AUTOMAKE_run
-grep 'define.*TAGS_DEPENDENCIES.*without' stderr && exit 1
-
-:
diff --git a/t/targetclash.sh b/t/targetclash.sh
index 031cbc1..9c71007 100755
--- a/t/targetclash.sh
+++ b/t/targetclash.sh
@@ -23,11 +23,11 @@ AC_PROG_CC
END
cat > Makefile.am << 'END'
-bin_PROGRAMS = ctags
+bin_PROGRAMS = distdir
END
$ACLOCAL
AUTOMAKE_fails -a
-grep 'redefinition.*ctags' stderr
+grep 'redefinition.*distdir' stderr
:
--
1.7.12.rc0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Automake-NG] [FYI] [ng] tags: rewrite to be included verbatim,
Stefano Lattarini <=