File: option-groups.awk

package info (click to toggle)
eglibc 2.13-38%2Bdeb7u8
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 148,228 kB
  • sloc: ansic: 916,251; asm: 203,084; sh: 9,197; makefile: 7,792; perl: 2,252; awk: 1,728; cpp: 1,279; pascal: 723; yacc: 317; sed: 131
file content (57 lines) | stat: -rw-r--r-- 1,664 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# option-groups.awk --- generate option group header file
# Given input files containing makefile-style assignments to variables, 
# print out a header file that #defines an appropriate preprocessor
# symbol for each variable left set to 'y'.

BEGIN { FS="=" }

# Trim spaces.
{ gsub (/[[:blank:]]/, "") }

# Skip comments.
/^#/ { next }

# Process assignments.
NF == 2 {
    vars[$1] = $2
}

# Print final values.
END {
    print "/* This file is automatically generated by scripts/option-groups.awk"
    print "   in the EGLIBC source tree."
    print ""
    print "   It defines macros that indicate which EGLIBC option groups were"
    print "   configured in 'option-groups.config' when this C library was"
    print "   built.  For each option group named OPTION_foo, it #defines"
    print "   __OPTION_foo to be 1 if the group is enabled, or leaves that"
    print "   symbol undefined if the group is disabled.  */"
    print ""
    print "#ifndef __GNU_OPTION_GROUPS_H"
    print "#define __GNU_OPTION_GROUPS_H"
    print ""

    # Produce a sorted list of variable names.
    i=0
    for (var in vars)
        names[i++] = var
    n = asort (names)

    for (i = 1; i <= n; i++)
    {
        var = names[i]
        if (var ~ /^OPTION_/)
        {
            if (vars[var] == "y")
                print "#define __" var " 1"
            else if (vars[var] == "n")
                print "/* #undef __" var " */"
            # Ignore variables that don't have boolean values.
            # Ideally, this would be driven by the types given in
            # option-groups.def.
        }
    }

    print ""
    print "#endif /* __GNU_OPTION_GROUPS_H */"
}