1# $OpenBSD: list2sh.awk,v 1.12 2002/11/28 03:06:30 deraadt Exp $ 2# $NetBSD: list2sh.awk,v 1.2 1996/05/04 15:45:31 pk Exp $ 3 4BEGIN { 5 printf("cd ${OBJDIR}\n"); 6 printf("\n"); 7} 8/^$/ || /^#/ { 9 print $0; 10 next; 11} 12$1 == "COPY" { 13 printf("echo '%s'\n", $0); 14 printf("test -f ${TARGDIR}/%s && rm -fr ${TARGDIR}/%s\n", $3, $3); 15 printf("cp %s ${TARGDIR}/%s\n", $2, $3); 16 next; 17} 18$1 == "REMOVE" { 19 printf("echo '%s'\n", $0); 20 printf("rm -f ${TARGDIR}/%s\n", $2); 21 next; 22} 23$1 == "STRIP" { 24 printf("echo '%s'\n", $0); 25 printf("test -f ${TARGDIR}/%s && rm -fr ${TARGDIR}/%s\n", $3, $3); 26 printf("cp %s ${TARGDIR}/%s\n", $2, $3); 27 printf("strip ${TARGDIR}/%s\n", $3); 28 next; 29} 30$1 == "LINK" { 31 printf("echo '%s'\n", $0); 32 for (i = 3; i <= NF; i++) { 33 printf("test -f ${TARGDIR}/%s && rm -f ${TARGDIR}/%s\n", $i, $i); 34 printf("(cd ${TARGDIR}; ln %s %s)\n", $2, $i); 35 } 36 next; 37} 38$1 == "SYMLINK" { 39 printf("echo '%s'\n", $0); 40 for (i = 3; i <= NF; i++) { 41 printf("test -f ${TARGDIR}/%s && rm -f ${TARGDIR}/%s\n", $i, $i); 42 printf("(cd ${TARGDIR}; ln -s %s %s)\n", $2, $i); 43 } 44 next; 45} 46$1 == "ARGVLINK" { 47 # crunchgen directive; ignored here 48 next; 49} 50$1 == "SRCDIRS" { 51 # crunchgen directive; ignored here 52 next; 53} 54$1 == "LIBS" { 55 # crunchgen directive; ignored here 56 next; 57} 58$1 == "CRUNCHSPECIAL" { 59 # crunchgen directive; ignored here 60 next; 61} 62$1 == "COPYDIR" { 63 printf("echo '%s'\n", $0); 64 printf("(cd ${TARGDIR}/%s && find . ! -name . | xargs /bin/rm -rf)\n", 65 $3); 66 printf("(cd %s && pax -pe -rw . ${TARGDIR}/%s)\n", $2, $3); 67 next; 68} 69$1 == "SPECIAL" { 70# escaping shell quotation is ugly whether you use " or ', use cat <<'!' ... 71 work=$0; 72 gsub("[\\\\]", "\\\\", work); 73 gsub("[\"]", "\\\"", work); 74 gsub("[$]", "\\$", work); 75 gsub("[`]", "\\`", work); 76 printf("echo \"%s\"\n", work); 77 work=$0; 78 sub("^[ ]*" $1 "[ ]*", "", work); 79 printf("(cd ${TARGDIR}; %s)\n", work); 80 next; 81} 82$1 == "TERMCAP" { 83 printf("echo '%s'\n", $0); 84 printf("(cd ${TARGDIR}; tic -C -x -r -e %s ${UTILS}/../../share/termtypes/termtypes.master | sed -e '/^#.*/d' -e 's,/usr/share/lib/tabset,/usr/share/tabset,g' -e 's,/usr/lib/tabset,/usr/share/tabset,g' > %s)\n", 85 $2, $3); 86 next; 87} 88$1 == "SCRIPT" { 89 printf("echo '%s'\n", $0); 90 printf("sed -e '/^[ ]*#[ ].*$/d' -e '/^[ ]*#$/d' -e \"s/^ARCH=ARCH$/ARCH=`arch -ks`/\" < %s > ${TARGDIR}/%s\n", 91 $2, $3); 92 next; 93} 94{ 95 printf("echo '%s'\n", $0); 96 printf("echo 'Unknown keyword \"%s\" at line %d of input.'\n", $1, NR); 97 printf("exit 1\n"); 98 exit 1; 99} 100END { 101 printf("\n"); 102 printf("exit 0\n"); 103 exit 0; 104} 105