automake-patches
[Top][All Lists]
Advanced

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

FYI: catch variable names starting with `_' (PR/291).


From: Alexandre Duret-Lutz
Subject: FYI: catch variable names starting with `_' (PR/291).
Date: 08 Jul 2002 21:21:34 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

I'm checking this in.  This prints a warning (under -Wportability)
when variable names starting with `_' are defined.

Strictly speaking, the _am_installdirs variable doesn't need to
be renamed because it's never output, but it seems cleaner to
keeps things simple and apply to same rule to everybody.  (BTW,
reading the code I've not found where this variable is stopped
from being output; there are a two `Accumulating variables must
not be output' comments, but they seem misplaced.)

Have a look at canon5.test, this is interesting: with the
current rules for canonicalization, a target which starts with
an non-alphanumeric character have a canonical name starting
with `_'.  Supporting these target portably probably require
changes to the canonicalization rules (is this worth the
trouble?).

2002-07-08  Alexandre Duret-Lutz  <address@hidden>

        Fix for PR automake/291:
        * automake.in (macro_define): Catch variable names starting
        with `_'.
        (handle_installdirs): Rename _am_installdirs to am__installdirs.
        * lib/am/data.am, lib/am/install.am, lib/am/libs.am,
        lib/am/lisp.am, lib/am/ltlibs.am, lib/am/mans.am,
        lib/am/progs.am, lib/am/python.am, lib/am/scripts.am,
        lib/am/texinfos.am: Likewise.
        * tests/canon5.test: Use -Wno-portability.
        * tests/vars2.test: New file.
        * tests/Makefile.am (TESTS): Add vars2.test.

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1319
diff -u -r1.1319 automake.in
--- automake.in 7 Jul 2002 22:38:45 -0000       1.1319
+++ automake.in 8 Jul 2002 19:21:27 -0000
@@ -4371,8 +4371,8 @@
 {
     $output_rules .=
       &file_contents ('install',
-                     ('_am_installdirs'
-                      => variable_value ('_am_installdirs') || '',
+                     ('am__installdirs'
+                      => variable_value ('am__installdirs') || '',
                       'installdirs-local'
                       => (target_defined ('installdirs-local')
                           ? ' installdirs-local' : '')));
@@ -5927,8 +5927,13 @@
 {
   my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
 
-  err $where, "bad characters in macro name `$var'"
+  err $where, "bad characters in variable name `$var'"
     if $var !~ /$MACRO_PATTERN/o;
+
+  # NEWS-OS 4.2R complains if a Makefile variable begins with `_'.
+  msg ('portability', $where,
+       "$var: variable names starting with `_' are not portable")
+    if $var =~ /^_/;
 
   $cond ||= 'TRUE';
 
Index: lib/am/data.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/data.am,v
retrieving revision 1.38
diff -u -r1.38 data.am
--- lib/am/data.am      9 Nov 2001 16:25:03 -0000       1.38
+++ lib/am/data.am      8 Jul 2002 19:21:30 -0000
@@ -21,7 +21,7 @@
 ## ------------ ##
 
 if %?INSTALL%
-_am_installdirs += $(DESTDIR)$(%NDIR%dir)
+am__installdirs += $(DESTDIR)$(%NDIR%dir)
 ?BASE?%DIR%%PRIMARY%_INSTALL = $(INSTALL_%ONE_PRIMARY%)
 ?!BASE?%DIR%%PRIMARY%_INSTALL = $(install_sh_DATA)
 ?EXEC?.PHONY install-exec-am: install-%DIR%%PRIMARY%
Index: lib/am/install.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/install.am,v
retrieving revision 1.9
diff -u -r1.9 install.am
--- lib/am/install.am   1 Jan 2002 12:45:44 -0000       1.9
+++ lib/am/install.am   8 Jul 2002 19:21:30 -0000
@@ -22,11 +22,11 @@
 ?SUBDIRS?.PHONY: installdirs installdirs-am installdirs-recursive
 ?SUBDIRS?installdirs: installdirs-recursive
 ?SUBDIRS?installdirs-am:%installdirs-local%
-?SUBDIRS??_am_installdirs?     $(mkinstalldirs) %_am_installdirs%
+?SUBDIRS??am__installdirs?     $(mkinstalldirs) %am__installdirs%
 
 ?!SUBDIRS?.PHONY: installdirs
 ?!SUBDIRS?installdirs:%installdirs-local%
-?!SUBDIRS??_am_installdirs?    $(mkinstalldirs) %_am_installdirs%
+?!SUBDIRS??am__installdirs?    $(mkinstalldirs) %am__installdirs%
 
 
 ## ----------------- ##
Index: lib/am/java.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/java.am,v
retrieving revision 1.16
diff -u -r1.16 java.am
--- lib/am/java.am      12 Jun 2002 07:52:34 -0000      1.16
+++ lib/am/java.am      8 Jul 2002 19:21:30 -0000
@@ -40,7 +40,7 @@
 ## ------------ ##
 
 if %?INSTALL%
-_am_installdirs += $(DESTDIR)$(%NDIR%dir)
+am__installdirs += $(DESTDIR)$(%NDIR%dir)
 ?EXEC?.PHONY install-exec-am: install-%DIR%JAVA
 ?!EXEC?.PHONY install-data-am: install-%DIR%JAVA
 install-%DIR%JAVA: class%DIR%.stamp
Index: lib/am/libs.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/libs.am,v
retrieving revision 1.22
diff -u -r1.22 libs.am
--- lib/am/libs.am      5 Mar 2002 21:34:14 -0000       1.22
+++ lib/am/libs.am      8 Jul 2002 19:21:30 -0000
@@ -32,7 +32,7 @@
 ## ------------ ##
 
 if %?INSTALL%
-_am_installdirs += $(DESTDIR)$(%NDIR%dir)
+am__installdirs += $(DESTDIR)$(%NDIR%dir)
 ?BASE?%DIR%LIBRARIES_INSTALL = $(INSTALL_DATA)
 ?!BASE?%DIR%LIBRARIES_INSTALL = $(install_sh_DATA)
 ?EXEC?.PHONY install-exec-am: install-%DIR%LIBRARIES
Index: lib/am/lisp.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/lisp.am,v
retrieving revision 1.32
diff -u -r1.32 lisp.am
--- lib/am/lisp.am      13 Apr 2002 21:26:35 -0000      1.32
+++ lib/am/lisp.am      8 Jul 2002 19:21:30 -0000
@@ -32,7 +32,7 @@
 ## ------------ ##
 
 if %?INSTALL%
-_am_installdirs += $(DESTDIR)$(%NDIR%dir)
+am__installdirs += $(DESTDIR)$(%NDIR%dir)
 ?BASE?%DIR%LISP_INSTALL = $(INSTALL_DATA)
 ?!BASE?%DIR%LISP_INSTALL = $(install_sh_DATA)
 ?EXEC?.PHONY install-exec-am: install-%DIR%LISP
Index: lib/am/ltlib.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/ltlib.am,v
retrieving revision 1.23
diff -u -r1.23 ltlib.am
--- lib/am/ltlib.am     30 Apr 2002 22:13:50 -0000      1.23
+++ lib/am/ltlib.am     8 Jul 2002 19:21:30 -0000
@@ -22,7 +22,7 @@
 ## ------------ ##
 
 if %?INSTALL%
-_am_installdirs += $(DESTDIR)$(%NDIR%dir)
+am__installdirs += $(DESTDIR)$(%NDIR%dir)
 ?BASE?%DIR%LTLIBRARIES_INSTALL = $(INSTALL)
 ?!BASE?%DIR%LTLIBRARIES_INSTALL = $(install_sh) -c
 ?EXEC?.PHONY install-exec-am: install-%DIR%LTLIBRARIES
Index: lib/am/mans.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/mans.am,v
retrieving revision 1.24
diff -u -r1.24 mans.am
--- lib/am/mans.am      13 Apr 2002 21:48:35 -0000      1.24
+++ lib/am/mans.am      8 Jul 2002 19:21:30 -0000
@@ -27,7 +27,7 @@
 
 .PHONY: install-man
 ?INSTALL-MAN?install-data-am: install-man
-?INSTALL-MAN?_am_installdirs += $(DESTDIR)$(man%SECTION%dir)
+?INSTALL-MAN?am__installdirs += $(DESTDIR)$(man%SECTION%dir)
 .PHONY install-man: install-man%SECTION%
 install-man%SECTION%: $(man%SECTION%_MANS) $(man_MANS)
        @$(NORMAL_INSTALL)
Index: lib/am/progs.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/progs.am,v
retrieving revision 1.35
diff -u -r1.35 progs.am
--- lib/am/progs.am     17 Jun 2002 12:20:22 -0000      1.35
+++ lib/am/progs.am     8 Jul 2002 19:21:30 -0000
@@ -23,7 +23,7 @@
 ## ------------ ##
 
 if %?INSTALL%
-_am_installdirs += $(DESTDIR)$(%NDIR%dir)
+am__installdirs += $(DESTDIR)$(%NDIR%dir)
 ?BASE?%DIR%PROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 ?!BASE?%DIR%PROGRAMS_INSTALL = $(install_sh_PROGRAM)
 ?EXEC?.PHONY install-exec-am: install-%DIR%PROGRAMS
Index: lib/am/python.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/python.am,v
retrieving revision 1.14
diff -u -r1.14 python.am
--- lib/am/python.am    9 Nov 2001 16:25:03 -0000       1.14
+++ lib/am/python.am    8 Jul 2002 19:21:31 -0000
@@ -22,7 +22,7 @@
 ## ------------ ##
 
 if %?INSTALL%
-_am_installdirs += $(DESTDIR)$(%NDIR%dir)
+am__installdirs += $(DESTDIR)$(%NDIR%dir)
 ?BASE?%DIR%PYTHON_INSTALL = $(INSTALL_DATA)
 ?!BASE?%DIR%PYTHON_INSTALL = $(install_sh_DATA)
 ?EXEC?.PHONY install-exec-am: install-%DIR%PYTHON
Index: lib/am/scripts.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/scripts.am,v
retrieving revision 1.44
diff -u -r1.44 scripts.am
--- lib/am/scripts.am   17 Jun 2002 12:20:22 -0000      1.44
+++ lib/am/scripts.am   8 Jul 2002 19:21:31 -0000
@@ -23,7 +23,7 @@
 
 if %?INSTALL%
 ## if doesn't work properly for Automake variables yet.
-_am_installdirs += $(DESTDIR)$(%NDIR%dir)
+am__installdirs += $(DESTDIR)$(%NDIR%dir)
 ?BASE?%DIR%SCRIPT_INSTALL = $(INSTALL_SCRIPT)
 ?!BASE?%DIR%SCRIPT_INSTALL = $(install_sh_SCRIPT)
 ?EXEC?.PHONY install-exec-am: install-%DIR%SCRIPTS
@@ -93,4 +93,3 @@
          done; \
        done; rm -f c$${pid}_.???; exit $$bad
 endif %?CK-OPTS%
-
Index: lib/am/texinfos.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/texinfos.am,v
retrieving revision 1.95
diff -u -r1.95 texinfos.am
--- lib/am/texinfos.am  26 Jun 2002 19:13:52 -0000      1.95
+++ lib/am/texinfos.am  8 Jul 2002 19:21:31 -0000
@@ -101,7 +101,7 @@
 ## is hard coded.
 if %?INSTALL-INFO%
 if %?LOCAL-TEXIS%
-_am_installdirs += $(DESTDIR)$(infodir)
+am__installdirs += $(DESTDIR)$(infodir)
 install-data-am: install-info-am
 endif %?LOCAL-TEXIS%
 if %?SUBDIRS%
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.413
diff -u -r1.413 Makefile.am
--- tests/Makefile.am   3 Jul 2002 18:50:04 -0000       1.413
+++ tests/Makefile.am   8 Jul 2002 19:21:33 -0000
@@ -380,6 +380,7 @@
 transform.test \
 unused.test \
 vars.test \
+vars2.test \
 vartar.test \
 version.test \
 version2.test \
Index: tests/canon5.test
===================================================================
RCS file: /cvs/automake/automake/tests/canon5.test,v
retrieving revision 1.3
diff -u -r1.3 canon5.test
--- tests/canon5.test   9 Apr 2001 14:50:51 -0000       1.3
+++ tests/canon5.test   8 Jul 2002 19:21:33 -0000
@@ -20,18 +20,21 @@
 _foo_SOURCES = foo.c
 END
 
-$AUTOMAKE || exit 1
+# Variables starting with `_' are not portable.
+$AUTOMAKE -Wno-portability || exit 1
 
 cat > Makefile.am << 'END'
 bin_PROGRAMS = ,foo
 ,foo_SOURCES = foo.c
 END
 
-$AUTOMAKE && exit 1
+# Variables starting with `_' are not portable.
+$AUTOMAKE -Wno-portability && exit 1
 
 cat > Makefile.am << 'END'
 bin_PROGRAMS = ,foo
 _foo_SOURCES = foo.c
 END
 
-$AUTOMAKE
+# Variables starting with `_' are not portable.
+$AUTOMAKE -Wno-portability
Index: tests/vars2.test
===================================================================
RCS file: tests/vars2.test
diff -N tests/vars2.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/vars2.test    8 Jul 2002 19:33:48 -0000
@@ -0,0 +1,22 @@
+#! /bin/sh
+
+# Check that Automake warns about variables starting with `_'.
+# PR/291
+
+. $srcdir/defs || exit 1
+
+set -e
+
+cat >Makefile.am <<EOF
+GOOD_ = 1
+_BAD  = 2
+ _bad = 3
+EOF
+
+$ACLOCAL
+# Make sure this warning is print in the `portability' category.
+$AUTOMAKE -Wno-error -Wnone -Wportability 2>stderr
+cat stderr
+grep GOOD stderr && exit 1
+grep _BAD stderr
+grep _bad stderr
-- 
Alexandre Duret-Lutz




reply via email to

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