Compare commits

...

2 Commits

Author SHA1 Message Date
1318c4983f
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.
2020-10-23 08:22:59 +02:00
c503954f44
Cleanup
The wchar_t variant of compute_width() is no longer needed.

So all in all the better help has saved code.
2020-10-23 07:53:37 +02:00
2 changed files with 14 additions and 14 deletions

View File

@ -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

View File

@ -353,13 +353,6 @@ fun print (const ncstring &nc, int limit) -> int {
return total_width;
}
fun compute_width (const wstring &w) -> int {
int total = 0;
for (const auto &c : w)
total += wcwidth (c);
return total;
}
fun compute_width (const ncstring &nc) -> int {
int total = 0;
for (const auto &c : nc)