Skip to content

Commit 833bb4a

Browse files
added static linking for executable portability
1 parent 37723be commit 833bb4a

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

makefile

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
all: phist matcher subsystem ng_zlib
22

3+
ifdef MSVC # Avoid the MingW/Cygwin sections
4+
uname_S := Windows
5+
uname_M := "x86_64"
6+
else # If uname not available => 'not'
7+
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
8+
uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
9+
endif
10+
11+
CFLAGS=-O3 -std=c++11
12+
13+
ifeq ($(uname_S),Linux)
14+
CFLAGS+=-fabi-version=6
15+
CFLAGS+=-static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
16+
endif
17+
18+
ifeq ($(uname_S),Darwin)
19+
CFLAGS+= -lc -static-libgcc
20+
endif
21+
22+
323
ZLIB_DIR=./3rd_party/zlib-ng
424

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

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

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

0 commit comments

Comments
 (0)