From 16351a7ebaf318d21632bbaabf0675a70bb67dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Tue, 3 Dec 2019 12:07:19 +0100 Subject: [PATCH 3/5] Generate both shared and static libraries --- c/Makefile | 14 ++++++++++---- cpp/Makefile | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) Index: QR-Code-generator-1.8.0/c/Makefile =================================================================== --- QR-Code-generator-1.8.0.orig/c/Makefile +++ QR-Code-generator-1.8.0/c/Makefile @@ -51,16 +51,19 @@ CFLAGS += -std=c99 -O # ---- Targets to build ---- LIB = qrcodegen -LIBFILE = lib$(LIB).a +ARFILE = lib$(LIB).a +LIBFILE = lib$(LIB).so +# Bump the soname number when the ABI changes and gets incompatible +SO_NAME = $(LIBFILE).1 LIBOBJ = qrcodegen.o MAINS = qrcodegen-demo qrcodegen-test # Build all binaries -all: $(LIBFILE) $(MAINS) +all: $(LIBFILE) $(ARFILE) $(MAINS) # Delete build output clean: - rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS) + rm -f -- $(LIBOBJ) $(LIBFILE) $(ARFILE) $(MAINS:=.o) $(MAINS) rm -rf .deps # Executable files @@ -72,9 +75,12 @@ qrcodegen-test: qrcodegen-test.c $(LIBOB $(CC) $(CFLAGS) $(LDFLAGS) -DQRCODEGEN_TEST -o $@ $^ # The library -$(LIBFILE): $(LIBOBJ) +$(ARFILE): $(LIBOBJ) $(AR) -crs $@ -- $^ +$(LIBFILE): $(LIBOBJ) + $(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^ + # Object files %.o: %.c .deps/timestamp $(CC) $(CFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $< Index: QR-Code-generator-1.8.0/cpp/Makefile =================================================================== --- QR-Code-generator-1.8.0.orig/cpp/Makefile +++ QR-Code-generator-1.8.0/cpp/Makefile @@ -51,16 +51,19 @@ CXXFLAGS += -std=c++11 -O # ---- Targets to build ---- LIB = qrcodegencpp -LIBFILE = lib$(LIB).a +ARFILE = lib$(LIB).a +LIBFILE = lib$(LIB).so +# Bump the soname number when the ABI changes and gets incompatible +SO_NAME = $(LIBFILE).1 LIBOBJ = qrcodegen.o MAINS = QrCodeGeneratorDemo # Build all binaries -all: $(LIBFILE) $(MAINS) +all: $(LIBFILE) $(LIBFILE) $(MAINS) # Delete build output clean: - rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS) + rm -f -- $(LIBOBJ) $(ARFILE) $(LIBFILE) $(MAINS:=.o) $(MAINS) rm -rf .deps # Executable files @@ -68,9 +71,12 @@ clean: $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $< -L . -l $(LIB) # The library -$(LIBFILE): $(LIBOBJ) +$(ARFILE): $(LIBOBJ) $(AR) -crs $@ -- $^ +$(LIBFILE): $(LIBOBJ) + $(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^ + # Object files %.o: %.cpp .deps/timestamp $(CXX) $(CXXFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $<