1- # Makefile (C/C++; OOS-build support; gmake-form/style; v2024.04 .16)
1+ # Makefile (C/C++; OOS-build support; gmake-form/style; v2025.06 .16)
22# Cross-platform (bash/sh + CMD/PowerShell)
33# `bcc32`, `cl`, `clang`, `embcc32`, and `gcc` (defaults to `CC=clang`)
44# * supports multi-binary projects; adapts to project structure
55# GNU make (gmake) compatible; ref: <https://www.gnu.org/software/make/manual>
6- # Copyright (C) 2020-2024 ~ Roy Ivy III <rivy.dev@gmail.com>; MIT+Apache-2.0 license
6+ # Copyright (C) 2020-2025 ~ Roy Ivy III <rivy.dev@gmail.com>; MIT+Apache-2.0 license
77
88# NOTE: * requires `make` version 4.0+ (minimum needed for correct path functions); for windows, install using `scoop install make`
99# NOTE: `make` doesn't handle spaces within file names without gyrations (see <https://stackoverflow.com/questions/9838384/can-gnu-make-handle-filenames-with-spaces>@@<https://archive.is/PYKKq>)
@@ -511,14 +511,23 @@ LDFLAGS_ARCH_64 := ${CFLAGS_ARCH_64}
511511LDFLAGS_DEBUG_false := $(if $(filter nix,${OSID}),-Xlinker --strip-all,)
512512LDFLAGS_DEBUG_true_STATIC_false_clang := -Xlinker /NODEFAULTLIB:libcmt -Xlinker /NODEFAULTLIB:libcmtd -lmsvcrtd
513513LDFLAGS_DEBUG_false_STATIC_false_clang := -Xlinker /NODEFAULTLIB:libcmt -Xlinker /NODEFAULTLIB:libcmtd -lmsvcrt
514- LDFLAGS_DEBUG_true_STATIC_false_gcc := -shared-libgcc -shared-libstdc++
515- LDFLAGS_DEBUG_false_STATIC_false_gcc := -shared-libgcc -shared-libstdc++
514+ # ## * gcc v10 (and earlier); dynamic linking of C++ library requires `-shared-libstdc++` option
515+ # LDFLAGS_DEBUG_true_STATIC_false_gcc := -shared -shared-libgcc -shared-libstdc++
516+ # LDFLAGS_DEBUG_false_STATIC_false_gcc := -shared -shared-libgcc -shared-libstdc++
517+ # ## * gcc v11+ ; dynamic linking of C++ library became the default (and `-shared-libstdc++` option removed)
518+ # LDFLAGS_DEBUG_true_STATIC_false_gcc := -shared -shared-libgcc
519+ # LDFLAGS_DEBUG_false_STATIC_false_gcc := -shared -shared-libgcc
516520# LDFLAGS_STATIC_false := -pie
517- # LDFLAGS_STATIC_false := -shared
521+ LDFLAGS_STATIC_false := -shared
518522# LDFLAGS_STATIC_true := -static -static-libgcc -static-libstdc++
519523LDFLAGS_STATIC_true := -static
520524LDFLAGS_clang += $(if $(filter nix,${OSID}),-lstdc++,)
521525LDFLAGS_gcc += -lstdc++
526+ # gcc-version-specific flags
527+ ## * gcc v10 (and earlier); dynamic linking of C++ library requires `-shared-libstdc++` option
528+ ## * gcc v11+ ; dynamic linking of C++ library became the default (and `-shared-libstdc++` option removed)
529+ LDFLAGS_gcc_gcc11+_false_STATIC_false := -shared-libgcc -shared-libstdc++
530+ LDFLAGS_gcc_gcc11+_true_STATIC_false := -shared-libgcc
522531## * resource compiler
523532## for `clang`, use `llvm-rc -H` for option help
524533## for `gcc`, use `windres --help` for option help
@@ -956,6 +965,7 @@ CC_version_Mm := $(strip ${CC_version_M}.${CC_version_m})
956965
957966is_clang13+ := $(call %as_truthy,$(and $(call %eq,clang,${CC_ID}),$(call %not,$(filter ${CC_version_M},0 1 2 3 4 5 6 7 8 9 10 11 12)),${true}))
958967is_CL1600+ := $(call %as_truthy,$(or $(call %eq,clang-cl,${CC}),$(and $(call %eq,cl,${CC}),$(call %not,$(filter ${CC_version_M},0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)),${true})))
968+ is_gcc11+ := $(call %as_truthy,$(and $(call %eq,gcc,${CC_ID}),$(call %not,$(filter ${CC_version_M},0 1 2 3 4 5 6 7 8 9 10)),${true}))
959969is_VC6 := $(call %as_truthy,$(and $(call %eq,cl,${CC}),$(call %eq,12,${CC_version_M}),${true}))
960970
961971$(call %debug_var,CC_version)
@@ -966,6 +976,7 @@ $(call %debug_var,CC_version_r)
966976$(call %debug_var,CC_version_Mm)
967977$(call %debug_var,is_clang13+)
968978$(call %debug_var,is_CL1600+)
979+ $(call %debug_var,is_gcc11+)
969980$(call %debug_var,is_VC6)
970981
971982####
@@ -1037,6 +1048,7 @@ LDFLAGS += ${LDFLAGS_DEBUG_${DEBUG}}
10371048LDFLAGS += ${LDFLAGS_STATIC_${STATIC}}
10381049LDFLAGS += ${LDFLAGS_DEBUG_${DEBUG}_STATIC_${STATIC}}
10391050LDFLAGS += ${LDFLAGS_DEBUG_${DEBUG}_STATIC_${STATIC}_${CC_ID}}
1051+ LDFLAGS += ${LDFLAGS_${CC_ID}_gcc11+_${is_gcc11+}_STATIC_${STATIC}}
10401052LDFLAGS += ${LDFLAGS_VC6_${is_VC6}}## name-expanded variable is only defined for ${CC_ID}=='cl'
10411053LDFLAGS += ${LDFLAGS_${CC_ID}}
10421054LDFLAGS += ${LDFLAGS_${CC_ID}_${OSID}}
0 commit comments