chiark / gitweb /
Apply https://sourceware.org/git/?p=glibc.git;a=commit;h=d5dd6189d506068ed11c8bfa1e1e...
[eglibc.git] / scripts / option-groups.awk
1 # option-groups.awk --- generate option group header file
2 # Given input files containing makefile-style assignments to variables, 
3 # print out a header file that #defines an appropriate preprocessor
4 # symbol for each variable left set to 'y'.
5
6 BEGIN { FS="=" }
7
8 # Trim spaces.
9 { gsub (/[[:blank:]]/, "") }
10
11 # Skip comments.
12 /^#/ { next }
13
14 # Process assignments.
15 NF == 2 {
16     vars[$1] = $2
17 }
18
19 # Print final values.
20 END {
21     print "/* This file is automatically generated by scripts/option-groups.awk"
22     print "   in the EGLIBC source tree."
23     print ""
24     print "   It defines macros that indicate which EGLIBC option groups were"
25     print "   configured in 'option-groups.config' when this C library was"
26     print "   built.  For each option group named OPTION_foo, it #defines"
27     print "   __OPTION_foo to be 1 if the group is enabled, or leaves that"
28     print "   symbol undefined if the group is disabled.  */"
29     print ""
30     print "#ifndef __GNU_OPTION_GROUPS_H"
31     print "#define __GNU_OPTION_GROUPS_H"
32     print ""
33
34     # Produce a sorted list of variable names.
35     i=0
36     for (var in vars)
37         names[i++] = var
38     n = asort (names)
39
40     for (i = 1; i <= n; i++)
41     {
42         var = names[i]
43         if (var ~ /^OPTION_/)
44         {
45             if (vars[var] == "y")
46                 print "#define __" var " 1"
47             else if (vars[var] == "n")
48                 print "/* #undef __" var " */"
49             # Ignore variables that don't have boolean values.
50             # Ideally, this would be driven by the types given in
51             # option-groups.def.
52         }
53     }
54
55     print ""
56     print "#endif /* __GNU_OPTION_GROUPS_H */"
57 }