* automake.in (require_build_directory): New function, extracted
authorAlexandre Duret-Lutz <adl@gnu.org>
Thu, 19 Jul 2001 07:49:13 +0000 (07:49 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Thu, 19 Jul 2001 07:49:13 +0000 (07:49 +0000)
from ...
(handle_single_transform_list): ... here.
(require_build_directory_maybe): New function.
(handle_prograns, handle_libraries, handle_ltlibraries): Call
require_build_directory_maybe() to ensure the subdirectory
in which a target may lie will exist when the target is created.
(handle_libraries, handle_ltlibraries): Use basename before
checking library name.
* lib/am/library.am (%LIBRARY%): Depend on %DIRSTAMP%.
* lib/am/ltlibrary.am (%LTLIBRARY%): Likewise.
* lib/am/program.am (%PROGRAM%): Likewise.

ChangeLog
automake.in
lib/am/library.am
lib/am/ltlibrary.am
lib/am/program.am

index e0856ef..bd71d11 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2001-07-18  Alexandre Duret-Lutz  <duret_g@epita.fr>
+
+       * automake.in (require_build_directory): New function, extracted
+       from ...
+       (handle_single_transform_list): ... here.
+       (require_build_directory_maybe): New function.
+       (handle_prograns, handle_libraries, handle_ltlibraries): Call
+       require_build_directory_maybe() to ensure the subdirectory
+       in which a target may lie will exist when the target is created.
+       (handle_libraries, handle_ltlibraries): Use basename before
+       checking library name.
+       * lib/am/library.am (%LIBRARY%): Depend on %DIRSTAMP%.
+       * lib/am/ltlibrary.am (%LTLIBRARY%): Likewise.
+       * lib/am/program.am (%PROGRAM%): Likewise.
+
 2001-07-18  Tim Van Holder  <tim.van.holder@pandora.be>
 
        * m4/missing.m4: Reword comment.
index 342d079..a15ceb3 100755 (executable)
@@ -2001,34 +2001,13 @@ sub handle_single_transform_list ($$$@)
                # Make sure object is removed by `make mostlyclean'.
                $compile_clean_files{$object} = $MOSTLY_CLEAN;
 
-                push (@dep_list, $directory . '/.dirstamp');
+                push (@dep_list, &require_build_directory ($directory));
 
                 # If we're generating dependencies, we also want
                 # to make sure that the appropriate subdir of the
                 # .deps directory is created.
-                if ($use_dependencies)
-                {
-                    push (@dep_list, '.deps/' . $directory . '/.dirstamp');
-                }
-
-                if (! defined $directory_map{$directory})
-                {
-                    $directory_map{$directory} = 1;
-
-                   # Directory must be removed by `make distclean'.
-                   $compile_clean_files{$directory . "/.dirstamp"} =
-                       $DIST_CLEAN;
-                    $output_rules .= ($directory . "/.dirstamp:\n"
-                                      . "\t\@\$(mkinstalldirs) $directory\n"
-                                      . "\t\@: > $directory/.dirstamp\n");
-                    if ($use_dependencies)
-                    {
-                        $output_rules .= ('.deps/' . $directory
-                                          . "/.dirstamp:\n"
-                                          . "\t\@\$(mkinstalldirs) .deps/$directory\n"
-                                          . "\t\@: > .deps/$directory/.dirstamp\n");
-                    }
-                }
+               push (@dep_list, &require_build_directory (".deps/$directory"))
+                   if ($use_dependencies);
             }
 
             &pretty_print_rule ($object . ':', "\t", @dep_list)
@@ -2479,10 +2458,15 @@ sub handle_programs
            $xlink = $linker ? $linker : 'LINK';
        }
 
+       # If the resulting program lies into a subdirectory,
+       # make sure this directory will exist.
+       my $dirstamp = &require_build_directory_maybe ($one_file);
+
        $output_rules .= &file_contents ('program',
                                         ('PROGRAM'  => $one_file,
                                          'XPROGRAM' => $xname,
-                                         'XLINK'    => $xlink));
+                                         'XLINK'    => $xlink,
+                                         'DIRSTAMP' => $dirstamp));
     }
 
     if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD'))
@@ -2539,7 +2523,7 @@ sub handle_libraries
     foreach my $onelib (@liblist)
     {
        # Check that the library fits the standard naming convention.
-       if ($onelib !~ m%^(?:.*/)?lib[^/]*\.a$%)
+       if (basename ($onelib) !~ /^lib.*\.a/)
        {
            # FIXME should put line number here.  That means mapping
            # from library name back to variable name.
@@ -2584,9 +2568,14 @@ sub handle_libraries
 
        &handle_source_transform ($xlib, $onelib, $obj);
 
+       # If the resulting library lies into a subdirectory,
+       # make sure this directory will exist.
+       my $dirstamp = &require_build_directory_maybe ($onelib);
+
        $output_rules .= &file_contents ('library',
                                         ('LIBRARY'  => $onelib,
-                                         'XLIBRARY' => $xlib));
+                                         'XLIBRARY' => $xlib,
+                                         'DIRSTAMP' => $dirstamp));
     }
 
     if ($seen_libobjs)
@@ -2672,7 +2661,7 @@ sub handle_ltlibraries
                # Relax name checking for libtool modules.
                $libname_rx = "\.la";
        }
-       if ($onelib !~ /$libname_rx$/)
+       if (basename ($onelib) !~ /$libname_rx$/)
        {
            # FIXME this should only be a warning for foreign packages
            # FIXME should put line number here.  That means mapping
@@ -2734,11 +2723,16 @@ sub handle_ltlibraries
            $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
        }
 
+       # If the resulting library lies into a subdirectory,
+       # make sure this directory will exist.
+       my $dirstamp = &require_build_directory_maybe ($onelib);
+
        $output_rules .= &file_contents ('ltlibrary',
                                         ('LTLIBRARY'  => $onelib,
                                          'XLTLIBRARY' => $xlib,
                                          'RPATH'      => $rpath,
-                                         'XLINK'      => $xlink));
+                                         'XLINK'      => $xlink,
+                                         'DIRSTAMP'   => $dirstamp));
     }
 
     if ($seen_libobjs)
@@ -7646,6 +7640,54 @@ sub require_conf_file_with_conf_line
 
 ################################################################
 
+# &require_build_directory ($DIRECTORY)
+# ------------------------------------
+# Emit rules to create $DIRECTORY if needed, and return
+# the file that any target requiring this directory should be made
+# dependent upon.
+sub require_build_directory ($)
+{
+    my $directory = shift;
+    my $dirstamp = "$directory/.dirstamp";
+
+    # Don't emit the rule twice.
+    if (! defined $directory_map{$directory})
+    {
+       $directory_map{$directory} = 1;
+
+       # Directory must be removed by `make distclean'.
+       $compile_clean_files{$dirstamp} = $DIST_CLEAN;
+
+       $output_rules .= ("$dirstamp:\n"
+                         . "\t\@\$(mkinstalldirs) $directory\n"
+                         . "\t\@: > $dirstamp\n");
+    }
+
+    return $dirstamp;
+}
+
+# &require_build_directory_maybe ($FILE)
+# --------------------------------------
+# If $FILE lies in a subdirectory, emit a rule to create this
+# directory and return the file that $FILE should be made
+# dependent upon.  Otherwise, just return the empty string.
+sub require_build_directory_maybe ($)
+{
+    my $file = shift;
+    my $directory = dirname ($file);
+
+    if ($directory ne '.')
+    {
+       return &require_build_directory ($directory);
+    }
+    else
+    {
+       return '';
+    }
+}
+
+################################################################
+
 # Push a list of files onto dist_common.
 sub push_dist_common
 {
index a9b8253..404a3ee 100644 (file)
@@ -15,7 +15,7 @@
 ## along with this program; if not, write to the Free Software
 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 ## 02111-1307, USA.
-%LIBRARY%: $(%XLIBRARY%_OBJECTS) $(%XLIBRARY%_DEPENDENCIES)
+%LIBRARY%: $(%XLIBRARY%_OBJECTS) $(%XLIBRARY%_DEPENDENCIES) %DIRSTAMP%
        -rm -f %LIBRARY%
        $(%XLIBRARY%_AR) %LIBRARY% $(%XLIBRARY%_OBJECTS) $(%XLIBRARY%_LIBADD)
        $(RANLIB) %LIBRARY%
index 276c70a..eb736de 100644 (file)
@@ -15,5 +15,5 @@
 ## along with this program; if not, write to the Free Software
 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 ## 02111-1307, USA.
-%LTLIBRARY%: $(%XLTLIBRARY%_OBJECTS) $(%XLTLIBRARY%_DEPENDENCIES)
+%LTLIBRARY%: $(%XLTLIBRARY%_OBJECTS) $(%XLTLIBRARY%_DEPENDENCIES) %DIRSTAMP%
        $(%XLINK%) %RPATH% $(%XLTLIBRARY%_LDFLAGS) $(%XLTLIBRARY%_OBJECTS) $(%XLTLIBRARY%_LIBADD) $(LIBS)
index 4879323..06e1313 100644 (file)
@@ -15,7 +15,7 @@
 ## along with this program; if not, write to the Free Software
 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 ## 02111-1307, USA.
-%PROGRAM%%EXEEXT%: $(%XPROGRAM%_OBJECTS) $(%XPROGRAM%_DEPENDENCIES)
+%PROGRAM%%EXEEXT%: $(%XPROGRAM%_OBJECTS) $(%XPROGRAM%_DEPENDENCIES) %DIRSTAMP%
 ## Remove program before linking.  Otherwise the link will fail if the
 ## program is running somewhere.  FIXME: this could be a loss if
 ## you're using an incremental linker.  Maybe we should think twice?