libgrapheme

Freestanding C library for unicode string handling
git clone https://git.sinitax.com/suckless/libgrapheme
Log | Files | Refs | README | LICENSE | sfeed.txt

commit 7230c626e0e193ec0b8ee45404e84e530c796e78
parent 68391fc580b9a855271be57038d69cd2ce6ca0de
Author: Laslo Hunhold <dev@frign.de>
Date:   Wed, 17 Aug 2022 09:55:10 +0200

Build tests and benchmarks locally and add separate shared build-flags

Naturally, given tests and benchmark link against the built libgrapheme,
it makes no sense to compile them in the local build architecture.

Additionally, we add the establisheed SHFLAGS- and SOFLAGS-variables to
config.mk to give finer control over build-flags specific for the
shared object files and linking of the final so. This saves us from
indiscriminately compiling all object files as PIC and setting soname
for the test- and benchmark-binaries, which makes zero sense.

Signed-off-by: Laslo Hunhold <dev@frign.de>

Diffstat:
MMakefile | 13++++++++-----
Mconfig.mk | 9++++++---
2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile @@ -171,20 +171,23 @@ data/WordBreakProperty.txt: data/WordBreakTest.txt: wget -O $@ https://www.unicode.org/Public/14.0.0/ucd/auxiliary/WordBreakTest.txt -$(BENCHMARK:=.o) $(GEN:=.o) $(TEST:=.o): +$(GEN:=.o): $(BUILD_CC) -c -o $@ $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) $(@:.o=.c) -$(SRC:=.o): +$(BENCHMARK:=.o) $(TEST:=.o): $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(@:.o=.c) +$(SRC:=.o): + $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(SHFLAGS) $(@:.o=.c) + $(BENCHMARK): - $(BUILD_CC) -o $@ $(BUILD_LDFLAGS) $@.o benchmark/util.o libgrapheme.a -lutf8proc + $(CC) -o $@ $(LDFLAGS) $@.o benchmark/util.o libgrapheme.a -lutf8proc $(GEN): $(BUILD_CC) -o $@ $(BUILD_LDFLAGS) $@.o gen/util.o $(TEST): - $(BUILD_CC) -o $@ $(BUILD_LDFLAGS) $@.o test/util.o libgrapheme.a + $(CC) -o $@ $(LDFLAGS) $@.o test/util.o libgrapheme.a $(GEN:=.h): $(@:.h=) > $@ @@ -194,7 +197,7 @@ libgrapheme.a: $(SRC:=.o) $(RANLIB) $@ libgrapheme.so: $(SRC:=.o) - $(CC) -o $@ -shared $(LDFLAGS) $(SRC:=.o) + $(CC) -o $@ $(SOFLAGS) $(LDFLAGS) $(SRC:=.o) benchmark: $(BENCHMARK) for m in $(BENCHMARK); do ./$$m; done diff --git a/config.mk b/config.mk @@ -11,12 +11,15 @@ MANPREFIX = $(PREFIX)/share/man # flags CPPFLAGS = -D_DEFAULT_SOURCE -CFLAGS = -std=c99 -Os -fPIC -Wall -Wextra -Wpedantic -LDFLAGS = -Wl,--soname=libgrapheme.so +CFLAGS = -std=c99 -Os -Wall -Wextra -Wpedantic +LDFLAGS = -s BUILD_CPPFLAGS = $(CPPFLAGS) BUILD_CFLAGS = $(CFLAGS) -BUILD_LDFLAGS = -s +BUILD_LDFLAGS = $(LDFLAGS) + +SHFLAGS = -fPIC +SOFLAGS = -shared -Wl,--soname=libgrapheme.so # tools CC = cc