Annotation of researchv10no/cmd/adb/conf/amkconf, revision 1.1

1.1     ! root        1: #!/usr/bin/awk -f
        !             2: BEGIN {
        !             3:        files = "files";
        !             4:        templ = "templ";
        !             5: #      out = stdout;
        !             6:        if (ARGC == 2 && ARGV[1] == "-")        # ugh
        !             7:                ARGC--;
        !             8:        if (ARGC < 2) {
        !             9:                printf "usage: %s pat ...\n", ARGV[0];
        !            10:                exit
        !            11:        }
        !            12:        for (i = 1; i < ARGC; i++)
        !            13:                atags[ARGV[i]] = ARGV[i];
        !            14:        rdfiles(files, atags);
        !            15:        putmake(templ, out);
        !            16:        exit
        !            17: }
        !            18: 
        !            19: #
        !            20: # read the list of component files
        !            21: # pick out the ones we care about
        !            22: # return
        !            23: #      src     array of source filenames
        !            24: #      obj     array of objects
        !            25: #      typ     array of types
        !            26: #      nf      number of names in the above arrays
        !            27: # to preserve order, the arrays are indexed by numbers
        !            28: #
        !            29: 
        !            30: func rdfiles(files, atags)
        !            31: {
        !            32:        nf = 0;
        !            33:        while ((getline f <files) > 0) {
        !            34:                if (split(f, ff, ":[ \t]*") != 4) {
        !            35:                        printf "bad files line: %s\n", f;
        !            36:                        continue;
        !            37:                }
        !            38:                if (split(ff[4], tags, "[ \t]+") < 1) {
        !            39:                        printf "bad files line: %s\n", f;
        !            40:                        continue;
        !            41:                }
        !            42:                mat = 0;
        !            43:                for (t in tags)
        !            44:                        if (atags[tags[t]] != "") {
        !            45:                                mat = 1;
        !            46:                                break;
        !            47:                        }
        !            48:                if (mat == 0)
        !            49:                        continue;
        !            50:                nf++;
        !            51:                obj[nf] = ff[1];
        !            52:                src[nf] = ff[2];        # perhaps a list
        !            53:                typ[nf] = ff[3];
        !            54:        }
        !            55:        for (i = 1; i < nf; i++)
        !            56:                allobj=allobj " " obj[i];
        !            57: }
        !            58: 
        !            59: #
        !            60: # read the template makefile
        !            61: # scoop up the rules;
        !            62: # spit out lists;
        !            63: # copy the literal part;
        !            64: # spit out rules for our files
        !            65: #
        !            66: 
        !            67: func putmake(templ, out)
        !            68: {
        !            69:        while ((getline l <templ) > 0) {
        !            70:                if (l == "%%")
        !            71:                        break;
        !            72:                if (l ~ /^#/)
        !            73:                        continue;
        !            74:                if ((i = index(l, ":")) == 0) {
        !            75:                        printf "bad line in template: %s\n", l;
        !            76:                        continue;
        !            77:                }
        !            78:                t = substr(l, 1, i - 1);
        !            79:                rule = "";
        !            80:                while ((getline r <templ) > 0) {
        !            81:                        if (r == "")
        !            82:                                break;
        !            83:                        rule = rule "\n" r;
        !            84:                }
        !            85:                if (rules[t] != "")
        !            86:                        printf "dup rule for %s ignored\n", t;
        !            87:                else {
        !            88:                        rules[t] = rule;
        !            89:                        extra[t] = substr(l, i + 1, length(l));
        !            90:                }
        !            91:        }
        !            92:        print "FILES=" allobj   # >out
        !            93:        while ((getline l <templ) > 0)
        !            94:                print l         # >out
        !            95:        print                   # >out
        !            96:        for (i = 1; i < nf; i++)
        !            97:                if (rules[typ[i]] == "")
        !            98:                        print obj[i] ": " src[i];
        !            99:                else
        !           100:                        print obj[i] ": " src[i] " " extra[typ[i]] rules[typ[i]];
        !           101: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.