automake-patches
[Top][All Lists]
Advanced

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

Re: allow convenient library in subdirectory


From: Alexandre Duret-Lutz
Subject: Re: allow convenient library in subdirectory
Date: 18 Jul 2001 12:50:06 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Ok, second try.

Note I've tested the change for programs and convenient
libraries but not libtool libraries (I've never used libtool
yet).

Index: ChangeLog
from  Alexandre Duret-Lutz  <address@hidden>

        * 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.
        * lib/am/library.am (%LIBRARY%): Depend on %DIRSTAMP%.
        * lib/am/ltlibrary.am (%LTLIBRARY%): Likewise.
        * lib/am/program.am (%PROGRAM%): Likewise.

Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1154
diff -u -r1.1154 automake.in
--- automake.in 2001/07/17 05:53:47 1.1154
+++ automake.in 2001/07/18 10:48:08
@@ -2001,34 +2001,13 @@
                # 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"
-                                      . "address@hidden(mkinstalldirs) 
$directory\n"
-                                      . "\t\@: > $directory/.dirstamp\n");
-                    if ($use_dependencies)
-                    {
-                        $output_rules .= ('.deps/' . $directory
-                                          . "/.dirstamp:\n"
-                                          . "address@hidden(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 @@
            $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 @@
     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 @@
 
        &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)
@@ -2734,11 +2723,16 @@
            $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)
@@ -7642,6 +7636,50 @@
     @config_aux_path = @require_file_paths;
     # avoid unsightly '/.'s.
     $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
+}
+
+################################################################
+
+# &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"
+                         . "address@hidden(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 '';
+    }
 }
 
 ################################################################
Index: lib/am/library.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/library.am,v
retrieving revision 1.13
diff -u -r1.13 library.am
--- lib/am/library.am 2001/02/27 09:12:42 1.13
+++ lib/am/library.am 2001/07/18 10:48:08
@@ -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: lib/am/ltlibrary.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/ltlibrary.am,v
retrieving revision 1.4
diff -u -r1.4 ltlibrary.am
--- lib/am/ltlibrary.am 2001/02/27 09:12:42 1.4
+++ lib/am/ltlibrary.am 2001/07/18 10:48:08
@@ -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: lib/am/program.am
===================================================================
RCS file: /cvs/automake/automake/lib/am/program.am,v
retrieving revision 1.22
diff -u -r1.22 program.am
--- lib/am/program.am 2001/07/05 01:19:35 1.22
+++ lib/am/program.am 2001/07/18 10:48:08
@@ -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?

-- 
Alexandre Duret-Lutz





reply via email to

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