diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2021-05-31 17:08:09 +0100 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2021-05-31 17:38:33 +0100 |
commit | a88ad680422949dfe2d16a544a529649c6d07109 (patch) | |
tree | df4d9463a099d4b87cd0f201f80db5c5d628ffad /configure | |
parent | 13ceac75a8ed37ddc02df2b41627329c4da24b04 (diff) | |
download | pack-a88ad680422949dfe2d16a544a529649c6d07109.tar.gz pack-a88ad680422949dfe2d16a544a529649c6d07109.tar.xz pack-a88ad680422949dfe2d16a544a529649c6d07109.zip |
Update build system to the latest luiml version
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 86 |
1 files changed, 83 insertions, 3 deletions
@@ -1,5 +1,85 @@ -#!/bin/sh +#!/bin/bash -for f in args/"$1"/*; do - ln -sf "$f" +warnings=( + -Wall -Wcast-align -Wcast-qual -Wextra -Wpedantic -Wformat=2 + -Winit-self -Wmissing-prototypes -Wpointer-arith -Wshadow + -Wstrict-prototypes -Wsuggest-attribute=format + -Wsuggest-attribute=noreturn +) + +CFLAGS+=(-std=c11 -fPIC) + +usage () { echo "Usage: $0 [-h|options...]"; } + +help () { + cat <<EOF +Options: + -B ldlib Append ldlib to LDLIBS + -C cflag Append cflag to CFLAGS + -L ldflag Append ldflag to LDFLAGS + -P cppflag Append cppflag to CPPFLAGS + -c when Enable compiler colours (always|auto|off) [default: auto] + -d Enable debugging flags + -e Enable -Werror + -f Generate a compile_flags.txt + -h Show this help + -o Enable optimisation flags + -v Print results of configuration + -w Enable warning flags +Environment: + CC C compiler + PKG_CONFIG pkg-config +EOF +} + +check() { + what=$1 + shift + for p do + if command -v "$p" >/dev/null 2>&1; then + echo "$p" + return + fi + done + echo "$what not set or found" >&2 + return 1 +} + + +CC=$(check '$CC, cc, gcc or clang' "$CC" cc gcc clang) || exit + +colour=auto +while getopts B:C:L:P:c:defhovw opt; do + case $opt in + B) LDLIBS+=("$OPTARG");; + C) CFLAGS+=("$OPTARG");; + L) LDFLAGS+=("$OPTARG");; + P) CPPFLAGS+=("$OPTARG");; + c) colour="$OPTARG";; + d) CFLAGS+=(-Og -g); LDFLAGS+=(-Og -g);; + e) CFLAGS+=(-Werror);; + f) gen_flags=1;; + h) usage; help; exit;; + o) CFLAGS+=(-O2 -flto); LDFLAGS+=(-O2 -flto);; + v) verbose=1;; + w) CFLAGS+=("${warnings[@]}");; + ?) usage >&2; exit 1;; + esac done +if [[ $colour == auto && -t 1 ]]; then + colour=always +fi +if [[ $colour == always ]]; then + CFLAGS+=(-fdiagnostics-color) +fi + +{ + echo "# generated using $0 $@" + echo "CC=$CC" + echo "CFLAGS=(${CFLAGS[@]@Q})" + echo "CPPFLAGS=(${CPPFLAGS[@]@Q})" + echo "LDFLAGS=(${LDFLAGS[@]@Q})" + echo "LDLIBS=(${LDLIBS[@]@Q})" +} >.config.rc +[[ $verbose ]] && cat .config.rc +[[ $gen_flags ]] && printf '%s\n' "${CFLAGS[@]}" "${CPPFLAGS[@]}" >compile_flags.txt |