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