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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
# We assume that the order of the passed files is
# - frontend compilers
# - backend compilers
# - mpi compilers
# - user-provided arguments
#
# With this order we guarantee that user-provided binary arguments takes
# precedence. They just overwrite already existing binary arguments.
#
# iterate over the fields. if a field is of the form "key=value", store it in
# a map<key, value>. subsequent insertions of the same key override the old
# value, e.g. the last insertion wins.
#
# fields not in "key=value" form are treated as unary arguments and are taken
# into account for the user-provided toplevel arguments only.
{
if (FILENAME == "user_provided_configure_args") {
gsub("'", "")
if ($0 == "") {
next
}
n = index($0, "=")
if (n != 0) { # line with at least one "=". Use first "=" as key-value separator
args_binary[substr($0, 1, n-1)] = substr($0, n+1)
}
else {
args_unary = "'" $0 "' " args_unary
}
}
# else if (FILENAME == "args_exported") {
# # HUH, it seems that exported values doesn't make it into configure
# # if I do a export CC=icc; ./configure then CC always equals gcc.
# # i.e. we can omit "args_exported"
# # don't put every exported symbol into the map but override only those
# # that were inserted by the platform defaults.
# n = split($0, split_array, "=")
# if (n == 2) {
# key = split_array[1]
# if (key in args_binary) {
# args_binary[key]=split_array[2]
# }
# }
# }
else { # FILENAME == "${ac_scorep_platform}"
if (index($0, "#") == 0) { # ! commented line
n = index($0, "=")
if (n != 0) { # line with at least one "=". Use first "=" as key-value separator
args_binary[substr($0, 1, n-1)] = substr($0, n+1)
}
}
}
}
function evaluate_placeholder(variable, separator)
{
# e.g. transform MPICC="mpiicc -cc={CC}" to MPICC="mpiicc -cc=gcc",
# assuming that CC=gcc
mpi_variable = "MPI" separator variable
pattern = "{" variable "}"
if (mpi_variable in args_binary) {
if (match(args_binary[mpi_variable], pattern) != 0) {
sub(pattern, args_binary[variable], args_binary[mpi_variable])
}
}
# e.g. transform SHMEMCC={CC} to SHMEMCC="icc",
# assuming that CC=icc
shmem_variable = "SHMEM" separator variable
pattern = "{" variable "}"
if (shmem_variable in args_binary) {
if (match(args_binary[shmem_variable], pattern) != 0) {
sub(pattern, args_binary[variable], args_binary[shmem_variable])
}
}
}
END{
evaluate_placeholder("CC", "")
evaluate_placeholder("CXX", "")
evaluate_placeholder("F77", "")
evaluate_placeholder("FC", "")
evaluate_placeholder("CFLAGS", "_")
evaluate_placeholder("CXXFLAGS", "_")
evaluate_placeholder("FFLAGS", "_")
evaluate_placeholder("FCFLAGS", "_")
# Concatenate the map's content into a "key=value" pair sequence, add the
# unary arguments and print it to stdout.
for (key in args_binary) {
result = "'" key "=" args_binary[key] "' " result
}
print result args_unary
}
|