# component.
s/t-\$@/\$\@-t/g;
- # Finally, references to $(srcdir) and $(builddir) need to be fixed up.
+ # Finally, $(srcdir), $(builddir) and %reldir% need to be fixed up.
s:\$\(srcdir\):\$\(top_srcdir\)/lib:g;
s:\$\(builddir\):\$\(top_builddir\)/lib:g;
+ s:%reldir%:lib:g;
} continue { s/(\n.)/\\\1/g; print; };
print <<'EOF' if ($use_libtool);
gl_V_at = $(AM_V_GEN)
## end gnulib module gen-header
+
+## begin gnulib module sys_types (2022-02-23)
+
+BUILT_SOURCES += sys/types.h
+
+# We need the following in order to create <sys/types.h> when the system
+# doesn't have one that works with the given compiler.
+sys/types.h: sys_types.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
+ $(AM_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_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
+ -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
+ -e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \
+ $(srcdir)/sys_types.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
+MOSTLYCLEANFILES += sys/types.h sys/types.h-t
+
+EXTRA_DIST += sys_types.in.h
+
+## end gnulib module sys_types
grep SED_HEADER test.mk], [0], [expout])
AT_CLEANUP
+
+AT_SETUP([fix-gnulib.pl %reldir% substitution])
+
+test_gnulib_mk sys_types >test.mk.in
+AT_CHECK([grep '%reldir%' test.mk.in >/dev/null || exit 99])
+
+sed -n -f - test.mk.in >expout <<'EOF'
+${G;p;b}
+/^## begin gnulib/,/^## end gnulib/!b
+/^#/{p;b}
+s|(srcdir)|(top_srcdir)|
+s|%reldir%|lib|
+s|BUILT_SOURCES|gnulib_core_headers|
+s|sys[[/_]]|lib/&|g
+/^MOSTLYCLEANFILES/{h;b}
+p
+EOF
+
+AT_CHECK([test_fix_gnulib -i test.mk.in -o test.mk || exit
+sed -n -e '/^## begin gnulib/,/^## end gnulib/p' \
+ -e '/CLEANFILES/p' test.mk],
+[0], [expout])
+
+AT_CLEANUP