#!/bin/bash usage () { echo "Usage: $0 [-h|options...]"; } help () { cat <config.rc conf() { echo "$1" >&3; } colour=auto while getopts B:C:L:P:c:dehovw opt; do qopt=${OPTARG@Q} case $opt in B) conf "LDLIBS+=($qopt)";; C) conf "CFLAGS+=($qopt)";; L) conf "LDFLAGS+=($qopt)";; P) conf "CPPFLAGS+=($qopt)";; c) colour="$OPTARG";; d) conf "debug=1" >&3;; e) conf "werror=1" >&3;; h) usage; help; exit;; o) conf "optimise=1" >&3;; v) conf "verbose=1" >&3;; w) conf "warn=1" >&3;; ?) usage >&2; exit 1;; esac done case "$colour" in auto) [[ -t 1 ]] && conf "colour=1" || conf "colour=0";; always) conf "colour=1";; off) conf "colour=0";; *) usage >&2; exit 1;; esac if [[ $CC ]]; then conf "CC=${CC@Q}"; fi