85 lines
2.3 KiB
Diff
85 lines
2.3 KiB
Diff
--- c/Makefile.orig 2021-08-08 17:21:08 UTC
|
|
+++ c/Makefile
|
|
@@ -29,11 +29,13 @@
|
|
# - CFLAGS: Any extra user-specified compiler flags (can be blank).
|
|
|
|
# Recommended compiler flags:
|
|
-CFLAGS += -std=c99 -O
|
|
+CFLAGS ?= -std=c99 -O
|
|
|
|
# Extra flags for diagnostics:
|
|
# CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
|
|
|
|
+# Version information
|
|
+VERSION = 1.7.0
|
|
|
|
# ---- Controlling make ----
|
|
|
|
@@ -51,18 +53,45 @@ 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
|
|
+REAL_NAME = $(LIBFILE).$(VERSION)
|
|
+HEADERS = qrcodegen.h
|
|
LIBOBJ = qrcodegen.o
|
|
MAINS = qrcodegen-demo qrcodegen-test
|
|
|
|
+# define paths to install
|
|
+INCLUDEDIR ?= $(DESTDIR)$(PREFIX)/include/qrcodegen
|
|
+LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
|
|
+
|
|
# 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
|
|
|
|
+install-shared: $(LIBFILE)
|
|
+ install -d $(LIBDIR) || true
|
|
+ install -m 0644 $(LIBFILE) $(LIBDIR)/$(REAL_NAME)
|
|
+ rm -f $(LIBDIR)/$(SO_NAME)
|
|
+ ln -s $(REAL_NAME) $(LIBDIR)/$(SO_NAME)
|
|
+ rm -f $(LIBDIR)/$(LIBFILE)
|
|
+ ln -s $(SO_NAME) $(LIBDIR)/$(LIBFILE)
|
|
+
|
|
+install-static: $(ARFILE)
|
|
+ install -d $(LIBDIR) || true
|
|
+ install -m 0644 $(ARFILE) $(LIBDIR)/$(ARFILE)
|
|
+
|
|
+install-header: $(HEADERS)
|
|
+ install -d $(INCLUDEDIR) || true
|
|
+ install -m 0644 $(HEADERS) $(INCLUDEDIR)/
|
|
+
|
|
+install: install-shared install-static install-header
|
|
+
|
|
# Executable files
|
|
%: %.o $(LIBFILE)
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -L . -l $(LIB)
|
|
@@ -72,12 +101,15 @@ 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) -c -o $@ -MMD -MF .deps/$*.d $<
|
|
+ $(CC) $(CFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $<
|
|
|
|
# Have a place to store header dependencies automatically generated by compiler
|
|
.deps/timestamp:
|