From: Alexandre Duret-Lutz Date: Thu, 19 Jul 2001 07:49:13 +0000 (+0000) Subject: * automake.in (require_build_directory): New function, extracted X-Git-Tag: Release-1-4j~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88ba6d7a137203664da031c6dd48921819c9a53f;p=thirdparty%2Fautomake.git * 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. --- diff --git a/ChangeLog b/ChangeLog index e0856efea..bd71d11ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2001-07-18 Alexandre Duret-Lutz + + * 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 * m4/missing.m4: Reword comment. diff --git a/automake.in b/automake.in index 342d0796c..a15ceb310 100755 --- a/automake.in +++ b/automake.in @@ -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 { diff --git a/lib/am/library.am b/lib/am/library.am index a9b825332..404a3ee12 100644 --- a/lib/am/library.am +++ b/lib/am/library.am @@ -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% diff --git a/lib/am/ltlibrary.am b/lib/am/ltlibrary.am index 276c70a02..eb736de45 100644 --- a/lib/am/ltlibrary.am +++ b/lib/am/ltlibrary.am @@ -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) diff --git a/lib/am/program.am b/lib/am/program.am index 487932327..06e1313c9 100644 --- a/lib/am/program.am +++ b/lib/am/program.am @@ -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?