From: Gary V. Vaughan Date: Thu, 10 Nov 2011 11:27:51 +0000 (+0700) Subject: libtoolize: simplify copying of files that are edited during install. X-Git-Tag: v2.4.2.418~265 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb82543f615145b78d2185c45b1abd98d0abf79b;p=thirdparty%2Flibtool.git libtoolize: simplify copying of files that are edited during install. * libltdl/Makefile.inc (EXTRA_DIST): Don't list autotools files that Automake automatically adds to a (subproject) distribution... * Makefile.am (EXTRA_DIST): ...although, our layout is a bit odd because we reuse libltdl/Makefile.inc in non-recursive mode in our own tree, so we do need to add those very same files here... * libtoolize.m4sh (require_Makefile_am_filter) (require_Makefile_inc_filter): ...all of which means we no longer need to manually remove those files at libtoolize time. These two new functions are factored out of... (func_fixup_Makefile): ...this old function, now removed. (func_copy): Add support for an optional sed script as the last argument to filter the content of a file as it is copied. (func_install_pkgltdl_files): Much simplified by $require_ the relevant filter scripts and passing them to func_copy. Signed-off-by: Gary V. Vaughan --- diff --git a/Makefile.am b/Makefile.am index ab6a10662..b79cad810 100644 --- a/Makefile.am +++ b/Makefile.am @@ -337,11 +337,19 @@ include libltdl/Makefile.inc lt_aclocal_m4 = $(srcdir)/$(ltdl_dir)/aclocal.m4 lt_config_h_in = $(srcdir)/$(ltdl_dir)/config-h.in lt_configure = $(srcdir)/$(ltdl_dir)/configure +lt_configure_ac = $(srcdir)/$(ltdl_dir)/configure.ac stamp_mk = $(srcdir)/$(ltdl_dir)/stamp-mk lt_obsolete_m4 = $(srcdir)/$(macro_dir)/lt~obsolete.m4 -EXTRA_DIST += $(stamp_mk) $(lt_obsolete_m4) +EXTRA_DIST += $(lt_aclocal_m4) \ + $(lt_configure) \ + $(lt_configure_ac) \ + $(lt_config_h_in) \ + $(lt_Makefile_am) \ + $(lt_Makefile_in) \ + $(lt_obsolete_m4) \ + $(stamp_mk) $(lt_Makefile_in): $(lt_Makefile_am) $(lt_aclocal_m4) $(AM_V_GEN)cd '$(srcdir)/$(ltdl_dir)' && $(AUTOMAKE) Makefile diff --git a/libltdl/Makefile.inc b/libltdl/Makefile.inc index 931b68d0b..0e5384899 100644 --- a/libltdl/Makefile.inc +++ b/libltdl/Makefile.inc @@ -126,12 +126,6 @@ CLEANFILES += libltdl/libltdl.la \ CLEANFILES += $(LIBOBJS) $(LTLIBOBJS) EXTRA_DIST += libltdl/COPYING.LIB \ - libltdl/configure.ac \ - libltdl/Makefile.am \ - libltdl/aclocal.m4 \ - libltdl/Makefile.in \ - libltdl/configure \ - libltdl/config-h.in \ libltdl/README ## --------------------------- ## diff --git a/libtoolize.m4sh b/libtoolize.m4sh index beef5ef97..f868757b6 100644 --- a/libtoolize.m4sh +++ b/libtoolize.m4sh @@ -213,12 +213,13 @@ func_whisper_error_hdr () } -# func_copy filename srcdir destdir [msg_var] +# func_copy filename srcdir destdir [msg_var [filter]] # If option `--copy' was specified, or soft-linking SRCFILE to DESTFILE # fails, then try to copy SRCFILE to DESTFILE (making sure to update the # timestamp so that a series of files with dependencies can be copied -# in the right order that their timestamps won't trigger rebuilds). -# MSG_VAR names a variable for use with func_whisper_hdr. +# in the right order that their timestamps won't trigger rebuilds). If +# FILTER is non-empty, it is a sed script to apply to SRCFILE as it is +# copied. MSG_VAR names a variable for use with func_whisper_hdr. func_copy () { $debug_cmd @@ -227,6 +228,7 @@ func_copy () my_srcdir=$2 my_destdir=$3 my_msg_var=$4 + my_filter=$5 my_srcfile=$my_srcdir/$my_filename my_destfile=$my_destdir/$my_filename @@ -249,7 +251,28 @@ func_copy () func_dirname "$my_destfile" func_mkdir_p "$func_dirname_result" - # Copy or link according to `--copy' option. + # Filters always take priority. + if test -n "$my_filter"; then + if $opt_dry_run || { + ( umask 0 + $SED -e "$my_filter" "$my_srcfile" > "$my_destfile" + ) >/dev/null 2>&1 + } + then + func_whisper_once "$my_msg_var" + if $opt_verbose; then + func_whisper "$SED -e '$my_filter' $my_srcfile > $my_destfile" + else + func_whisper "creating file \`$my_destfile'" + fi + else + func_whisper_error_hdr "$my_msg_var" "creating \`$my_destfile' from \`$my_srcfile' failed" + return 1 + fi + return 0 + fi + + # Otherwise copy or link according to `--copy' option. if $opt_copy; then my_copycmd=$CP my_copy_type=copying @@ -275,59 +298,6 @@ func_copy () } -# func_fixup_Makefile srcfile srcdir destdir -func_fixup_Makefile () -{ - $debug_cmd - - $require_ltdl_dir - - my_filename="$1" - my_srcdir="$2" - my_destdir="$3" - my_fixup_non_subpackage_script='/^[^#]/{ - s,(LIBOBJS),(ltdl_LIBOBJS),g - s,(LTLIBOBJS),(ltdl_LTLIBOBJS),g - s,libltdl/configure.ac,, - s,libltdl/configure,, - s,libltdl/aclocal.m4,, - s,libltdl/config-h.in,, - s,libltdl/Makefile.am,, - s,libltdl/Makefile.in,, - /^[ ]*\\\\$/d - }' - case $my_filename in - Makefile.am) - my_fixup_non_subpackage_script=`echo "$my_fixup_non_subpackage_script" | \ - sed 's,libltdl/,,'` - my_fixup_inc_paths_script= ;; - Makefile.inc) - repl=$ltdl_dir - repl_uscore=`$ECHO "$repl" | $SED 's,[/.+-],_,g'` - my_fixup_inc_paths_script="\ - s,libltdl_,@repl_uscore@_, - s,libltdl/,@repl@/, - s,: libltdl/,: @repl@/, - s, -Ilibltdl , -I@repl@ , - s,\\\$(libltdl_,\$(@repl_uscore@_, - s,)/libltdl ,)/@repl@ , - s,@repl_uscore@,${repl_uscore},g - s,@repl@,${repl},g" - ;; - esac - - $RM "$my_destdir/$my_filename" 2>/dev/null - func_whisper "creating file \`$my_destdir/$my_filename'" - if $opt_dry_run; then :; - else - $SED "$my_fixup_non_subpackage_script - $my_fixup_inc_paths_script" \ - < "$my_srcdir/$my_filename" > "$my_destdir/$my_filename" || - func_fatal_error "cannot create $my_destdir/$my_filename" - fi -} - - # func_extract_trace macro_name [filename ...] # set `$func_extract_trace_result' to a colon delimited list of arguments # to MACRO_NAME in FILENAME. If no FILENAME is given, then @@ -880,35 +850,45 @@ func_install_pkgltdl_files () pkgltdl_header="putting libltdl files in \`$ltdl_dir'." fi + $require_Makefile_am_filter + $require_Makefile_inc_filter + # Copy ltdl sources appropriate to the requested ltdl_mode. for file in $pkgltdl_files; do + my_copy_filter= case $file in Makefile.am|Makefile.in) - test recursive = "$ltdl_mode" \ - && func_fixup_Makefile "$file" "$pkgltdldir" "$ltdl_dir" - test subproject = "$ltdl_mode" \ - && func_copy "$file" "$pkgltdldir" "$ltdl_dir" pkgltdl_header + case $ltdl_mode in + nonrecursive) continue ;; + recursive) my_copy_filter=$Makefile_am_filter ;; + *) ;; # fall through to unfiltered func_copy + esac ;; + Makefile.inc) - test nonrecursive = "$ltdl_mode" \ - && func_fixup_Makefile "$file" "$pkgltdldir" "$ltdl_dir" + test nonrecursive = "$ltdl_mode" || continue + my_copy_filter=$Makefile_inc_filter ;; + aclocal.m4|configure) # Always copy aclocal.m4 and configure, otherwise regenerating # them can overwrite the destination if they are symlinked. - test subproject = "$ltdl_mode" || continue - ( opt_copy=: - func_copy "$file" "$pkgltdldir" "$ltdl_dir" pkgltdl_header - ) + test subproject = "$ltdl_mode" && { + ( opt_copy=: + func_copy "$file" "$pkgltdldir" "$ltdl_dir" pkgltdl_header + ) + } + continue ;; + config-h.in|configure.ac) - test subproject = "$ltdl_mode" \ - && func_copy "$file" "$pkgltdldir" "$ltdl_dir" pkgltdl_header - ;; - *) - func_copy "$file" "$pkgltdldir" "$ltdl_dir" pkgltdl_header + test subproject = "$ltdl_mode" || continue ;; esac + + # Still here? Copy the file then, with selected filters. + func_copy "$file" "$pkgltdldir" "$ltdl_dir" \ + pkgltdl_header "$my_copy_filter" done } @@ -1212,6 +1192,64 @@ func_autoconf_configure () # most, once. +# require_Makefile_am_filter +# -------------------------- +# Set `Makefile_am_filter' ready for passing to func_copy when libltdl's +# stock Makefile.am contents need to be filtered to work in recursive +# mode. +require_Makefile_am_filter=func_require_Makefile_am_filter +func_require_Makefile_am_filter () +{ + $debug_cmd + + Makefile_am_filter=' + /^[^#]/{ + s,(LIBOBJS),(ltdl_LIBOBJS),g + s,(LTLIBOBJS),(ltdl_LTLIBOBJS),g + }' + + require_Makefile_am_filter=: +} + + +# require_Makefile_inc_filter +# --------------------------- +# Set `Makefile_inc_filter' ready for passing to func_copy in order for +# the contents of Makefile.inc to match the nonrecursive libltdl +# directory into which it is copied. +require_Makefile_inc_filter=func_require_Makefile_inc_filter +func_require_Makefile_inc_filter () +{ + $debug_cmd + + $require_ltdl_dir + + # Note that we strip comments right here, rather than rely on + # using a $SED that allows comments. + my_uscore=`$ECHO "$ltdl_dir" | $SED 's,[/.+-],_,g'` + Makefile_inc_filter=`$ECHO ' + /^[^#]/{ + + # Use only libltdl conditional objects. + s,(LIBOBJS),(ltdl_LIBOBJS),g + s,(LTLIBOBJS),(ltdl_LTLIBOBJS),g + + # Convert libltdl path and variable sections to $ltdl_dir. + s,libltdl_,@my_uscore@_, + s,libltdl/,@ltdl_dir@/, + s,: libltdl/,: @ltdl_dir@/, + s, -Ilibltdl , -I@ltdl_dir@ , + s,\$(libltdl_,\$(@my_uscore@_, + s,)/libltdl ,)/@ltdl_dir@ , + s,@my_uscore@,'"$my_uscore"',g + s,@ltdl_dir@,'"$ltdl_dir"',g + + }' | $SED '/^[ ]*#/d;/^$/d'` + + require_Makefile_inc_filter=: +} + + # require_ac_aux_dir # ------------------ # Extract ac_aux_dir from AC_CONFIG_AUX_DIR.