From: Tom Tromey Date: Fri, 25 Apr 1997 18:31:57 +0000 (+0000) Subject: config header patch from Ian X-Git-Tag: pre-ian-conditionals~20 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=be107a4ef828d7225551b66d1794ec969f060ce1;p=thirdparty%2Fautomake.git config header patch from Ian --- diff --git a/ChangeLog b/ChangeLog index 18b0f0121..52e99a8df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Mon Apr 21 12:35:57 1997 Ian Lance Taylor + + * automake.in (@config_fullnames): New array. + (@config_names): New array, replacing $config_name. + (@config_headers): New array, replacing $config_header. + (get_object_extension): Handle multiple header files. + (handle_tags, handle_merge_targets): Likewise. + (scan_one_configure_file): Likewise. + (handle_configure): Likewise. Don't check for the configuration + header file in AC_OUTPUT; it won't be there. + * remake-hdr.am: Handle multiple header files. + * clean-hdr.am: New file, broken out of remake-hdr.am. + * m4/header.m4: Handle multiple header files. + * Makefile.am (pkgdata_DATA): Add clean-hdr.am. + Wed Apr 16 00:05:47 1997 Tom Tromey * texinfos.am (.texi.info, .texi, .texinfo.info, .info): Remove diff --git a/Makefile.am b/Makefile.am index 27af5e556..4c1d6aab6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,7 +8,7 @@ SUBDIRS = tests m4 bin_SCRIPTS = automake aclocal info_TEXINFOS = automake.texi -pkgdata_DATA = clean-kr.am clean.am compile-kr.am comp-vars.am \ +pkgdata_DATA = clean-kr.am clean.am clean-hdr.am compile-kr.am comp-vars.am \ compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am \ footer.am header.am header-vars.am kr-extra.am libs.am library.am \ libtool.am ltlib.am ltlibrary.am mans-vars.am program.am progs.am \ diff --git a/Makefile.in b/Makefile.in index c163b0efe..b65417ebd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -67,7 +67,7 @@ SUBDIRS = tests m4 bin_SCRIPTS = automake aclocal info_TEXINFOS = automake.texi -pkgdata_DATA = clean-kr.am clean.am compile-kr.am comp-vars.am \ +pkgdata_DATA = clean-kr.am clean.am clean-hdr.am compile-kr.am comp-vars.am \ compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am \ footer.am header.am header-vars.am kr-extra.am libs.am library.am \ libtool.am ltlib.am ltlibrary.am mans-vars.am program.am progs.am \ diff --git a/automake.in b/automake.in index 6593b9623..0960e8d4d 100755 --- a/automake.in +++ b/automake.in @@ -97,12 +97,14 @@ $add_missing = 0; # True if AM_C_PROTOTYPES appears in configure.in. $am_c_prototypes = 0; -# Names used in AC_CONFIG_HEADER call. $config_name is the actual -# (first) argument. $config_header is the '.in' file. Ordinarily the -# second is derived from the first, but they can be different if the -# weird "NAME:FILE" syntax is used. -$config_name = ''; -$config_header = ''; +# Names used in AC_CONFIG_HEADER call. @config_fullnames holds the +# name which appears in AC_CONFIG_HEADER, colon and all. +# @config_names holds the file names. @config_headers holds the '.in' +# files. Ordinarily these are similar, but they can be different if +# the weird "NAME:FILE" syntax is used. +@config_fullnames = (); +@config_names = (); +@config_headers = (); # Line number at which AC_CONFIG_HEADER appears in configure.in. $config_header_line = 0; @@ -672,9 +674,14 @@ sub get_object_extension local ($xform) = ''; if (&variable_defined ('CONFIG_HEADER')) { - ($xform = &dirname ($contents{'CONFIG_HEADER'})) - =~ s/(\W)/\\$1/g; - $xform = '-I' . $xform; + local ($one_hdr); + foreach $one_hdr (split (' ', $contents{'CONFIG_HEADER'})) + { + local ($var); + ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g; + $xform .= ' ' if $xform; + $xform .= '-I' . $var; + } } $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;'; $output_vars .= &file_contents_with_transform ($xform, @@ -2096,10 +2103,17 @@ sub handle_tags || @tag_deps) { local ($xform) = ''; - if ($config_header && $relative_dir eq &dirname ($config_header)) + local ($one_hdr); + foreach $one_hdr (@config_headers) { - # The config header is in this directory. So require it. - ($xform = &basename ($config_header)) =~ s/(\W)/\\$1/g; + if ($relative_dir eq &dirname ($one_hdr)) + { + # The config header is in this directory. So require it. + local ($var); + ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g; + $xform .= ' ' if $xform; + $xform .= $var; + } } $xform = ('s/\@CONFIG\@/' . $xform . '/;' . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;'); @@ -2787,43 +2801,72 @@ sub handle_configure } # If we have a configure header, require it. - if ($config_header && $relative_dir eq &dirname ($config_header)) - { - local ($ch_sans_dir) = &basename ($config_header); - local ($cn_sans_dir) = &basename ($config_name); + local ($one_hdr); + local (@local_fullnames) = @config_fullnames; + local (@local_names) = @config_names; + local ($hdr_index) = 0; + local ($distclean_config) = ''; + foreach $one_hdr (@config_headers) + { + local ($one_fullname) = shift (@local_fullnames); + local ($one_name) = shift (@local_names); + $hdr_index += 1; + if ($relative_dir eq &dirname ($one_hdr)) + { + local ($ch_sans_dir) = &basename ($one_hdr); + local ($cn_sans_dir) = &basename ($one_name); + + &require_file_with_conf_line ($config_header_line, + $FOREIGN, $ch_sans_dir); + + # Header defined and in this directory. + local (@files); + if (-f $relative_dir . '/acconfig.h') + { + push (@files, 'acconfig.h'); + } + if (-f $one_name . '.top') + { + push (@files, "${cn_sans_dir}.top"); + } + if (-f $one_name . '.bot') + { + push (@files, "${cn_sans_dir}.bot"); + } - &require_file_with_conf_line ($config_header_line, - $FOREIGN, $ch_sans_dir); + &push_dist_common (@files); - # Header defined and in this directory. - local (@files); - if (-f $relative_dir . '/acconfig.h') - { - push (@files, 'acconfig.h'); - } - if (-f $config_name . '.top') - { - push (@files, "${cn_sans_dir}.top"); - } - if (-f $config_name . '.bot') - { - push (@files, "${cn_sans_dir}.bot"); + local ($stamp_name) = 'stamp-h'; + $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1; + + local ($xform) = ''; + + $xform = 's/\@FILES\@/' . join (' ', @files) . '/;'; + $xform .= 's/\@CONFIG_HEADER\@/' . "${cn_sans_dir}" . '/;'; + $xform .= 's/\@CONFIG_HEADER_IN\@/' . "${ch_sans_dir}" . '/;'; + $xform .= 's/\@CONFIG_HEADER_FULL\@/' . "${one_fullname}" . '/;'; + $xform .= 's/\@STAMP\@/' . "${stamp_name}" . '/;'; + + $output_rules .= &file_contents_with_transform ($xform, + 'remake-hdr'); + + &touch ($relative_dir . "/${stamp_name}.in"); + &require_file_with_conf_line ($config_header_line, $FOREIGN, + "${stamp_name}.in"); + + $distclean_config .= ' ' if $distclean_config; + $distclean_config .= $cn_sans_dir; } + } - &push_dist_common (@files); + if ($distclean_config) + { $output_rules .= &file_contents_with_transform ('s/\@FILES\@/' - . join (' ', @files) + . $distclean_config . '/;', - 'remake-hdr'); - - &touch ($relative_dir . '/stamp-h.in'); - &require_file_with_conf_line ($config_header_line, $FOREIGN, - 'stamp-h.in'); - + 'clean-hdr'); push (@clean, 'hdr'); &push_phony_cleaners ('hdr'); - &define_variable ("CONFIG_HEADER_IN", "${ch_sans_dir}"); - &define_variable ('CONFIG_HEADER_FULL', $config_name); } # Set location of mkinstalldirs. @@ -2842,18 +2885,27 @@ sub handle_configure "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'") if &variable_defined ('CONFIG_HEADER'); - if ($config_name) + local ($one_name); + local ($config_header) = ''; + foreach $one_name (@config_names) { # Generate CONFIG_HEADER define. - if ($relative_dir eq &dirname ($config_name)) + local ($one_hdr); + if ($relative_dir eq &dirname ($one_name)) { - &define_variable ("CONFIG_HEADER", &basename ($config_name)); + $one_hdr = &basename ($one_name); } else { - &define_variable ("CONFIG_HEADER", - "${top_builddir}/${config_name}"); + $one_hdr = "${top_builddir}/${one_name}"; } + + $config_header .= ' ' if $config_header; + $config_header .= $one_hdr; + } + if ($config_header) + { + &define_variable ("CONFIG_HEADER", $config_header); } # Now look for other files in this directory which must be remade @@ -2883,9 +2935,6 @@ sub handle_configure # Skip files not in this directory. next unless &dirname ($file) eq $relative_dir; - # Skip the config header. - next if $local eq $top_builddir . '/' . $config_name; - # Skip any Makefile. next if $local eq 'Makefile'; @@ -3063,8 +3112,13 @@ sub handle_merge_targets } push (@all, 'Makefile'); - push (@all, &basename ($config_name)) - if $config_name && &dirname ($config_name) eq $relative_dir; + + local ($one_name); + foreach $one_name (@config_names) + { + push (@all, &basename ($one_name)) + if &dirname ($one_name) eq $relative_dir; + } &do_one_merge_target ('info', @info); &do_one_merge_target ('dvi', @dvi); @@ -3129,7 +3183,17 @@ sub handle_merge_targets if (@all) { local (@hackall) = (); - if ($config_name && &dirname ($config_name) eq $relative_dir) + local ($one_name); + local ($local_headers) = ''; + foreach $one_name (@config_names) + { + if (&dirname ($one_name) eq $relative_dir) + { + $local_headers .= ' ' if $local_headers; + $local_headers .= &basename ($one_name); + } + } + if ($local_headers) { # This is kind of a hack, but I couldn't see a better @@ -3139,7 +3203,7 @@ sub handle_merge_targets # dependencies to the "all" because that breaks when # using parallel makes. Instead we handle things # explicitly. - $output_rules .= ('all-recursive-am: $(CONFIG_HEADER)' + $output_rules .= ("all-recursive-am: ${local_headers}" . "\n\t" . '$(MAKE) all-recursive' . "\n\n"); push (@hackall, 'all-recursive-am'); @@ -3748,15 +3812,20 @@ sub scan_one_configure_file if $1 eq 'C'; $config_header_line = $.; - $config_name = $2; - if ($config_name =~ /^([^:]+):(.+)$/) - { - $config_name = $1; - $config_header = $2; - } - else + local ($one_hdr); + foreach $one_hdr (split (' ', $2)) { - $config_header = $config_name . '.in'; + push (@config_fullnames, $one_hdr); + if ($one_hdr =~ /^([^:]+):(.+)$/) + { + push (@config_names, $1); + push (@config_headers, $2); + } + else + { + push (@config_names, $one_hdr); + push (@config_headers, $one_hdr . '.in'); + } } } diff --git a/clean-hdr.am b/clean-hdr.am new file mode 100644 index 000000000..781b6f0c6 --- /dev/null +++ b/clean-hdr.am @@ -0,0 +1,25 @@ +## automake - create Makefile.in from Makefile.am +## Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2, or (at your option) +## any later version. + +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. + +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +## 02111-1307, USA. +mostlyclean-hdr: + +clean-hdr: + +distclean-hdr: + rm -f @FILES@ + +maintainer-clean-hdr: diff --git a/lib/am/Makefile.am b/lib/am/Makefile.am index 27af5e556..4c1d6aab6 100644 --- a/lib/am/Makefile.am +++ b/lib/am/Makefile.am @@ -8,7 +8,7 @@ SUBDIRS = tests m4 bin_SCRIPTS = automake aclocal info_TEXINFOS = automake.texi -pkgdata_DATA = clean-kr.am clean.am compile-kr.am comp-vars.am \ +pkgdata_DATA = clean-kr.am clean.am clean-hdr.am compile-kr.am comp-vars.am \ compile.am data.am dejagnu.am depend.am depend2.am dist-vars.am \ footer.am header.am header-vars.am kr-extra.am libs.am library.am \ libtool.am ltlib.am ltlibrary.am mans-vars.am program.am progs.am \ diff --git a/lib/am/clean-hdr.am b/lib/am/clean-hdr.am new file mode 100644 index 000000000..781b6f0c6 --- /dev/null +++ b/lib/am/clean-hdr.am @@ -0,0 +1,25 @@ +## automake - create Makefile.in from Makefile.am +## Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2, or (at your option) +## any later version. + +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. + +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +## 02111-1307, USA. +mostlyclean-hdr: + +clean-hdr: + +distclean-hdr: + rm -f @FILES@ + +maintainer-clean-hdr: diff --git a/lib/am/remake-hdr.am b/lib/am/remake-hdr.am index d63798a04..5088e82ec 100644 --- a/lib/am/remake-hdr.am +++ b/lib/am/remake-hdr.am @@ -15,22 +15,13 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -$(CONFIG_HEADER): stamp-h -stamp-h: $(CONFIG_HEADER_IN) $(top_builddir)/config.status +@CONFIG_HEADER@: @STAMP@ +@STAMP@: @CONFIG_HEADER_IN@ $(top_builddir)/config.status cd $(top_builddir) \ - && CONFIG_FILES= CONFIG_HEADERS=$(CONFIG_HEADER_FULL) \ + && CONFIG_FILES= CONFIG_HEADERS=@CONFIG_HEADER_FULL@ \ $(SHELL) ./config.status - @echo timestamp > stamp-h -$(srcdir)/$(CONFIG_HEADER_IN): @MAINT@stamp-h.in -$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) @FILES@ + @echo timestamp > @STAMP@ +$(srcdir)/@CONFIG_HEADER_IN@: @MAINT@@STAMP@.in +$(srcdir)/@STAMP@.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) @FILES@ cd $(top_srcdir) && $(AUTOHEADER) - echo timestamp > $(srcdir)/stamp-h.in - -mostlyclean-hdr: - -clean-hdr: - -distclean-hdr: - rm -f $(CONFIG_HEADER) - -maintainer-clean-hdr: + echo timestamp > $(srcdir)/@STAMP@.in diff --git a/m4/header.m4 b/m4/header.m4 index 3a408e105..95ccb6164 100644 --- a/m4/header.m4 +++ b/m4/header.m4 @@ -8,5 +8,15 @@ dnl This file resides in the same directory as the config header dnl that is generated. We must strip everything past the first ":", dnl and everything past the last "/". AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl -test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl +ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, +<>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, +<>; do + case " <<$>>CONFIG_HEADERS " in + *" <<$>>am_file "*<<)>> + echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx + ;; + esac + am_indx=`expr "<<$>>am_indx" + 1` +done<<>>dnl>>) changequote([,]))]) diff --git a/remake-hdr.am b/remake-hdr.am index d63798a04..5088e82ec 100644 --- a/remake-hdr.am +++ b/remake-hdr.am @@ -15,22 +15,13 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -$(CONFIG_HEADER): stamp-h -stamp-h: $(CONFIG_HEADER_IN) $(top_builddir)/config.status +@CONFIG_HEADER@: @STAMP@ +@STAMP@: @CONFIG_HEADER_IN@ $(top_builddir)/config.status cd $(top_builddir) \ - && CONFIG_FILES= CONFIG_HEADERS=$(CONFIG_HEADER_FULL) \ + && CONFIG_FILES= CONFIG_HEADERS=@CONFIG_HEADER_FULL@ \ $(SHELL) ./config.status - @echo timestamp > stamp-h -$(srcdir)/$(CONFIG_HEADER_IN): @MAINT@stamp-h.in -$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) @FILES@ + @echo timestamp > @STAMP@ +$(srcdir)/@CONFIG_HEADER_IN@: @MAINT@@STAMP@.in +$(srcdir)/@STAMP@.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) @FILES@ cd $(top_srcdir) && $(AUTOHEADER) - echo timestamp > $(srcdir)/stamp-h.in - -mostlyclean-hdr: - -clean-hdr: - -distclean-hdr: - rm -f $(CONFIG_HEADER) - -maintainer-clean-hdr: + echo timestamp > $(srcdir)/@STAMP@.in diff --git a/tests/ChangeLog b/tests/ChangeLog index 1fe6608a2..0fdc6918a 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +Fri Apr 25 12:30:22 1997 Tom Tromey + + * conf2.test: New file. + Tue Apr 8 19:26:07 1997 Tom Tromey * ansi.test, empty.test, exsource.test, insh2.test, man.test, diff --git a/tests/Makefile.am b/tests/Makefile.am index a92440f31..c985affe6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,7 +25,7 @@ colon2.test colon3.test remake.test output.test output2.test \ remake2.test output3.test output4.test colneq2.test subst.test \ defun2.test yaccpp.test texinfo3.test texinfo4.test tagsub.test \ cxxlibobj.test seenc.test cygwin32.test lisp.test stamph.test \ -ldadd.test version2.test +ldadd.test version2.test conf2.test EXTRA_DIST = defs $(TESTS) diff --git a/tests/Makefile.in b/tests/Makefile.in index 499262570..388d4e38b 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -84,7 +84,7 @@ colon2.test colon3.test remake.test output.test output2.test \ remake2.test output3.test output4.test colneq2.test subst.test \ defun2.test yaccpp.test texinfo3.test texinfo4.test tagsub.test \ cxxlibobj.test seenc.test cygwin32.test lisp.test stamph.test \ -ldadd.test version2.test +ldadd.test version2.test conf2.test EXTRA_DIST = defs $(TESTS) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/tests/conf2.test b/tests/conf2.test new file mode 100755 index 000000000..31fa6f004 --- /dev/null +++ b/tests/conf2.test @@ -0,0 +1,22 @@ +#! /bin/sh + +# Test to make sure several config headers are allowed. + +. $srcdir/defs || exit 1 + +cat > configure.in << 'END' +AM_CONFIG_HEADER(config.h two.h) +PACKAGE=nonesuch +VERSION=nonesuch +AC_PROG_CC +AC_ARG_PROGRAM +AM_PROG_INSTALL +AC_OUTPUT(Makefile) +END + +: > Makefile.am + +: > config.h.in +: > two.h.in + +$AUTOMAKE