Detect "fancy" compilers that support more flags.
Some checks failed
Compile Cytoplasm / Compile Cytoplasm (x86, freebsd-v14.0) (push) Failing after 6s
Compile Cytoplasm / Compile Cytoplasm (x86, debian-v12.4) (push) Failing after 11s
Compile Cytoplasm / Compile Cytoplasm (x86_64, freebsd-v14.0) (push) Failing after 7s
Compile Cytoplasm / Compile Cytoplasm (x86, alpine-v3.19) (push) Failing after 10s
Compile Cytoplasm / Compile Cytoplasm (x86, netbsd-v9.3) (push) Failing after 11s
Compile Cytoplasm / Compile Cytoplasm (x86_64, openbsd-v7.4) (push) Failing after 12s
Compile Cytoplasm / Compile Cytoplasm (x86_64, alpine-v3.19) (push) Successful in 10s
Compile Cytoplasm / Compile Cytoplasm (x86_64, debian-v12.4) (push) Successful in 15s
Compile Cytoplasm / Compile Cytoplasm (x86_64, netbsd-v9.3) (push) Successful in 16s
Some checks failed
Compile Cytoplasm / Compile Cytoplasm (x86, freebsd-v14.0) (push) Failing after 6s
Compile Cytoplasm / Compile Cytoplasm (x86, debian-v12.4) (push) Failing after 11s
Compile Cytoplasm / Compile Cytoplasm (x86_64, freebsd-v14.0) (push) Failing after 7s
Compile Cytoplasm / Compile Cytoplasm (x86, alpine-v3.19) (push) Failing after 10s
Compile Cytoplasm / Compile Cytoplasm (x86, netbsd-v9.3) (push) Failing after 11s
Compile Cytoplasm / Compile Cytoplasm (x86_64, openbsd-v7.4) (push) Failing after 12s
Compile Cytoplasm / Compile Cytoplasm (x86_64, alpine-v3.19) (push) Successful in 10s
Compile Cytoplasm / Compile Cytoplasm (x86_64, debian-v12.4) (push) Successful in 15s
Compile Cytoplasm / Compile Cytoplasm (x86_64, netbsd-v9.3) (push) Successful in 16s
We now default to only specifying POSIX compiler flags to maintain portability, unless a "fancy" compiler is detected that supports additional flags.
This commit is contained in:
parent
c693ab0a6a
commit
40a9c089ee
1 changed files with 40 additions and 31 deletions
71
configure
vendored
71
configure
vendored
|
@ -13,23 +13,44 @@ SRC="src"
|
|||
INCLUDE="src/include"
|
||||
TOOLS="tools"
|
||||
|
||||
CFLAGS="-Wall -Wextra -pedantic -std=c99 -O3 -pipe -D_DEFAULT_SOURCE -I${INCLUDE}"
|
||||
LIBS="-lm -pthread"
|
||||
# Default compiler flags. These must be supported by all POSIX C compilers.
|
||||
# "Fancy" compilers that have additional options must be detected and set below.
|
||||
CFLAGS="-O1 -D_DEFAULT_SOURCE -I${INCLUDE}"
|
||||
LIBS="-lm -lpthread"
|
||||
|
||||
# Default args for all platforms.
|
||||
SCRIPT_ARGS="--prefix=/usr/local --lib-name=Cytoplasm --lib-version=0.4.1"
|
||||
|
||||
# Set default args for all platforms
|
||||
SCRIPT_ARGS="--cc=c99 --prefix=/usr/local --enable-ld-extra --lib-name=Cytoplasm --lib-version=0.4.1 $@"
|
||||
|
||||
# Set platform specific args
|
||||
# Set SSL flags depending on the platform.
|
||||
case "$(uname)" in
|
||||
OpenBSD)
|
||||
SCRIPT_ARGS="--with-libressl $SCRIPT_ARGS"
|
||||
SCRIPT_ARGS="${SCRIPT_ARGS} --with-libressl"
|
||||
;;
|
||||
*)
|
||||
SCRIPT_ARGS="--with-openssl $SCRIPT_ARGS"
|
||||
SCRIPT_ARGS="${SCRIPT_ARGS} --with-openssl"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Set compiler depending on the platform.
|
||||
case "$(uname)" in
|
||||
Linux|NetBSD)
|
||||
# These systems typically use GCC.
|
||||
SCRIPT_ARGS="${SCRIPT_ARGS} --cc=gcc"
|
||||
;;
|
||||
OpenBSD|FreeBSD)
|
||||
# These systems typically use Clang.
|
||||
SCRIPT_ARGS="${SCRIPT_ARGS} --cc=clang"
|
||||
;;
|
||||
*)
|
||||
# Use default compiler which is required to be present on
|
||||
# all POSIX-compliant systems.
|
||||
SCRIPT_ARGS="${SCRIPT_ARGS} --cc=c99"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Append any additional args specified by user
|
||||
SCRIPT_ARGS="${SCRIPT_ARGS} $@"
|
||||
|
||||
echo "Processing options..."
|
||||
echo "Ran with arguments: $SCRIPT_ARGS"
|
||||
|
||||
|
@ -38,6 +59,14 @@ for arg in $SCRIPT_ARGS; do
|
|||
case "$arg" in
|
||||
--cc=*)
|
||||
CC=$(echo "$arg" | cut -d '=' -f 2-)
|
||||
case "${CC}" in
|
||||
gcc*|clang*)
|
||||
# "Fancy" compilers that support a plethora of additional flags we
|
||||
# want to enable if present.
|
||||
CFLAGS="-Wall -Werror -pedantic -std=c99 ${CFLAGS}"
|
||||
LDFLAGS="-flto -fdata-sections -ffunction-sections -s -Wl,-gc-sections"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
--with-openssl)
|
||||
TLS_IMPL="TLS_OPENSSL"
|
||||
|
@ -54,12 +83,6 @@ for arg in $SCRIPT_ARGS; do
|
|||
--prefix=*)
|
||||
PREFIX=$(echo "$arg" | cut -d '=' -f 2-)
|
||||
;;
|
||||
--enable-ld-extra)
|
||||
LD_EXTRA="-flto -fdata-sections -ffunction-sections -s -Wl,-gc-sections"
|
||||
;;
|
||||
--disable-ld-extra)
|
||||
LD_EXTRA=""
|
||||
;;
|
||||
--lib-name=*)
|
||||
LIB_NAME=$(echo "$arg" | cut -d '=' -f 2-)
|
||||
;;
|
||||
|
@ -68,21 +91,10 @@ for arg in $SCRIPT_ARGS; do
|
|||
;;
|
||||
--enable-debug)
|
||||
DEBUG="-O0 -g"
|
||||
echo "Notice: --enable-debug implies --disable-ld-extra and --no-static."
|
||||
echo "You must explicitly provide --enable-ld-extra and/or --static after"
|
||||
echo "specifying --enable-debug if you wish to enable these features in debug mode."
|
||||
LD_EXTRA=""
|
||||
STATIC=""
|
||||
;;
|
||||
--disable-debug)
|
||||
DEBUG=""
|
||||
;;
|
||||
--static)
|
||||
STATIC="-static -Wl,-static"
|
||||
;;
|
||||
--no-static)
|
||||
STATIC=""
|
||||
;;
|
||||
*)
|
||||
echo "Invalid argument: $arg"
|
||||
exit 1
|
||||
|
@ -96,7 +108,7 @@ if [ -n "$TLS_IMPL" ]; then
|
|||
fi
|
||||
|
||||
CFLAGS="${CFLAGS} '-DLIB_NAME=\"${LIB_NAME}\"' '-DLIB_VERSION=\"${LIB_VERSION}\"' ${DEBUG}"
|
||||
LDFLAGS="${LIBS} ${LD_EXTRA}"
|
||||
LDFLAGS="${LIBS} ${LDFLAGS}"
|
||||
|
||||
#
|
||||
# Makefile generation
|
||||
|
@ -159,16 +171,13 @@ compile_bin() {
|
|||
|
||||
echo "${out}: ${OUT}/lib/lib${LIB_NAME}.a ${OUT}/lib/lib${LIB_NAME}.so ${src}"
|
||||
echo "${TAB}@mkdir -p ${OUT}/bin"
|
||||
echo "${TAB}\$(CC) \$(CFLAGS) -o \"${out}\" \"${src}\" -L${OUT}/lib \$(LDFLAGS) -l${LIB_NAME} ${STATIC}"
|
||||
echo "${TAB}\$(CC) \$(CFLAGS) -o \"${out}\" \"${src}\" -L${OUT}/lib \$(LDFLAGS) -l${LIB_NAME}"
|
||||
}
|
||||
|
||||
compile_doc() {
|
||||
src="$1"
|
||||
out="$2"
|
||||
|
||||
if [ -z "${STATIC}" ]; then
|
||||
pref="LD_LIBRARY_PATH=${OUT}/lib "
|
||||
fi
|
||||
pref="LD_LIBRARY_PATH=${OUT}/lib "
|
||||
|
||||
echo "${out}: ${OUT}/bin/hdoc ${src}"
|
||||
echo "${TAB}@mkdir -p ${OUT}/man/man3"
|
||||
|
|
Loading…
Reference in a new issue