Make organization++
[henge/webcc.git] / make / lib / awk.mk
diff --git a/make/lib/awk.mk b/make/lib/awk.mk
new file mode 100644 (file)
index 0000000..81b57ca
--- /dev/null
@@ -0,0 +1,25 @@
+################################################################################
+# Desc:   Named functions for awk
+# Author: Ken Grimes
+# Date:   2016
+################################################################################
+# This makefile consists of awk programs that may come in handy as an extension
+# to the basic lisp make capabilities without having to invoke guile
+################################################################################
+
+# AWK_REVERSE_SQUASH############################################################
+# The following awk program reverses the order of a list while also removing
+# duplicate entries.  The effect of this when run on the dependency tree is that
+# it will remove duplicates occurring in reverse order, allowing the most deeply
+# nested libraries to be built, and linked, first. #############################
+define AWK_REVERSE_SQUASH =
+awk \
+'
+{ for(i=NF;i>0;i--)
+    printf (!a[$$i]++) ? $$i FS : "";
+  i=split("",a);
+  print ""
+}
+'
+#/AWK_REVERSE_SQUASH############################################################
+endef