diff options
Diffstat (limited to 'gcc/opts.sh')
-rw-r--r-- | gcc/opts.sh | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/gcc/opts.sh b/gcc/opts.sh index 3e670600d7e..dbff2f8cf31 100644 --- a/gcc/opts.sh +++ b/gcc/opts.sh @@ -42,37 +42,38 @@ ${AWK} ' /^[ \t]*(;|$)/ { next } /^[^ \t]/ { gsub ("\n", "\034", $0); print } ' "$@" | ${SORT} | ${AWK} ' - function switch_flags (langs, flags) + function switch_flags (flags, result) { - langs = ":" langs ":" - gsub( " ", ":", langs) - flags = "0" - if (langs ~ ":C:") flags = flags " | CL_C" - if (langs ~ ":ObjC:") flags = flags " | CL_OBJC" - if (langs ~ ":C\\+\\+:") flags = flags " | CL_CXX" - if (langs ~ ":ObjC\\+\\+:") flags = flags " | CL_OBJCXX" - if (langs ~ ":F77:") flags = flags " | CL_F77" - if (langs ~ ":Java:") flags = flags " | CL_JAVA" - if (langs ~ ":Ada:") flags = flags " | CL_ADA" - if (langs ~ ":Tree:") flags = flags " | CL_TREELANG" - if (langs ~ ":Common:") flags = flags " | CL_COMMON" - if (langs ~ ":Joined:") flags = flags " | CL_JOINED" - if (langs ~ ":Separate:") flags = flags " | CL_SEPARATE" - if (langs ~ ":RejectNegative:") flags = flags " | CL_REJECT_NEGATIVE" - sub( "^0 \\| ", "", flags ) - return flags + flags = " " flags " " + result = "0" + for (j = 0; j < n_langs; j++) { + if (flags ~ " " langs[j] " ") + result = result " | " macros[j] + } + if (flags ~ " Common ") result = result " | CL_COMMON" + if (flags ~ " Joined ") result = result " | CL_JOINED" + if (flags ~ " Separate ") result = result " | CL_SEPARATE" + if (flags ~ " RejectNegative ") result = result " | CL_REJECT_NEGATIVE" + sub( "^0 \\| ", "", result ) + return result } BEGIN { FS = "\034" n_opts = 0 + n_langs = 0 } # Collect the text and flags of each option into an array { - opts[n_opts] = $1 - flags[n_opts] = $2 - n_opts++; + if ($1 == "Language") { + langs[n_langs] = $2 + n_langs++; + } else { + opts[n_opts] = $1 + flags[n_opts] = $2 + n_opts++; + } } # Dump out an enumeration into a .h file, and an array of options into a @@ -83,7 +84,13 @@ ${AWK} ' comma = "," print "/* This file is auto-generated by opts.sh. */\n" > h_file - print "enum opt_code\n{" >> h_file + for (i = 0; i < n_langs; i++) { + macros[i] = "CL_" langs[i] + gsub( "[^A-Za-z0-9_]", "X", macros[i] ) + s = substr(" ", length (macros[i])) + print "#define " macros[i] s " (1 << " i ")" >> h_file + } + print "\nenum opt_code\n{" >> h_file print "/* This file is auto-generated by opts.sh. */\n" > c_file print "#include \"" h_file "\"" >> c_file |