forked from ports/contrib
86 lines
2.3 KiB
Diff
86 lines
2.3 KiB
Diff
diff --git a/c/Makefile b/c/Makefile
|
|
index 99f926b..635faa2 100644
|
|
--- a/c/Makefile
|
|
+++ b/c/Makefile
|
|
@@ -28,13 +28,6 @@
|
|
# - CC: The C compiler, such as gcc or clang.
|
|
# - CFLAGS: Any extra user-specified compiler flags (can be blank).
|
|
|
|
-# Mandatory compiler flags
|
|
-CFLAGS += -std=c99
|
|
-# Diagnostics. Adding '-fsanitize=address' is helpful for most versions of Clang and newer versions of GCC.
|
|
-CFLAGS += -Wall -fsanitize=undefined
|
|
-# Optimization level
|
|
-CFLAGS += -O1
|
|
-
|
|
|
|
# ---- Controlling make ----
|
|
|
|
@@ -52,18 +45,45 @@ CFLAGS += -O1
|
|
# ---- Targets to build ----
|
|
|
|
LIB = qrcodegen
|
|
-LIBFILE = lib$(LIB).a
|
|
+LIBFILE = lib$(LIB).so
|
|
+ARFILE = lib$(LIB).a
|
|
+SO_NAME = $(LIBFILE).1
|
|
+REAL_NAME = $(LIBFILE).$(QRCODEGEN_VERSION)
|
|
+HEADERS = qrcodegen.h
|
|
LIBOBJ = qrcodegen.o
|
|
MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker
|
|
|
|
+MULTIARCH := $(shell gcc --print-multiarch)
|
|
+
|
|
+INCLUDEDIR := $(DESTDIR)/usr/include/qrcodegen
|
|
+LIBDIR := $(DESTDIR)/usr/lib/$(MULTIARCH)
|
|
+
|
|
# 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) -o $@ $< -L . -l $(LIB)
|
|
@@ -73,12 +93,15 @@ qrcodegen-test: qrcodegen-test.c $(LIBOBJ:%.o=%.c)
|
|
$(CC) $(CFLAGS) -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:
|