81b57ca2ccf6474b5625371482ad0988f8447c66
[henge/webcc.git] / make / lib / awk.mk
1 ################################################################################
2 # Desc: Named functions for awk
3 # Author: Ken Grimes
4 # Date: 2016
5 ################################################################################
6 # This makefile consists of awk programs that may come in handy as an extension
7 # to the basic lisp make capabilities without having to invoke guile
8 ################################################################################
9
10 # AWK_REVERSE_SQUASH############################################################
11 # The following awk program reverses the order of a list while also removing
12 # duplicate entries. The effect of this when run on the dependency tree is that
13 # it will remove duplicates occurring in reverse order, allowing the most deeply
14 # nested libraries to be built, and linked, first. #############################
15 define AWK_REVERSE_SQUASH =
16 awk \
17 '
18 { for(i=NF;i>0;i--)
19 printf (!a[$$i]++) ? $$i FS : "";
20 i=split("",a);
21 print ""
22 }
23 '
24 #/AWK_REVERSE_SQUASH############################################################
25 endef