Skip to content

Commit

Permalink
add CFLAGS+=... handling to configure
Browse files Browse the repository at this point in the history
The `+=` argument form provides a way of extending the current or
default value of a compiler-configuration variable, instead of
replacing it. For example, `CFLAGS+=-std=gnu99` adds `-std=gnu99` to
the C compiler flags, instead of requiring `CFLAGS=-O2 -std=gnu99` to
keep the default and add a new flag.

In addition, changed `configure` to treat the existence of a `CFLAGS`
environment variable the same as if `CFLAGS=` is provided as an
argument.
  • Loading branch information
mflatt committed Dec 11, 2023
1 parent 9b274bb commit 5c1b298
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ if [ "$srcdir" != "." ]; then
fi
machs=$machs$sep2$last

if [ "${CFLAGS}" != "" ] ; then
cflagsset=yes
elif [ "${CFLAGS-default}" = "" ] ; then
cflagsset=yes
else
cflagsset=no
fi

m=""
w=""
pb=no
Expand All @@ -65,7 +73,6 @@ installpetitename="petite"
installscriptname="scheme-script"
unamebits=""
relativeBootFiles=yes
cflagsset=no
disablex11=no
disablecurses=no
disableiconv=no
Expand All @@ -83,6 +90,7 @@ default_warning_flags="-Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough"
: ${RANLIB:="ranlib"}
: ${WINDRES:="windres"}
: ${STRIP:="strip"}
CFLAGS_ADD=
zlibLib=
LZ4Lib=
Kernel=KernelLib
Expand Down Expand Up @@ -389,10 +397,16 @@ while [ $# != 0 ] ; do
CPPFLAGS=*)
CPPFLAGS=`echo $1 | sed -e 's/^CPPFLAGS=//'`
;;
CPPFLAGS+=*)
CPPFLAGS="$CPPFLAGS "`echo $1 | sed -e 's/^CPPFLAGS+=//'`
;;
CFLAGS=*)
CFLAGS=`echo $1 | sed -e 's/^CFLAGS=//'`
cflagsset=yes
;;
CFLAGS+=*)
CFLAGS_ADD="$CFLAGS_ADD "`echo $1 | sed -e 's/^CFLAGS+=//'`
;;
CC_FOR_BUILD=*)
CC_FOR_BUILD=`echo $1 | sed -e 's/^CC_FOR_BUILD=//'`
;;
Expand All @@ -402,9 +416,15 @@ while [ $# != 0 ] ; do
LDFLAGS=*)
LDFLAGS=`echo $1 | sed -e 's/^LDFLAGS=//'`
;;
LDFLAGS+=*)
LDFLAGS=`echo $1 | sed -e 's/^LDFLAGS+=//'`
;;
LIBS=*)
LIBS=`echo $1 | sed -e 's/^LIBS=//'`
;;
LIBS+=*)
LIBS="${LIBS} "`echo $1 | sed -e 's/^LIBS+=//'`
;;
AR=*)
AR=`echo $1 | sed -e 's/^AR=//'`
;;
Expand Down Expand Up @@ -636,11 +656,15 @@ if [ "$help" = "yes" ]; then
echo " --as-is skip Git submodule update"
echo " CC=<C compiler> C compiler"
echo " CPPFLAGS=<C preprocessor flags> C preprocessor flags"
echo " CPPFLAGS+=<C preprocessor flags> add C preprocessor flags"
echo " CFLAGS=<C compiler flags> C compiler flags"
echo " CFLAGS+=<C compiler flags> add C compiler flags"
echo " CC_FOR_BUILD=<C compiler> C compiler and flags for build machine"
echo " LD=<linker> linker"
echo " LDFLAGS=<linker flags> additional linker flags"
echo " LDFLAGS+=<linker flags> add additional linker flags"
echo " LIBS=<libraries> additional libraries"
echo " LIBS+=<libraries> add additional libraries"
echo " AR=<archiver> archiver"
echo " ARFLAGS=<archiver flgs> archiver flags"
echo " RANLIB=<archive indexer> archive indexer"
Expand Down Expand Up @@ -767,6 +791,8 @@ if [ "$cflagsset" = "no" ] ; then
esac
fi

CFLAGS="${CFLAGS}${CFLAGS_ADD}"

if [ "$CC_FOR_BUILD" = "" ] ; then
CC_FOR_BUILD="${CC} ${CFLAGS}"
else
Expand Down

0 comments on commit 5c1b298

Please sign in to comment.