1# $OpenBSD: makeconf.awk,v 1.28 2019/06/07 14:38:42 deraadt Exp $ 2 3# 4# generate crunchgen(1) configuration file from `list' spec. 5# 6 7BEGIN { 8 printf("#\n# This file is automatically generated by `makeconf'\n#\n\n"); 9 libs = "libs -lstubs -lutil -lm -ltls -lssl -lcrypto -levent -lc -lz"; 10} 11 12$1 == "LIBS" { 13 $1 = tolower($1); 14 libs = $0; 15} 16 17$1 == "SRCDIRS" { 18 $1 = tolower($1); 19 print; 20} 21 22($1 == "LINK" || $1 == "SYMLINK") && $2 == "instbin" { 23 # find basenames for inclusion in crunchgen's `prog' and `ln' directives 24 n = split($3, x, "/"); 25 p = x[n]; 26 progs[p] = NF - 3; 27 for (i = 4; i <= NF; i++) { 28 n = split($i, x, "/"); 29 l = x[n]; 30 links[i - 3, p] = l; 31 } 32} 33 34$1 == "ARGVLINK" { 35 # add extra `ln' entries (these don't appear in the filesystem) 36 n = progs[$2]; 37 progs[$2] = ++n; 38 links[n, $2] = $3; 39} 40 41$1 == "CRUNCHSPECIAL" { 42 # collect crunchgen `special' directives 43 $1 = ""; 44 specials[$0] = 1; 45} 46 47END { 48 # write crunchgen configuration 49 50 # `prog' directives; print 8 to a line 51 column = 0; 52 for (p in progs) { 53 if ((column++ % 8) == 0) 54 printf("\nprogs"); 55 printf(" %s", p); 56 } 57 printf("\n\n"); 58 59 # `ln' directives 60 for (p in progs) { 61 n = progs[p]; 62 for (i = 1; i <= n; i++) 63 printf("ln %s %s\n", p, links[i,p]); 64 } 65 printf("\n%s\n\n", libs); 66 printf("libdirs distrib/special/libstubs\n"); 67 68 # `special' directives 69 for (s in specials) { 70 printf("special %s\n", s); 71 } 72} 73