PROJECTNAME=unicode VERSION=$(shell dpkg-parsechangelog --show-field Version) DISTROS=base debian10 ubuntu2004 ubuntu2010 ifeq ($(wildcard $(shell which clang++-11)),) ifeq ($(wildcard $(shell which clang++)),) $(error No clang++-11 nor clang++ available!) else CXX=clang++ endif else CXX=clang++-11 # GCC is buggy: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85282 #CXX=g++-10 endif STANDARD=c++17 #STANDARD=c++20 ifeq ($(CXXFLAGS),) CXXFLAGS=-O0 -g -D_DEBUG #CXXFLAGS=-O2 -DNDEBUG endif CXXFLAGS+=-Wall -Iinclude -std=$(STANDARD) ifeq ($(CXX),clang++-11) COMPILER_SUITE=clang LIBS+=-fuse-ld=lld-11 endif ifeq ($(CXX),clang++) COMPILER_SUITE=clang LIBS+=-fuse-ld=lld endif ifeq ($(COMPILER_SUITE),clang) CXXFLAGS+=-stdlib=libc++ endif LDLIBS+=\ -lboost_context \ -lboost_filesystem \ -lboost_timer \ -lboost_system \ ifeq ($(COMPILER_SUITE),clang) LIBS+= \ -lc++ \ -lc++abi #-lc++fs #-lstdc++ \ #-lstdc++fs else LIBS+= \ -lstdc++ #-lstdc++fs endif SRC=\ src/recode.cpp \ src/test-unicode.cpp all: src/recode src/test-unicode test: src/test-unicode src/test-unicode src/recode: src/recode.o dep $(CXX) $(LDFLAGS) $< $(LDLIBS) $(LIBS) -o $@ src/test-unicode: src/test-unicode.o dep $(CXX) $(LDFLAGS) $< $(LDLIBS) $(LIBS) -o $@ dep: $(SRC:.cpp=.d) %.d: %.cpp $(CXX) $(CXXFLAGS) -MM -MP -MF $@ -MT $(*D)/$(*F).o -c $< %.o: %.cpp %.d $(CXX) $(CXXFLAGS) -c $< -o $@ clean: -rm -f src/recode src/test-unicode -rm -rf result -find . -name '*.o' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f install: mkdir -p $(DESTDIR)/usr/include cp include/unicode.h $(DESTDIR)/usr/include deb: # build binary deb package dpkg-buildpackage -rfakeroot deb-src: dh_clean dh_auto_clean dpkg-source -b -I.git -Iresult . $(DISTROS): deb-src sudo pbuilder build --basetgz /var/cache/pbuilder/$@.tgz --buildresult result/$@ ../$(PROJECTNAME)_$(VERSION).dsc debsign result/$@/$(PROJECTNAME)_$(VERSION)_amd64.changes debs: $(DISTROS) .PHONY: all test clean install dep deb deb-src $(DISTROS) -include $(wildcard $(SRC:.cpp=.d))