# HG changeset patch # User Mike Becker # Date 1767892575 -3600 # Node ID 93b2368451f67f183308910ba47efb1b9ae7d5db # Parent ba9431028671a556d225a71a9811c674de9c2867 toolchain.sh now generates defaults for all flags variables - resolves #767 diff -r ba9431028671 -r 93b2368451f6 src/main/resources/make/cc.mk --- a/src/main/resources/make/cc.mk Wed Dec 24 14:25:24 2025 +0100 +++ b/src/main/resources/make/cc.mk Thu Jan 08 18:16:15 2026 +0100 @@ -2,6 +2,11 @@ # cc toolchain config # +# How to use: +# - remove empty assignments and variables that you do not need +# - optionally: add toolchain specific variables and/or options +# - or: remove this file entirely (defaults will apply) +# - remove this comment CFLAGS = CXXFLAGS = DEBUG_CFLAGS = -g diff -r ba9431028671 -r 93b2368451f6 src/main/resources/make/clang.mk --- a/src/main/resources/make/clang.mk Wed Dec 24 14:25:24 2025 +0100 +++ b/src/main/resources/make/clang.mk Thu Jan 08 18:16:15 2026 +0100 @@ -2,6 +2,11 @@ # clang toolchain config # +# How to use: +# - remove empty assignments and variables that you do not need +# - optionally: add toolchain specific variables and/or options +# - or: remove this file entirely (cc.mk or defaults will apply) +# - remove this comment CFLAGS = CXXFLAGS = DEBUG_CFLAGS = -g diff -r ba9431028671 -r 93b2368451f6 src/main/resources/make/gcc.mk --- a/src/main/resources/make/gcc.mk Wed Dec 24 14:25:24 2025 +0100 +++ b/src/main/resources/make/gcc.mk Thu Jan 08 18:16:15 2026 +0100 @@ -2,6 +2,11 @@ # gcc toolchain config # +# How to use: +# - remove empty assignments and variables that you do not need +# - optionally: add toolchain specific variables and/or options +# - or: remove this file entirely (cc.mk or defaults will apply) +# - remove this comment CFLAGS = CXXFLAGS = DEBUG_CFLAGS = -g diff -r ba9431028671 -r 93b2368451f6 src/main/resources/make/suncc.mk --- a/src/main/resources/make/suncc.mk Wed Dec 24 14:25:24 2025 +0100 +++ b/src/main/resources/make/suncc.mk Thu Jan 08 18:16:15 2026 +0100 @@ -2,6 +2,11 @@ # suncc toolchain # +# How to use: +# - remove empty assignments and variables that you do not need +# - optionally: add toolchain specific variables and/or options +# - or: remove this file entirely (cc.mk or defaults will apply) +# - remove this comment CFLAGS = CXXFLAGS = DEBUG_CFLAGS = -g diff -r ba9431028671 -r 93b2368451f6 src/main/resources/make/toolchain.sh --- a/src/main/resources/make/toolchain.sh Wed Dec 24 14:25:24 2025 +0100 +++ b/src/main/resources/make/toolchain.sh Thu Jan 08 18:16:15 2026 +0100 @@ -162,21 +162,66 @@ fi } +is_flag_not_specified() +{ + # 1: flag to test + # 2: toolchain.mk file + if [ -n "$2" ] && grep "^ *$1 *=" "$2" > /dev/null; then + return 1 + else + return 0 + fi +} + write_toolchain_defaults() { + if [ -f "make/${TOOLCHAIN_NAME}.mk" ]; then + mkfile="make/${TOOLCHAIN_NAME}.mk" + elif [ -f 'make/cc.mk' ]; then + mkfile='make/cc.mk' + else + mkfile='' + fi + echo "# toolchain" >> "$1" if [ -n "$TOOLCHAIN_CC" ]; then echo "CC = ${TOOLCHAIN_CC}" >> "$1" + if is_flag_not_specified 'CFLAGS' "$mkfile"; then + echo 'CFLAGS =' >> "$1" + fi + if is_flag_not_specified 'DEBUG_CFLAGS' "$mkfile"; then + echo 'DEBUG_CFLAGS = -g' >> "$1" + fi + if is_flag_not_specified 'RELEASE_CFLAGS' "$mkfile"; then + echo 'RELEASE_CFLAGS = -O3 -DNDEBUG' >> "$1" + fi + if is_flag_not_specified 'SHLIB_CFLAGS' "$mkfile"; then + echo 'SHLIB_CFLAGS = -fPIC' >> "$1" + fi fi if [ -n "$TOOLCHAIN_CXX" ]; then echo "CXX = ${TOOLCHAIN_CXX}" >> "$1" + if is_flag_not_specified 'CXXFLAGS' "$mkfile"; then + echo 'CXXFLAGS =' >> "$1" + fi + if is_flag_not_specified 'DEBUG_CXXFLAGS' "$mkfile"; then + echo 'DEBUG_CXXFLAGS = -g' >> "$1" + fi + if is_flag_not_specified 'RELEASE_CXXFLAGS' "$mkfile"; then + echo 'RELEASE_CXXFLAGS = -O3 -DNDEBUG' >> "$1" + fi + if is_flag_not_specified 'SHLIB_CXXFLAGS' "$mkfile"; then + echo 'SHLIB_CXXFLAGS = -fPIC' >> "$1" + fi + fi + if is_flag_not_specified 'LDFLAGS' "$mkfile"; then + echo 'LDFLAGS =' >> "$1" + fi + if is_flag_not_specified 'SHLIB_LDFLAGS' "$mkfile"; then + echo 'SHLIB_LDFLAGS = -shared' >> "$1" fi echo >> "$1" - if [ -f "make/${TOOLCHAIN_NAME}.mk" ]; then - cat "make/${TOOLCHAIN_NAME}.mk" >> "$1" - elif [ -f "make/cc.mk" ]; then - cat "make/cc.mk" >> "$1" - else - echo "!!! WARNING !!! Default toolchain flags not found. Configuration might be incomplete." + if [ -n "$mkfile" ]; then + cat "$mkfile" >> "$1" fi } diff -r ba9431028671 -r 93b2368451f6 test/make/cc.mk --- a/test/make/cc.mk Wed Dec 24 14:25:24 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -# -# cc toolchain config -# - -CFLAGS = -CXXFLAGS = -DEBUG_CFLAGS = -g -DEBUG_CXXFLAGS = -g -RELEASE_CFLAGS = -O3 -DNDEBUG -RELEASE_CXXFLAGS = -O3 -DNDEBUG -LDFLAGS = - -SHLIB_CFLAGS = -fPIC -SHLIB_LDFLAGS = -shared diff -r ba9431028671 -r 93b2368451f6 test/make/clang.mk --- a/test/make/clang.mk Wed Dec 24 14:25:24 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -# -# clang toolchain config -# - -CFLAGS = -CXXFLAGS = -DEBUG_CFLAGS = -g -DEBUG_CXXFLAGS = -g -RELEASE_CFLAGS = -O3 -DNDEBUG -RELEASE_CXXFLAGS = -O3 -DNDEBUG -LDFLAGS = - -SHLIB_CFLAGS = -fPIC -SHLIB_LDFLAGS = -shared diff -r ba9431028671 -r 93b2368451f6 test/make/gcc.mk --- a/test/make/gcc.mk Wed Dec 24 14:25:24 2025 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -# -# gcc toolchain config -# - -CFLAGS = -CXXFLAGS = -DEBUG_CFLAGS = -g -DEBUG_CXXFLAGS = -g -RELEASE_CFLAGS = -O3 -DNDEBUG -RELEASE_CXXFLAGS = -O3 -DNDEBUG -LDFLAGS = - -SHLIB_CFLAGS = -fPIC -SHLIB_LDFLAGS = -shared - diff -r ba9431028671 -r 93b2368451f6 test/make/suncc.mk --- a/test/make/suncc.mk Wed Dec 24 14:25:24 2025 +0100 +++ b/test/make/suncc.mk Thu Jan 08 18:16:15 2026 +0100 @@ -2,14 +2,6 @@ # suncc toolchain # -CFLAGS = -CXXFLAGS = -DEBUG_CFLAGS = -g -DEBUG_CXXFLAGS = -g -RELEASE_CFLAGS = -O3 -DNDEBUG -RELEASE_CXXFLAGS = -O3 -DNDEBUG -LDFLAGS = - SHLIB_CFLAGS = -Kpic SHLIB_LDFLAGS = -G diff -r ba9431028671 -r 93b2368451f6 test/make/toolchain.sh --- a/test/make/toolchain.sh Wed Dec 24 14:25:24 2025 +0100 +++ b/test/make/toolchain.sh Thu Jan 08 18:16:15 2026 +0100 @@ -162,21 +162,66 @@ fi } +is_flag_not_specified() +{ + # 1: flag to test + # 2: toolchain.mk file + if [ -n "$2" ] && grep "^ *$1 *=" "$2" > /dev/null; then + return 1 + else + return 0 + fi +} + write_toolchain_defaults() { + if [ -f "make/${TOOLCHAIN_NAME}.mk" ]; then + mkfile="make/${TOOLCHAIN_NAME}.mk" + elif [ -f 'make/cc.mk' ]; then + mkfile='make/cc.mk' + else + mkfile='' + fi + echo "# toolchain" >> "$1" if [ -n "$TOOLCHAIN_CC" ]; then echo "CC = ${TOOLCHAIN_CC}" >> "$1" + if is_flag_not_specified 'CFLAGS' "$mkfile"; then + echo 'CFLAGS =' >> "$1" + fi + if is_flag_not_specified 'DEBUG_CFLAGS' "$mkfile"; then + echo 'DEBUG_CFLAGS = -g' >> "$1" + fi + if is_flag_not_specified 'RELEASE_CFLAGS' "$mkfile"; then + echo 'RELEASE_CFLAGS = -O3 -DNDEBUG' >> "$1" + fi + if is_flag_not_specified 'SHLIB_CFLAGS' "$mkfile"; then + echo 'SHLIB_CFLAGS = -fPIC' >> "$1" + fi fi if [ -n "$TOOLCHAIN_CXX" ]; then echo "CXX = ${TOOLCHAIN_CXX}" >> "$1" + if is_flag_not_specified 'CXXFLAGS' "$mkfile"; then + echo 'CXXFLAGS =' >> "$1" + fi + if is_flag_not_specified 'DEBUG_CXXFLAGS' "$mkfile"; then + echo 'DEBUG_CXXFLAGS = -g' >> "$1" + fi + if is_flag_not_specified 'RELEASE_CXXFLAGS' "$mkfile"; then + echo 'RELEASE_CXXFLAGS = -O3 -DNDEBUG' >> "$1" + fi + if is_flag_not_specified 'SHLIB_CXXFLAGS' "$mkfile"; then + echo 'SHLIB_CXXFLAGS = -fPIC' >> "$1" + fi + fi + if is_flag_not_specified 'LDFLAGS' "$mkfile"; then + echo 'LDFLAGS =' >> "$1" + fi + if is_flag_not_specified 'SHLIB_LDFLAGS' "$mkfile"; then + echo 'SHLIB_LDFLAGS = -shared' >> "$1" fi echo >> "$1" - if [ -f "make/${TOOLCHAIN_NAME}.mk" ]; then - cat "make/${TOOLCHAIN_NAME}.mk" >> "$1" - elif [ -f "make/cc.mk" ]; then - cat "make/cc.mk" >> "$1" - else - echo "!!! WARNING !!! Default toolchain flags not found. Configuration might be incomplete." + if [ -n "$mkfile" ]; then + cat "$mkfile" >> "$1" fi }