open STDIN, "<", $input or die "$input: $!\n" if (defined $input);
my $printed_header = 0;
+my $check_mkdir;
my @cleanfiles;
# Hashes to record make variables used in the automake source. The allvars
# ordinary variable so we can deal with them later.
s/BUILT_SOURCES/gnulib_core_headers/;
+ # Rules for "toplevel" header files do not include commands to create
+ # the target directory; let's add that.
+ if (defined $check_mkdir) {
+ if (/gl_V_at/ || /AM_V_GEN/ and not /MKDIR_P/) {
+ my $dir = "lib/$check_mkdir";
+ $dir =~ s|/[^/]*||;
+
+ print "\t\$(AM_V_GEN)\$(MKDIR_P) $dir\n";
+ s/AM_V_GEN|gl_V_at/AM_V_at/;
+ }
+ undef $check_mkdir
+ }
+
# Targets are similar to variables: the target and its dependencies
# need to be mangled.
- if (/^[^\t].*:/) {
+ if (/^([^\t:]*):/) {
+ $check_mkdir = $1;
$_ = mangle_target($_);
}
EXTRA_DIST += sys_types.in.h
## end gnulib module sys_types
+
+## begin gnulib module alloca-opt (2021-03-07)
+
+BUILT_SOURCES += $(ALLOCA_H)
+
+# We need the following in order to create <alloca.h> when the system
+# doesn't have one that works with the given compiler.
+if GL_GENERATE_ALLOCA_H
+alloca.h: alloca.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''HAVE_ALLOCA_H''@|$(HAVE_ALLOCA_H)|g' < $(srcdir)/alloca.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+else
+alloca.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += alloca.h alloca.h-t
+
+EXTRA_DIST += alloca.in.h
+
+## end gnulib module alloca-opt
+
+## begin gnulib module stddef (2022-02-23)
+
+BUILT_SOURCES += $(STDDEF_H)
+
+# We need the following in order to create <stddef.h> when the system
+# doesn't have one that works with the given compiler.
+if GL_GENERATE_STDDEF_H
+stddef.h: stddef.in.h $(top_builddir)/config.status
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
+ -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \
+ -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
+ -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
+ $(srcdir)/stddef.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
+else
+stddef.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += stddef.h stddef.h-t
+
+EXTRA_DIST += stddef.in.h
+
+## end gnulib module stddef
$PERL -f "$srcdir/scripts/fix-gnulib.pl" "$@"
}
test_gnulib_mk () {
- echo; sed -n -f - "$srcdir/tests/data/gnulib.mk" <<EOF
-/^## begin gnulib module $1/,/^## end gnulib module $1/p
+ echo;
+ for arg
+ do
+ sed -n -f - "$srcdir/tests/data/gnulib.mk" <<EOF
+/^## begin gnulib module $arg/,/^## end gnulib module $arg/p
EOF
+ done
}
m4_divert_pop([PREPARE_TESTS])
AT_CLEANUP
+AT_SETUP([fix-gnulib.pl header directory creation])
+
+AT_DATA([extract.sed],
+[[/AM_V_GEN/b ok
+/gl_V_at/b ok
+s/:.*/:/
+h
+b
+:ok
+s/'//g
+x
+G
+p
+n
+s/[)].*/)/
+p
+]])
+
+test_gnulib_mk alloca-opt sys_types stddef >test.mk.in
+AT_CHECK([test_fix_gnulib -i test.mk.in -o test.mk || exit
+sed -n -f extract.sed test.mk], [0],
+[[lib/alloca.h:
+ $(AM_V_GEN)$(MKDIR_P) lib
+ $(AM_V_at)
+lib/sys/types.h:
+ $(AM_V_GEN)$(MKDIR_P) lib/sys
+ $(AM_V_at)
+lib/stddef.h:
+ $(AM_V_GEN)$(MKDIR_P) lib
+ $(AM_V_at)
+]])
+
+AT_CLEANUP
+
dnl TEST_FIND_AUTOMAKE_VER([to-check], [test-action])
dnl
dnl For each whitespace-separated version token in to-check, check if we can