summaryrefslogtreecommitdiffhomepage
path: root/common.mk
diff options
context:
space:
mode:
Diffstat (limited to 'common.mk')
-rw-r--r--common.mk71
1 files changed, 71 insertions, 0 deletions
diff --git a/common.mk b/common.mk
new file mode 100644
index 0000000..5f4c77c
--- /dev/null
+++ b/common.mk
@@ -0,0 +1,71 @@
+CXX=clang++-14
+#CXX=g++-12
+
+ifeq ($(shell which $(CXX)),)
+CXX=clang++-13
+endif
+
+ifeq ($(shell which $(CXX)),)
+CXX=clang++-11
+endif
+
+ifeq ($(shell which $(CXX)),)
+CXX=clang++-10
+endif
+
+ifeq ($(shell which $(CXX)),)
+CXX=clang++
+endif
+
+ifeq ($(shell which $(CXX)),)
+CXX=g++-9
+endif
+
+ifeq ($(shell which $(CXX)),)
+CXX=g++
+endif
+
+ifeq ($(CXXFLAGS),)
+CXXFLAGS=-g -O2
+endif
+
+CXXFLAGS+=-Wall -fPIE -Wpedantic -gdwarf-4
+LDFLAGS+=-pie
+
+ifeq ($(CXX),g++-9)
+CXXFLAGS+=-std=c++17
+else
+CXXFLAGS+=-std=c++20
+endif
+
+ifeq ($(CXX),clang++-10)
+LIBS+=-fuse-ld=lld-10 -lstdc++
+CXXTYPE=clang++
+else ifeq ($(CXX),clang++-11)
+#LIBS+=-fuse-ld=lld-11 -lc++ -lc++abi
+LLVMPROFDATA=llvm-profdata-11
+LLVMCOV=llvm-cov-11
+CXXTYPE=clang++
+else ifeq ($(CXX),clang++-14)
+#LIBS+=-fuse-ld=lld-14 -lc++ -lc++abi
+LLVMPROFDATA=llvm-profdata-14
+LLVMCOV=llvm-cov-14
+CXXTYPE=clang++
+else
+LIBS+=-lstdc++ -lstdc++fs
+CXXTYPE=g++
+endif
+
+CXXFLAGS+=$(shell pkg-config --cflags qrcodegencpp GraphicsMagick++ fmt sqlite3)
+LIBS+=-lboost_filesystem -lpthread
+LIBS+=-lSQLiteCpp $(shell pkg-config --libs qrcodegencpp GraphicsMagick++ fmt sqlite3)
+LIBS+=-lreichwein
+
+SRC_ROOT=$(shell echo $(MAKEFILE_LIST) | tr " " "\n" | grep common.mk | sed -e 's/\([^ ]*\)common.mk/\1/g')
+ifeq ($(SRC_ROOT),)
+SRC_ROOT=.
+endif
+
+VERSION=$(shell dpkg-parsechangelog --show-field Version --file $(SRC_ROOT)/debian/changelog)
+CXXFLAGS+=-DWHITEBOARD_VERSION=\"$(VERSION)\"
+