From: Nick Bowler Date: Thu, 24 Feb 2022 01:41:35 +0000 (-0500) Subject: fix-gnulib: Patch %reldir% too. X-Git-Url: https://git.draconx.ca/gitweb/dxcommon.git/commitdiff_plain/5d7b80ce6f21d6d90ecec188f135e665d789dede fix-gnulib: Patch %reldir% too. Gnulib has recently started producing rules using %reldir%. This is cool but since we are postprocessing the automake fragment anyway, we can easily substitute %reldir% ourselves which avoids requiring newer Automake just for this. --- diff --git a/scripts/fix-gnulib.pl b/scripts/fix-gnulib.pl index 9f868f2..3af852d 100755 --- a/scripts/fix-gnulib.pl +++ b/scripts/fix-gnulib.pl @@ -246,9 +246,10 @@ EOF # 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); diff --git a/tests/data/gnulib.mk b/tests/data/gnulib.mk index dfcd630..e44e645 100644 --- a/tests/data/gnulib.mk +++ b/tests/data/gnulib.mk @@ -36,3 +36,27 @@ SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) -n -e 'w $@-t' 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 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 diff --git a/tests/scripts.at b/tests/scripts.at index fdc0240..a546b61 100644 --- a/tests/scripts.at +++ b/tests/scripts.at @@ -599,3 +599,27 @@ AT_CHECK([test_fix_gnulib -i test.mk.in -o test.mk || exit 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