Skip to content

Commit

Permalink
Update Makefile for partial static compilation on freebsd
Browse files Browse the repository at this point in the history
  • Loading branch information
aristocratos committed Aug 3, 2023
1 parent c8ec6bb commit 1b126f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Makefile
Expand Up @@ -92,15 +92,17 @@ ifneq ($(PLATFORM) $(ARCH),macos arm64)
endif

ifeq ($(STATIC),true)
ifeq ($(CXX_IS_CLANG),true)
ifeq ($(CXX_IS_CLANG) $(CLANG_WORKS),true true)
ifeq ($(shell $(CXX) -print-target-triple | grep gnu >/dev/null; echo $$?),0)
$(error $(shell printf "\033[1;91mERROR: \033[97m$(CXX) can't statically link glibc\033[0m"))
endif
else
override ADDFLAGS += -static-libgcc -static-libstdc++
endif
ifneq ($(PLATFORM),macos)
ifeq ($(PLATFORM_LC),linux)
override ADDFLAGS += -DSTATIC_BUILD -static -Wl,--fatal-warnings
else ifeq ($(PLATFORM_LC),freebsd)
override ADDFLAGS += -DSTATIC_BUILD
endif
endif

Expand All @@ -123,7 +125,10 @@ else ifeq ($(PLATFORM_LC),freebsd)
PLATFORM_DIR := freebsd
THREADS := $(shell getconf NPROCESSORS_ONLN 2>/dev/null || echo 1)
SU_GROUP := wheel
override ADDFLAGS += -lstdc++ -lm -lkvm -ldevstat -Wl,-rpath=/usr/local/lib/gcc$(CXX_VERSION_MAJOR)
override ADDFLAGS += -lm -lkvm -ldevstat -Wl,-rpath=/usr/local/lib/gcc$(CXX_VERSION_MAJOR)
ifneq ($(STATIC),true)
override ADDFLAGS += -lstdc++
endif
export MAKE = gmake
else ifeq ($(PLATFORM_LC),macos)
PLATFORM_DIR := osx
Expand Down
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -510,6 +510,8 @@ Also needs a UTF8 locale and a font that covers:

Append `VERBOSE=true` to display full compiler/linker commands.

Append `STATIC=true` for static compilation (only libgcc and libstdc++ will be static!).

Append `QUIET=true` for less verbose output.

Append `STRIP=true` to force stripping of debug symbols (adds `-s` linker flag).
Expand Down

0 comments on commit 1b126f5

Please sign in to comment.