#!/usr/bin/make -f DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH) ifneq (,$(filter $(DEB_BUILD_ARCH),armhf arm64)) SIGNED_CHAR = -fsigned-char else SIGNED_CHAR = endif CFLAGS = $(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS) $(SIGNED_CHAR) -Wno-error CXXFLAGS = $(shell dpkg-buildflags --get CXXFLAGS) $(shell dpkg-buildflags --get CPPFLAGS) -std=gnu++98 -Wno-error LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS) -Wl,--as-needed cmake_options = \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_VERBOSE_MAKEFILE=ON \ -DCMAKE_BUILD_TYPE=relwithdebinfo \ -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(CFLAGS)" \ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(CXXFLAGS)" \ -DCMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO="$(LDFLAGS)" \ -DCMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO="$(LDFLAGS)" \ -DCMAKE_INSTALL_RPATH=/usr/lib/$(DEB_HOST_MULTIARCH)/cuneiform parallel = -j$(or $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))),1) # These don't need to be exported and if they are we'll get the flags # duplicated in the command line. unexport CFLAGS unexport CXXFLAGS unexport LDFLAGS export DPKG_GENSYMBOLS_CHECK_LEVEL = 4 # build and build-{arch,indep} targets # ==================================== .PHONY: build build-arch build-indep build: build-arch build-indep build-indep: # Nothing to do here. build-arch: obj/build-stamp obj/test-stamp obj/CMakeCache.txt: CMakeLists.txt mkdir -p obj cd obj && cmake .. $(cmake_options) obj/build-stamp: obj/CMakeCache.txt $(MAKE) $(parallel) -C obj touch $(@) obj/test-stamp: obj/build-stamp ifeq "$(filter nocheck,$(DEB_BUILD_OPTIONS))" "" CF_DATADIR=$(CURDIR)/datafiles/ debian/tests/ground-truth obj/cuneiform endif touch $(@) # binary and binary-{arch,indep} targets # ====================================== .PHONY: binary binary-arch binary-indep binary: binary-arch binary-indep binary-arch: build-arch dh_testroot dh_prep -a $(MAKE) -C obj install DESTDIR=$(CURDIR)/debian/tmp/ dh_install -p libcuneiform-dev '/usr/lib*/libcuneiform.so' /usr/lib/$(DEB_HOST_MULTIARCH)/ dh_install -p libcuneiform0 '/usr/lib*/lib*.so.*' /usr/lib/$(DEB_HOST_MULTIARCH)/cuneiform/ cd debian/libcuneiform0/usr/lib/$(DEB_HOST_MULTIARCH)/cuneiform/ && mv -t ../ libcuneiform.so.* dh_install -a dh_installdocs -a dh_installchangelogs -a dh_buildinfo -a dh_installman -a dh_compress -a dh_fixperms -a dh_strip -a dh_makeshlibs -a -X/cuneiform/ dh_shlibdeps -a dh_installdeb -a dh_gencontrol -a dh_md5sums -a dh_builddeb -a binary-indep: build-indep dh_testroot dh_prep -i -X tmp dh_install -i dh_installdocs -i dh_installchangelogs -i dh_buildinfo -a dh_compress -i dh_fixperms -i dh_installdeb -i dh_gencontrol -i dh_md5sums -i dh_builddeb -i # clean target # ============ .PHONY: clean clean: dh_clean rm -rf obj # get-orig-source target # ====================== here = $(dir $(firstword $(MAKEFILE_LIST)))/.. upstream_version = $(shell cd $(here) && dpkg-parsechangelog -SVersion | sed -r -e 's/([0-9.]+).*/\1/') .PHONY: get-orig-source get-orig-source: sh $(here)/debian/get-orig-source.sh $(upstream_version)