rsys

Basic data structures and low-level features
git clone git://git.meso-star.fr/rsys.git
Log | Files | Refs | README | LICENSE

commit 42625e3a9d80106e6f9324af1e0956d805ba42dc
parent e8713f82929fc807a30f230f07f759b5bda1df19
Author: vaplv <vaplv@free.fr>
Date:   Sun,  7 May 2023 16:42:53 +0200

Rework how the library is handled by the POSIX Makefile

The LIBSUFFIX macro is replaced by the more explicit LIB_TYPE macro,
which can take the value SHARED or STATIC. In addition, we define the
private libraries, i.e. the libraries that RSys depends on for linking
against it statically. The pkg-config file is thus updated as well as
the list of libraries against which the tests are linked according to
the LIB_TYPE macro.

Finally, the linker flags are also differentiated from BUILD_TYPE. In
the release, the entire symbol table and relocation information is
removed from the executables.

Diffstat:
MMakefile | 35+++++++++++++++++++++--------------
Mconfig.mk | 8+++++---
Mrsys.pc.in | 3++-
3 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/Makefile b/Makefile @@ -20,6 +20,10 @@ VERSION = 0.13.0 include config.mk +LIBNAME_STATIC = librsys.a +LIBNAME_SHARED = librsys.so +SYMBOL_SHARED = -DRSYS_SHARED_BUILD + ################################################################################ # RSys building ################################################################################ @@ -42,12 +46,12 @@ OBJ = $(SRC:.c=.o) DEP = $(SRC:.c=.d) build_library: $(DEP) - @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) librsys.$(LIBSUFFIX) + @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) $(LIBNAME_$(LIB_TYPE)) $(OBJ): config.mk librsys.so: $(OBJ) - $(CC) -o $@ $(OBJ) $(LDFLAGS) $(SOFLAGS) $(LIBS) + $(CC) -o $@ $(OBJ) $(LDFLAGS_$(BUILD_TYPE)) $(SOFLAGS) $(LIBS) librsys.a: $(OBJ) $(AR) -rc $@ $? @@ -58,7 +62,7 @@ librsys.a: $(OBJ) @$(CC) $(CFLAGS_$(BUILD_TYPE)) -MM -MT "$(@:.d=.o) $@" $< -MF $@ .c.o: - $(CC) $(CFLAGS_$(BUILD_TYPE)) -DRSYS_SHARED_BUILD -c $< -o $@ + $(CC) $(CFLAGS_$(BUILD_TYPE)) $(SYMBOL_$(LIB_TYPE)) -c $< -o $@ ################################################################################ # Installation @@ -128,16 +132,16 @@ pkg: @sed -e 's#@PREFIX@#$(PREFIX)#g' -e 's#@VERSION@#$(VERSION)#g' rsys.pc.in > rsys.pc install: build_library pkg - @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" librsys.$(LIBSUFFIX) + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/" $(LIBNAME_$(LIB_TYPE)) @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/rsys" COPYING README.md @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" rsys.pc @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/rsys" $(API) uninstall: - rm -f $(DESTDIR)$(PREFIX)/lib/librsys.$(LIBSUFFIX) - rm -f $(DESTDIR)$(PREFIX)/lib/pkgconfig/rsys.pc - rm -f $(DESTDIR)$(PREFIX)/share/doc/rsys/COPYING - rm -f $(DESTDIR)$(PREFIX)/share/doc/rsys/README.md + rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME_$(LIB_TYPE))" + rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/rsys.pc" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/rsys/COPYING" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/rsys/README.md" rm -f $$(echo $(API) | sed 's,src\/,$(DESTDIR)$(PREFIX)\/include\/rsys\/,g') ################################################################################ @@ -202,6 +206,9 @@ TEST_SRC =\ TEST_OBJ = $(TEST_SRC:.c=.o) TEST_DEP = $(TEST_SRC:.c=.d) +RSYS_LIBS_STATIC = librsys.a -ldl -lpthread -lm +RSYS_LIBS_SHARED = -L./ -lrsys + build_tests: build_library $(TEST_DEP) .test @$(MAKE) -fMakefile -f.test $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) test_bin @@ -273,7 +280,7 @@ test_morton \ test_ref \ test_vmacros \ : - $(CC) -o $@ src/$@.o $(LDFLAGS) + $(CC) -o $@ src/$@.o $(LDFLAGS_$(BUILD_TYPE)) test_double22 \ test_double2 \ @@ -289,7 +296,7 @@ test_float44 \ test_float4 \ test_math \ : - $(CC) -o $@ src/$@.o $(LDFLAGS) -lm + $(CC) -o $@ src/$@.o $(LDFLAGS_$(BUILD_TYPE)) -lm test_binary_heap\ test_cstr \ @@ -308,18 +315,18 @@ test_stretchy_array \ test_text_reader \ test_time \ : - $(CC) -o $@ src/$@.o $(LDFLAGS) -L$$(pwd) -lrsys + $(CC) -o $@ src/$@.o $(LDFLAGS_$(BUILD_TYPE)) $(RSYS_LIBS_$(LIB_TYPE)) test_quaternion: - $(CC) -o $@ src/$@.o $(LDFLAGS) -L$$(pwd) -lrsys -lm + $(CC) -o $@ src/$@.o $(LDFLAGS_$(BUILD_TYPE)) $(RSYS_LIBS_$(LIB_TYPE)) -lm test_condition test_mutex: - $(CC) -o $@ src/$@.o $(LDFLAGS) -fopenmp -L$$(pwd) -lrsys -lm + $(CC) -o $@ src/$@.o $(LDFLAGS_$(BUILD_TYPE)) $(RSYS_LIBS_$(LIB_TYPE)) -lm -fopenmp test_lib.o: src/test_library.c src/rsys.h $(CC) $(CFLAGS_$(BUILD_TYPE)) -c src/test_library.c -DTEST_LIBRARY_BUILD_LIB -o $@ libtest_lib.so: test_lib.o - $(CC) -o $@ test_lib.o $(LDFLAGS) $(SOFLAGS) + $(CC) -o $@ test_lib.o $(LDFLAGS_$(BUILD_TYPE)) $(SOFLAGS) test_library: libtest_lib.so diff --git a/config.mk b/config.mk @@ -1,7 +1,7 @@ PREFIX = /usr/local -LIBSUFFIX = so # Shared library -#LIBSUFFIX = a # Static library +LIB_TYPE = SHARED +#LIB_TYPE = STATIC BUILD_TYPE = RELEASE #BUILD_TYPE = DEBUG @@ -41,4 +41,6 @@ CFLAGS_DEBUG = -g $(CFLAGS_COMMON) ################################################################################ LIBS = -ldl -lpthread -lm SOFLAGS = -shared -Wl,--no-undefined -LDFLAGS = + +LDFLAGS_DEBUG = +LDFLAGS_RELEASE = -s diff --git a/rsys.pc.in b/rsys.pc.in @@ -5,5 +5,6 @@ libdir=${prefix}/lib Name: RSys Description: RSys library Version: @VERSION@ -Libs: -L${libdir} -lrsys -ldl -lpthread -lm +Libs: -L${libdir} -lrsys +Libs.private: -ldl -lpthread -lm CFlags: -I${includedir}