forked from ports/contrib
86 lines
2.3 KiB
Diff
86 lines
2.3 KiB
Diff
diff --git a/cpp/Makefile b/cpp/Makefile
|
|
index 858a1bf..2f8d8ed 100644
|
|
--- a/cpp/Makefile
|
|
+++ b/cpp/Makefile
|
|
@@ -28,13 +28,6 @@
|
|
# - CXX: The C++ compiler, such as g++ or clang++.
|
|
# - CXXFLAGS: Any extra user-specified compiler flags (can be blank).
|
|
|
|
-# Mandatory compiler flags
|
|
-CXXFLAGS += -std=c++11
|
|
-# Diagnostics. Adding '-fsanitize=address' is helpful for most versions of Clang and newer versions of GCC.
|
|
-CXXFLAGS += -Wall -fsanitize=undefined
|
|
-# Optimization level
|
|
-CXXFLAGS += -O1
|
|
-
|
|
|
|
# ---- Controlling make ----
|
|
|
|
@@ -51,30 +44,60 @@ CXXFLAGS += -O1
|
|
|
|
# ---- Targets to build ----
|
|
|
|
-LIB = qrcodegen
|
|
-LIBFILE = lib$(LIB).a
|
|
+LIB = qrcodegencpp
|
|
+LIBFILE = lib$(LIB).so
|
|
+ARFILE = lib$(LIB).a
|
|
+SO_NAME = $(LIBFILE).1
|
|
+REAL_NAME = $(LIBFILE).$(QRCODEGEN_VERSION)
|
|
+HEADERS = BitBuffer.hpp QrCode.hpp QrSegment.hpp
|
|
LIBOBJ = BitBuffer.o QrCode.o QrSegment.o
|
|
MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker
|
|
|
|
+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)
|
|
$(CXX) $(CXXFLAGS) -o $@ $< -L . -l $(LIB)
|
|
|
|
# The library
|
|
-$(LIBFILE): $(LIBOBJ)
|
|
+$(ARFILE): $(LIBOBJ)
|
|
$(AR) -crs $@ -- $^
|
|
|
|
+$(LIBFILE): $(LIBOBJ)
|
|
+ $(CXX) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^
|
|
+
|
|
# Object files
|
|
%.o: %.cpp .deps/timestamp
|
|
- $(CXX) $(CXXFLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
|
|
+ $(CXX) $(CXXFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $<
|
|
|
|
# Have a place to store header dependencies automatically generated by compiler
|
|
.deps/timestamp:
|