[hackers] [libgrapheme] Build tests and benchmarks locally and add separate shared build-flags || Laslo Hunhold

From: <git_AT_suckless.org>
Date: Wed, 17 Aug 2022 09:59:54 +0200 (CEST)

commit 7230c626e0e193ec0b8ee45404e84e530c796e78
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Wed Aug 17 09:55:10 2022 +0200
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Wed Aug 17 09:55:10 2022 +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_AT_frign.de>

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

This archive was generated by hypermail 2.3.0 : Wed Aug 17 2022 - 10:00:47 CEST