#!/usr/bin/env bash

# initial flags to pass to our C compiler

# first, the default flags
printf '["-x", "c", "-std=c11", "-Werror=format", "-Werror=sign-compare", '
printf '"-Werror=type-limits"'

# test if the C compiler supports -Werror=enum-conversion
${CC:-cc} -x c -std=c11 -Werror=enum-conversion -o /dev/null - &>/dev/null <<EOT
int main(void) {
  return 0;
}
EOT
if [ $? -eq 0 ]; then
  printf ', "-Werror=enum-conversion"'
fi

# test is the C compiler supports -mcx16
${CC:-cc} -x c -std=c11 -mcx16 -o /dev/null - &>/dev/null <<EOT
int main(void) {
  return 0;
}
EOT
if [ $? -eq 0 ]; then
  printf ', "-mcx16"'
fi

printf ']\n'
