summaryrefslogtreecommitdiff
path: root/Build/source/texk/kpathsea/cnf-to-paths.awk
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/kpathsea/cnf-to-paths.awk')
-rw-r--r--Build/source/texk/kpathsea/cnf-to-paths.awk49
1 files changed, 49 insertions, 0 deletions
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 "";
+}