commit 6edcfca97fb01418cfdb8a2595060a63b7471d48 from: Omar Polo date: Tue Jul 06 13:01:11 2021 UTC try to preserve as much as possible CFLAGS and LDFLAGS from env but still try to autodetect with pkg-config if they aren't provided. Passing CFLAGS/LDFLAGS from the command line will still override the guessed ones. commit - eb877bffaa6b188caf0f8fc75a89f8e4721cc167 commit + 6edcfca97fb01418cfdb8a2595060a63b7471d48 blob - ec62a4673ef7c34f742d9f68bdcd0afa582cf5a1 blob + 1b4b649070c2f364030aad0c49b2015f0023dcaf --- ChangeLog +++ ChangeLog @@ -1,3 +1,7 @@ +2021-07-06 Omar Polo + + * configure (guessing_cflags): try to preserve CFLAGS/LDFLAGS + 2021-07-02 Omar Polo * sandbox.c (filter): seccomp filter reworked: now it should work on x86 and possibly other arches too! blob - b2016559f0f3a24fbce5cce38c46e2182fafc469 blob + 2cfcff2238759a428e3adb09f53b86ffb4d4af6d --- configure +++ configure @@ -32,13 +32,25 @@ echo "file config.log: writing..." # -------- # default settings: initialize all vars here such that nothing is -# leaked from the environment except for CC and CFLAGS +# leaked from the environment except for CC, CFLAGS and LDFLAGS CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | make ${MAKE_FLAGS} -sf -` -CFLAGS=`printf "all:\\n\\t@echo \\\$(CFLAGS)\\n" | make ${MAKE_FLAGS} -sf -` -CFLAGS="${CFLAGS} -g -W -Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes" -CFLAGS="${CFLAGS} -Wwrite-strings -Wno-unused-parameter" -LDFLAGS="-ltls -levent" + +guessing_cflags=0 +if [ -z "${CFLAGS}" ]; then + guessing_cflags=1 + CFLAGS=`printf "all:\\n\\t@echo \\\$(CFLAGS)\\n" | make ${MAKE_FLAGS} -sf -` + CFLAGS="${CFLAGS} -W -Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes" + CFLAGS="${CFLAGS} -Wwrite-strings -Wno-unused-parameter" +fi + +guessing_ldflags=0 +if [ -z "${LDFLAGS}" ]; then + guessing_ldflags=1 + LDFLAGS=`printf "all:\\n\\t@echo \\\$(LDFLAGS)\\n" | make ${MAKE_FLAGS} -sf -` + LDFLAGS="-ltls -levent -lcrypto" +fi + LD_IMSG= STATIC= YACC=yacc @@ -53,15 +65,28 @@ BINDIR= INSTALL="install" +add_cflags() { + if [ $guessing_cflags = 1 ]; then + CFLAGS="${CFLAGS} $1" + fi +} + +add_ldflags() { + if [ $guessing_ldflags = 1 ]; then + LDFLAGS="${LDFLAGS} $1" + fi +} + # try to auto detect CFLAGS and LDFLAGS if which pkg-config 2>/dev/null 1>&2; then if pkg-config libtls; then - CFLAGS="${CFLAGS} $(pkg-config --cflags libtls)" - LDFLAGS="$(pkg-config --libs libtls)" + add_cflags "$(pkg-config --cflags libtls)" + add_ldflags "$(pkg-config --libs libtls)" fi + if pkg-config openssl; then - CFLAGS="${CFLAGS} $(pkg-config --cflags openssl)" - LDFLAGS="${LDFLAGS} $(pkg-config --libs openssl)" + add_cflags "$(pkg-config --cflags openssl)" + add_ldflags "$(pkg-config --libs openssl)" fi case "$(uname)" in @@ -70,8 +95,8 @@ if which pkg-config 2>/dev/null 1>&2; then ;; *) if pkg-config libevent; then - CFLAGS="${CFLAGS} $(pkg-config --cflags libevent)" - LDFLAGS="${LDFLAGS} $(pkg-config --libs libevent)" + add_cflags "$(pkg-config --cflags libevent)" + add_ldflags "$(pkg-config --libs libevent)" fi ;; esac