summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/kpathsea/ChangeLog8
-rw-r--r--Build/source/texk/kpathsea/Makefile.am49
-rw-r--r--Build/source/texk/kpathsea/Makefile.in18
-rw-r--r--Build/source/texk/kpathsea/cnf-to-paths.awk49
4 files changed, 64 insertions, 60 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index 0bdfe69cbec..f9121033957 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,11 @@
+2011-05-23 Karl Berry <karl@tug.org>
+
+ * cnf-to-paths.awk: new awk script.
+ * Makefile.am (stamp-paths): use it instead of the inline sed.
+ Also, change the generated paths.h so that all non-SELFAUTO paths
+ become a constant string "/nonesuch". That way, if the definitions
+ change, the binaries don't all uselessly change with them.
+
2011-05-22 Karl Berry <karl@tug.org>
* texmf.cnf: doc fixes.
diff --git a/Build/source/texk/kpathsea/Makefile.am b/Build/source/texk/kpathsea/Makefile.am
index 823cc3726bf..52406abec48 100644
--- a/Build/source/texk/kpathsea/Makefile.am
+++ b/Build/source/texk/kpathsea/Makefile.am
@@ -157,40 +157,15 @@ kpseinclude_HEADERS = \
xopendir.h \
xstat.h
-## First null out comments and leading/trailing whitespace, then remove
-## lines that define invalid C identifiers, then remove blank lines and
-## lines that define lowercase values (those are never path values).
-## Each line remaining looks like
-## <name> = <value>
-## (but = and surrounding spaces are optional, hence can't remove all spaces).
-## Change this to #ifndef DEFAULT_name@#define DEFAULT_name "value"@#endif,
-## then change the @'s to newlines (sed isn't good at multiline replacements).
-##
-## No backslash-newline escapes in the long sed replacement because that
-## will turn into a space in the output.
-##
-## We replace the $TEXMF* references with nonexisting directories. These
-## are the compile-time defaults and are not useful in the native TL
-## builds; we rely completely on the self-location. (Previously, the
-## random build-time paths would get included in the binaries, to
-## consequent confusion.)
-##
-## We preserve the $SELFAUTO* references, since the selfauto-using
-## compile-time path for cnf files is how texmf.cnf gets found, which
-## determines everything else.
-##
-## The definition of DEFAULT_TEXMF (and other variables)
-## that winds up in the final paths.h will not be used.
-##
+## Handle backslash continuations, then null out comments and
+## leading/trailing whitespace. An awk script does the rest.
+##
## We don't want to rewrite paths.h when we have only changed comments
## in texmf.cnf that have no effect on paths.h, since that would cause
## almost everything to be rebuilt.
##
-## We also replace all semicolons with colons in the paths.
-## (The path-splitting code should be changed to understand both.)
-##
paths.h: stamp-paths
-stamp-paths: texmf.cnf bsnl.awk
+stamp-paths: texmf.cnf bsnl.awk cnf-to-paths.awk
# ensure grep is not completely broken, e.g., from GREP_OPTIONS.
echo a | grep -v b >/dev/null || { echo "*** grep broken, goodbye."; exit 1; }
#
@@ -198,21 +173,7 @@ stamp-paths: texmf.cnf bsnl.awk
echo "/* paths.h: Generated from texmf.cnf. */" >paths.tmp
awk -f $(srcdir)/bsnl.awk $(srcdir)/texmf.cnf \
| sed -e 's/%.*//' -e 's/^[ ]*//' -e 's/[ ]*$$//' \
- | grep '^[ ]*[A-Z0-9_]*[ =]' \
- | sed '/^$$/d' \
- | sed 's/^\([^ =]*\)[ ]*=*[ ]*\(.*\)/#ifndef DEFAULT_\1%#define DEFAULT_\1 "\2"%#endif/' \
- | tr '%' '\012' \
- | sed -e 's%\$$TEXMFCONFIG%/nonesuch/texmfconfig%g' \
- -e 's%\$$TEXMFDIST%/nonesuch/texmfdist%g' \
- -e 's%\$$TEXMFDOCDIR%/nonesuch/texmfdocdir%g' \
- -e 's%\$$TEXMFLOCAL%/nonesuch/texmflocal%g' \
- -e 's%\$$TEXMFMAIN%/nonesuch/texmfmain%g' \
- -e 's%\$$TEXMFSYSCONFIG%/nonesuch/texmfsysconfig%g' \
- -e 's%\$$TEXMFSYSVAR%/nonesuch/texmfsysvar%g' \
- -e 's%\$$TEXMFVAR%/nonesuch/texmfvar%g' \
- -e 's%\$$TEXMF%/nonesuch/texmf%g' \
- -e 's%\$$VARTEXFONTS%/nonesuch/vartexfonts%g' \
- | sed -e 's%;%:%g' \
+ | awk -f $(srcdir)/cnf-to-paths.awk \
>>paths.tmp
@if cmp -s paths.h paths.tmp 2>/dev/null; then \
echo "paths.h is unchanged"; \
diff --git a/Build/source/texk/kpathsea/Makefile.in b/Build/source/texk/kpathsea/Makefile.in
index 436bf93db4c..0586ad196e3 100644
--- a/Build/source/texk/kpathsea/Makefile.in
+++ b/Build/source/texk/kpathsea/Makefile.in
@@ -1750,7 +1750,7 @@ rebuild: all
$(libkpathsea_la_OBJECTS): paths.h kpathsea.h
paths.h: stamp-paths
-stamp-paths: texmf.cnf bsnl.awk
+stamp-paths: texmf.cnf bsnl.awk cnf-to-paths.awk
# ensure grep is not completely broken, e.g., from GREP_OPTIONS.
echo a | grep -v b >/dev/null || { echo "*** grep broken, goodbye."; exit 1; }
#
@@ -1758,21 +1758,7 @@ stamp-paths: texmf.cnf bsnl.awk
echo "/* paths.h: Generated from texmf.cnf. */" >paths.tmp
awk -f $(srcdir)/bsnl.awk $(srcdir)/texmf.cnf \
| sed -e 's/%.*//' -e 's/^[ ]*//' -e 's/[ ]*$$//' \
- | grep '^[ ]*[A-Z0-9_]*[ =]' \
- | sed '/^$$/d' \
- | sed 's/^\([^ =]*\)[ ]*=*[ ]*\(.*\)/#ifndef DEFAULT_\1%#define DEFAULT_\1 "\2"%#endif/' \
- | tr '%' '\012' \
- | sed -e 's%\$$TEXMFCONFIG%/nonesuch/texmfconfig%g' \
- -e 's%\$$TEXMFDIST%/nonesuch/texmfdist%g' \
- -e 's%\$$TEXMFDOCDIR%/nonesuch/texmfdocdir%g' \
- -e 's%\$$TEXMFLOCAL%/nonesuch/texmflocal%g' \
- -e 's%\$$TEXMFMAIN%/nonesuch/texmfmain%g' \
- -e 's%\$$TEXMFSYSCONFIG%/nonesuch/texmfsysconfig%g' \
- -e 's%\$$TEXMFSYSVAR%/nonesuch/texmfsysvar%g' \
- -e 's%\$$TEXMFVAR%/nonesuch/texmfvar%g' \
- -e 's%\$$TEXMF%/nonesuch/texmf%g' \
- -e 's%\$$VARTEXFONTS%/nonesuch/vartexfonts%g' \
- | sed -e 's%;%:%g' \
+ | awk -f $(srcdir)/cnf-to-paths.awk \
>>paths.tmp
@if cmp -s paths.h paths.tmp 2>/dev/null; then \
echo "paths.h is unchanged"; \
diff --git a/Build/source/texk/kpathsea/cnf-to-paths.awk b/Build/source/texk/kpathsea/cnf-to-paths.awk
new file mode 100644
index 00000000000..755a5c30d14
--- /dev/null
+++ b/Build/source/texk/kpathsea/cnf-to-paths.awk
@@ -0,0 +1,49 @@
+# $Id$
+# cnf-to-paths.awk - convert texmf.cnf assignments to paths.h #define's.
+# Public domain. Originally written 2011, Karl Berry.
+
+# We assume comments have been stripped.
+#
+# we only care about definitions with a valid C identifier (e.g.,
+# TEXINPUTS, not TEXINPUTS.latex), that is, lines that look like this:
+# <name> = <value>
+# (whitespace around the = is optional)
+#
+/^[ \t]*[A-Z0-9_]+[ \t]*=/ {
+ # On these lines, there are two cases:
+ #
+ # 1) definitions referring to SELFAUTO*, which we want to keep. In
+ # particular, this is how the compile-time TEXMFCNF gets defined and
+ # thus how texmf.cnf gets found.
+ #
+ # 2) all the others, which we want to convert to a constant
+ # /nonesuch. That way, the binaries don't get change just because we
+ # change definitions in texmf.cnf.
+ #
+ # The definition of DEFAULT_TEXMF (and other variables)
+ # that winds up in the final paths.h will not be used.
+
+ # Let's extract the identifier and the value from the line. Since
+ # gawk's subexpression matching is an extension, do it with copies.
+ ident = $0;
+ sub(/^[ \t]*/, "", ident);
+ sub(/[ \t]*=.*/, "", ident);
+
+ val = $0;
+ sub(/^.*=[ \t]*/, "", val);
+ sub(/[ \t]*$/, "", val);
+ #print "got ident", ident, "and val", val >"/dev/stderr";
+
+ if (val ~ /\$SELFAUTO/) {
+ # Replace all semicolons with colons in the SELFAUTO paths we're keeping.
+ # (The path-splitting code should be changed to understand both.)
+ gsub(/;/, ":", val);
+ } else {
+ val = "/nonesuch";
+ }
+
+ print "#ifndef DEFAULT_" ident;
+ print "#define DEFAULT_" ident " \"" val "\"";
+ print "#endif";
+ print "";
+}