]> git.draconx.ca Git - dxcommon.git/commitdiff
fix-gnulib: Patch %reldir% too.
authorNick Bowler <nbowler@draconx.ca>
Thu, 24 Feb 2022 01:41:35 +0000 (20:41 -0500)
committerNick Bowler <nbowler@draconx.ca>
Thu, 24 Feb 2022 01:41:35 +0000 (20:41 -0500)
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.

scripts/fix-gnulib.pl
tests/data/gnulib.mk
tests/scripts.at

index 9f868f2ef0121293fd7f0142d540fce5a875b775..3af852d20d0ec54f4c42e759a1904c3e4db066da 100755 (executable)
@@ -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);
index dfcd630b8fb712c7d46bec51f88ca6f2f4c26833..e44e6450e258867f646bad5d71803548f0a0b7db 100644 (file)
@@ -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 <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
index fdc0240ad25ee54e1b4d1f6a2c1383a56ea430a8..a546b61a557240ae8b10a26065c8cee4a1a275aa 100644 (file)
@@ -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