diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2020-10-23 08:16:36 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2020-10-23 08:22:59 +0200 |
commit | 1318c4983f830693cc614921b68f35ff46646f4a (patch) | |
tree | 224696f7ca12e2fcfd2a7a07f26afcc5e27a4844 | |
parent | c503954f4426bd0fb719c9e403d3de36094978ac (diff) | |
download | sdn-1318c4983f830693cc614921b68f35ff46646f4a.tar.gz sdn-1318c4983f830693cc614921b68f35ff46646f4a.tar.xz sdn-1318c4983f830693cc614921b68f35ff46646f4a.zip |
Makefile: make portable, support static linking
We can happily stick to POSIX and the usual variable names,
with the following exceptions:
- pkg-config(1) is used to find libraries and compile flags
- the new "static" target uses non-standard compiler
and linker flags, though it's not the default target
sdn is predestined for wild distribution,
even the dynamically linked libc is rather suboptimal.
-rw-r--r-- | Makefile | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -1,12 +1,19 @@ +.POSIX: SHELL = /bin/sh -CXXFLAGS = -g -std=c++14 -Wall -Wextra -pedantic -static-libstdc++ - -all: sdn -%: %.cpp CMakeLists.txt - $(CXX) $(CXXFLAGS) $< -o $@ `pkg-config --libs --cflags ncursesw` -lacl \ - `sed -ne 's/^project (\([^ )]*\).*/-DPROJECT_NAME="\1"/p' \ +CXXFLAGS = -g -std=c++14 -Wall -Wextra -pedantic +CPPFLAGS = `sed -ne 's/^project (\([^ )]*\).*/-DPROJECT_NAME="\1"/p' \ -e 's/^set (version \([^ )]*\).*/-DPROJECT_VERSION="\1"/p' CMakeLists.txt` + +sdn: sdn.cpp CMakeLists.txt + $(CXX) $(CXXFLAGS) $(CPPFLAGS) $< -o sdn \ + -lacl `pkg-config --libs --cflags ncursesw` +static: sdn.cpp CMakeLists.txt + $(CXX) $(CXXFLAGS) $(CPPFLAGS) $< -o sdn \ + -static-libstdc++ \ + -Wl,--start-group,-Bstatic \ + -lacl `pkg-config --static --libs --cflags ncursesw` \ + -Wl,--end-group,-Bdynamic clean: rm -f sdn -.PHONY: all clean +.PHONY: static clean |