automake-patches
[Top][All Lists]
Advanced

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

Re: rewrite of m4/depout.m4


From: Ralf Wildenhues
Subject: Re: rewrite of m4/depout.m4
Date: Tue, 17 Apr 2007 19:02:13 +0200
User-agent: Mutt/1.5.15 (2007-04-11)

To continue an older issue with another post merely for your amusement
(prompted by Jim's bug report in
<http://thread.gmane.org/gmane.comp.sysutils.automake.bugs/3885>).

* Ralf Wildenhues wrote on Sat, May 06, 2006 at 06:13:25PM CEST:
> Let's un-bitrot _AM_OUTPUT_DEPENDENCY_COMMANDS and make it nice and
> fast.  We observe:
[...]

FWIW, here's another, *really* crazy attempt, making it more hackish and
more powerful but slower.   Posted for amusement mostly.  ;-)

The motivation to do this was to work towards allowing non-static
content in *_SOURCES variables, so that it works even with
subdir-objects.  IOW, one stepping stone to eventually allow
  bin_PROGRAMS = foo
  mydir = foo/bar
  foo_SOURCES = $(mydir)/a1.c

The patch is missing documentation stating that, for a makefile named
$Makefile, a temporary file named t$Makefile will be created and removed
during the `depfiles' stage.

No, I don't really want this applied.

I think the killer argument against this change is the point that a
buggy Makefile has worse consequences, starting from spurious errors
at config.status time, and not ending in an infinite configure recheck
loop.

Cheers,
Ralf

        Use `make' to generate the dependency files.
        * automake.in (handle_languages, handle_single_transform): Avoid
        `./' prefix before `$(DEPDIR)'.
        (handle_LIBOBJS, handle_ALLOCA): Call `require_build_directory'
        for the depdir, to allow the dependency generation to work.
        * m4/depout.m4 (_AM_OUTPUT_DEPENDENCY_COMMANDS)
        (AM_OUTPUT_DEPENDENCY_COMMANDS): Set `ac_aux_dir' and `am_make'.
        Remove the FIXME in the comment: AM_OUTPUT_DEPENDENCY_COMMANDS
        is not expanded if `no-dependencies' is an option to
        AM_INIT_AUTOMAKE.

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1641
diff -u -r1.1641 automake.in
--- automake.in 16 Oct 2006 05:24:17 -0000      1.1641
+++ automake.in 29 Nov 2006 19:43:11 -0000
@@ -1259,7 +1261,7 @@
            #
            # In the latter case the rule is used to build objects
            # in the current directory, and dependencies always
-           # go into `./$(DEPDIR)/'.  We can hard-code this value.
+           # go into `$(DEPDIR)/'.  We can hard-code this value.
            #
            # In the former case the rule can be used to build
            # objects in sub-directories too.  Dependencies should
@@ -1910,8 +1912,10 @@
                 # If we're generating dependencies, we also want
                 # to make sure that the appropriate subdir of the
                 # .deps directory is created.
+               my $depdir = ($directory eq '' || $directory eq '.' ?
+                             '' : $directory . '/') . '$(DEPDIR)';
                push (@dep_list,
-                     require_build_directory ($directory . '/$(DEPDIR)'))
+                     require_build_directory ($depdir))
                  unless option 'no-dependencies';
             }
 
@@ -1926,7 +1930,8 @@
             my $depfile = $object;
             $depfile =~ s/\.([^.]*)$/.P$1/;
             $depfile =~ s/\$\(OBJEXT\)$/o/;
-            $dep_files{dirname ($depfile) . '/$(DEPDIR)/'
+           my $depdir = dirname ($depfile);
+            $dep_files{($depdir eq '.' ? '' : $depdir . '/') . '$(DEPDIR)/'
                         . basename ($depfile)} = 1;
         }
     }
@@ -2249,6 +2253,7 @@
          my $rewrite = $iter;
          $rewrite =~ s/\.c$/.P$myobjext/;
          $dep_files{$dir . '$(DEPDIR)/' . $rewrite} = 1;
+         require_build_directory ($dir . '$(DEPDIR)');
          $rewrite = "^" . quotemeta ($iter) . "\$";
          # Only require the file if it is not a built source.
          my $bs = var ('BUILT_SOURCES');
@@ -2269,6 +2274,7 @@
 
   $var->requires_variables ("address@hidden@ used", $lt . 'ALLOCA');
   $dep_files{$dir . '$(DEPDIR)/alloca.P' . $myobjext} = 1;
+  require_build_directory ($dir . '$(DEPDIR)');
   require_libsource_with_macro ($cond, $var, FOREIGN, 'alloca.c');
   &saw_extension ('.c');
 }
Index: m4/depout.m4
===================================================================
RCS file: /cvs/automake/automake/m4/depout.m4,v
retrieving revision 1.19
diff -u -r1.19 depout.m4
--- m4/depout.m4        6 Jun 2006 20:39:22 -0000       1.19
+++ m4/depout.m4        29 Nov 2006 18:56:21 -0000
@@ -24,32 +24,24 @@
   # limit of 2048, but all sed's we know have understand at least 4000.
   if sed 10q "$mf" | grep '^#.*generated by automake' > /dev/null 2>&1; then
     dirpart=`AS_DIRNAME("$mf")`
+    mfile=`AS_BASENAME("$mf")`
   else
     continue
   fi
-  # Extract the definition of DEPDIR, am__include, and am__quote
-  # from the Makefile without running `make'.
-  DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
-  test -z "$DEPDIR" && continue
-  am__include=`sed -n 's/^am__include = //p' < "$mf"`
-  test -z "am__include" && continue
-  am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-  # When using ansi2knr, U may be empty or an underscore; expand it
-  U=`sed -n 's/^U = //p' < "$mf"`
-  # Find all dependency output files, they are included files with
-  # $(DEPDIR) in their names.  We invoke sed twice because it is the
-  # simplest approach to changing $(DEPDIR) to its actual value in the
-  # expansion.
-  for file in `sed -n "
-    s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-       sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
-    # Make sure the directory exists.
-    test -f "$dirpart/$file" && continue
-    fdir=`AS_DIRNAME(["$file"])`
-    AS_MKDIR_P([$dirpart/$fdir])
-    # echo "creating $dirpart/$file"
-    echo '# dummy' > "$dirpart/$file"
-  done
+  ( cd "$dirpart" &&
+    sed '$a\
+am__depfiles:
+       s&^'"$am__include $am__quote"'\(\$(DEPDIR)/.*\)'"$am__quote"'$&\1:\
+\      test -d $(DEPDIR) || mkdir $(DEPDIR)\
+\      test -f $[]@ || echo >address@hidden
+am__depfiles: \1&;t
+       s&^'"$am__include 
$am__quote"'\(.*(DEPDIR)/\)\(.*\)'"$am__quote"'$&\1\2: \1$(am__dirstamp)\
+\      test -f $[]@ || echo >address@hidden
+am__depfiles: \1\2&;t
+' < "$mfile" >"t$mfile" &&
+    $am_make -s -f "t$mfile" am__depfiles
+    rm -f "t$mfile"
+  )
 done
 ])# _AM_OUTPUT_DEPENDENCY_COMMANDS
 
@@ -59,10 +51,12 @@
 # This macro should only be invoked once -- use via AC_REQUIRE.
 #
 # This code is only required when automatic dependency tracking
-# is enabled.  FIXME.  This creates each `.P' file that we will
-# need in order to bootstrap the dependency handling code.
+# is enabled.  This creates each `.P' file that we will need in
+# order to bootstrap the dependency handling code.
 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 [AC_CONFIG_COMMANDS([depfiles],
-     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
-     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+     [test x"$AMDEP_TRUE" != x || test x"$am__include" == "x#" ||
+       _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" am_make="$am_make"
+      am__include="$am__include" am__quote='$am__quote'])
 ])




reply via email to

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