[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: warn if `obj' occurs in SUBDIRS.
From: |
Alexandre Duret-Lutz |
Subject: |
FYI: warn if `obj' occurs in SUBDIRS. |
Date: |
22 Jul 2002 22:45:10 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
Today I was shown an autoconfiscated project that would create 3
libraries when built with GNU make, and only one with BSD make!
The library that was built lied in an `obj/' subdirectory, and
it turns out that BSD make has a special hard-coded rule for
this directory. If an `obj/' directory exists, BSD make enter
it before reading the Makefile; thus it processes obj/Makefile
instead of ./Makefile! It can take some time before you realize
what happens.
Obviously such behavior will break any projects using `obj/' as
a subdirectory. This seems a good candidate for -Wportability,
so I'm checking this in.
2002-07-22 Alexandre Duret-Lutz <address@hidden>
* automake.in (handle_subdirs): Warn if `obj' appears in SUBDIRS.
* tests/subdir7.test: New file.
* tests/Makefile.am (TESTS): Add subdir7.test.
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1331
diff -u -r1.1331 automake.in
--- automake.in 19 Jul 2002 11:04:12 -0000 1.1331
+++ automake.in 22 Jul 2002 20:37:07 -0000
@@ -4054,8 +4054,36 @@
return
unless variable_defined ('SUBDIRS');
+ my @subdirs = &variable_value_as_list_recursive ('SUBDIRS', 'all');
+ my @dsubdirs = ();
+ @dsubdirs = &variable_value_as_list_recursive ('DIST_SUBDIRS', 'all')
+ if variable_defined ('DIST_SUBDIRS');
+
+ # If an `obj/' directory exists, BSD make will enter it before
+ # reading `Makefile'. Hence the `Makefile' in the current directory
+ # will not be read.
+ #
+ # % cat Makefile
+ # all:
+ # echo Hello
+ # % cat obj/Makefile
+ # all:
+ # echo World
+ # % make # GNU make
+ # echo Hello
+ # Hello
+ # % pmake # BSD make
+ # echo World
+ # World
+ msg_var ('portability', 'SUBDIRS',
+ "naming a subdirectory `obj' causes troubles with BSD make")
+ if grep ($_ eq 'obj', @subdirs);
+ msg_var ('portability', 'DIST_SUBDIRS',
+ "naming a subdirectory `obj' causes troubles with BSD make")
+ if grep ($_ eq 'obj', @dsubdirs);
+
# Make sure each directory mentioned in SUBDIRS actually exists.
- foreach my $dir (&variable_value_as_list_recursive ('SUBDIRS', 'all'))
+ foreach my $dir (@subdirs)
{
# Skip directories substituted by configure.
next if $dir =~ /address@hidden@$/;
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.422
diff -u -r1.422 Makefile.am
--- tests/Makefile.am 22 Jul 2002 17:00:44 -0000 1.422
+++ tests/Makefile.am 22 Jul 2002 20:37:10 -0000
@@ -337,6 +337,7 @@
subdir4.test \
subdir5.test \
subdir6.test \
+subdir7.test \
subdirbuiltsources.test \
subdircond.test \
subobj.test \
Index: tests/subdir7.test
===================================================================
RCS file: tests/subdir7.test
diff -N tests/subdir7.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/subdir7.test 22 Jul 2002 20:37:10 -0000
@@ -0,0 +1,32 @@
+#! /bin/sh
+
+# Naming a subdirectory `obj/' is a bad idea. Automake should say so.
+
+. $srcdir/defs || exit 1
+
+set -e
+
+mkdir obj
+
+cat >>configure.in << 'END'
+AC_CONFIG_FILES(obj/Makefile)
+AC_OUTPUT
+END
+
+: > obj/Makefile.am
+echo 'SUBDIRS = obj' >Makefile.am
+
+$ACLOCAL
+
+$AUTOMAKE 2>stderr && exit 1
+cat stderr
+grep 'obj.*BSD' stderr
+
+cat >Makefile.am <<EOF
+SUBDIRS = @STH@
+DIST_SUBDIRS = obj
+EOF
+
+$AUTOMAKE 2>stderr && exit 1
+cat stderr
+grep 'obj.*BSD' stderr
--
Alexandre Duret-Lutz
- FYI: warn if `obj' occurs in SUBDIRS.,
Alexandre Duret-Lutz <=