Skip to content

Commit

Permalink
added static linking for executable portability
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiandeorowicz committed Jul 8, 2024
1 parent 37723be commit 833bb4a
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
all: phist matcher subsystem ng_zlib

ifdef MSVC # Avoid the MingW/Cygwin sections
uname_S := Windows
uname_M := "x86_64"
else # If uname not available => 'not'
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
endif

CFLAGS=-O3 -std=c++11

ifeq ($(uname_S),Linux)
CFLAGS+=-fabi-version=6
CFLAGS+=-static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
endif

ifeq ($(uname_S),Darwin)
CFLAGS+= -lc -static-libgcc
endif


ZLIB_DIR=./3rd_party/zlib-ng

phist: utils/phist.cpp ng_zlib subsystem
$(CXX) -std=c++11 -O3 utils/phist.cpp -o utils/phist
$(CXX) $(CFLAGS) utils/phist.cpp -o utils/phist

matcher: utils/matcher.cpp utils/input_file.cpp ng_zlib
$(CXX) -std=c++11 -o utils/matcher -I${ZLIB_DIR} -O3 utils/matcher.cpp utils/input_file.cpp $(ZLIB_DIR)/libz.a
$(CXX) $(CFLAGS) -o utils/matcher -I${ZLIB_DIR} utils/matcher.cpp utils/input_file.cpp $(ZLIB_DIR)/libz.a

ng_zlib:
cd $(ZLIB_DIR) && ./configure --zlib-compat && $(MAKE) libz.a
Expand Down

0 comments on commit 833bb4a

Please sign in to comment.