2016-02-07 20:02:44 +00:00
|
|
|
#!/usr/bin/make -f
|
|
|
|
# -*- makefile -*-
|
|
|
|
|
|
|
|
# Uncomment this to turn on verbose mode.
|
2018-03-23 16:05:14 +00:00
|
|
|
export DH_VERBOSE=1
|
2017-04-10 17:43:30 +00:00
|
|
|
|
|
|
|
# -pie only for static mode
|
2020-12-22 19:56:44 +00:00
|
|
|
export DEB_BUILD_MAINT_OPTIONS=hardening=-all
|
2017-04-10 17:43:30 +00:00
|
|
|
|
|
|
|
# because copy_headers.sh have hardcoded path to build/include_directories.txt
|
2019-01-18 15:19:53 +00:00
|
|
|
BUILDDIR = obj-$(DEB_HOST_GNU_TYPE)
|
2018-03-28 12:17:23 +00:00
|
|
|
CURDIR = $(shell pwd)
|
|
|
|
DESTDIR = $(CURDIR)/debian/tmp
|
2017-04-10 17:43:30 +00:00
|
|
|
|
|
|
|
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
|
2016-02-07 20:02:44 +00:00
|
|
|
|
2018-09-28 14:53:20 +00:00
|
|
|
ifeq ($(CCACHE_PREFIX),distcc)
|
|
|
|
THREADS_COUNT=$(shell distcc -j)
|
|
|
|
endif
|
|
|
|
ifeq ($(THREADS_COUNT),)
|
2020-09-17 09:52:15 +00:00
|
|
|
THREADS_COUNT=$(shell nproc || grep -c ^processor /proc/cpuinfo || sysctl -n hw.ncpu || echo 4)
|
2018-05-07 20:31:50 +00:00
|
|
|
endif
|
|
|
|
DEB_BUILD_OPTIONS+=parallel=$(THREADS_COUNT)
|
2016-11-15 10:25:08 +00:00
|
|
|
|
2018-02-07 15:58:48 +00:00
|
|
|
ifndef ENABLE_TESTS
|
|
|
|
CMAKE_FLAGS += -DENABLE_TESTS=0
|
2020-05-21 15:02:52 +00:00
|
|
|
else
|
|
|
|
# To export binaries and from deb build we do not strip them. No need to run tests in deb build as we run them in CI
|
|
|
|
DEB_BUILD_OPTIONS+= nocheck
|
|
|
|
DEB_BUILD_OPTIONS+= nostrip
|
2018-02-07 15:58:48 +00:00
|
|
|
endif
|
2017-08-30 14:08:19 +00:00
|
|
|
|
2018-08-23 12:28:45 +00:00
|
|
|
ifndef MAKE_TARGET
|
|
|
|
MAKE_TARGET = clickhouse-bundle
|
|
|
|
endif
|
|
|
|
|
2018-08-23 16:06:13 +00:00
|
|
|
CMAKE_FLAGS += -DENABLE_UTILS=0
|
|
|
|
|
2020-09-24 08:35:16 +00:00
|
|
|
DEB_CC ?= $(shell which gcc-10 gcc-9 gcc | head -n1)
|
|
|
|
DEB_CXX ?= $(shell which g++-10 g++-9 g++ | head -n1)
|
2019-09-17 10:37:35 +00:00
|
|
|
|
2017-08-30 14:08:19 +00:00
|
|
|
ifdef DEB_CXX
|
|
|
|
DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
|
|
|
DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
|
2017-01-10 18:28:24 +00:00
|
|
|
ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
|
2017-08-30 14:08:19 +00:00
|
|
|
CC := $(DEB_CC)
|
|
|
|
CXX := $(DEB_CXX)
|
2017-01-10 18:28:24 +00:00
|
|
|
else
|
2017-08-30 14:08:19 +00:00
|
|
|
CC := $(DEB_HOST_GNU_TYPE)-$(DEB_CC)
|
|
|
|
CXX := $(DEB_HOST_GNU_TYPE)-$(DEB_CXX)
|
|
|
|
endif
|
2017-01-10 18:28:24 +00:00
|
|
|
endif
|
|
|
|
|
2018-09-18 15:59:14 +00:00
|
|
|
ifdef CXX
|
|
|
|
CMAKE_FLAGS += -DCMAKE_CXX_COMPILER=`which $(CXX)`
|
|
|
|
endif
|
|
|
|
ifdef CC
|
|
|
|
CMAKE_FLAGS += -DCMAKE_C_COMPILER=`which $(CC)`
|
|
|
|
endif
|
2018-03-29 12:57:23 +00:00
|
|
|
|
2018-05-05 12:31:47 +00:00
|
|
|
ifndef DISABLE_NINJA
|
|
|
|
NINJA=$(shell which ninja)
|
2018-03-29 12:57:23 +00:00
|
|
|
ifneq ($(NINJA),)
|
2018-05-05 12:31:47 +00:00
|
|
|
CMAKE_FLAGS += -GNinja
|
2020-12-22 07:38:39 +00:00
|
|
|
export MAKE=$(NINJA) $(NINJA_FLAGS)
|
2018-05-05 12:31:47 +00:00
|
|
|
endif
|
2018-03-29 12:57:23 +00:00
|
|
|
endif
|
2017-08-30 14:08:19 +00:00
|
|
|
|
2017-05-03 15:21:16 +00:00
|
|
|
ifndef DH_VERBOSE
|
|
|
|
CMAKE_FLAGS += -DCMAKE_VERBOSE_MAKEFILE=0
|
|
|
|
endif
|
2017-01-10 18:28:24 +00:00
|
|
|
|
2018-04-25 05:59:48 +00:00
|
|
|
# Useful for bulding on low memory systems
|
|
|
|
ifndef DISABLE_PARALLEL
|
|
|
|
DH_FLAGS += --parallel
|
2018-05-07 20:31:50 +00:00
|
|
|
else
|
|
|
|
THREADS_COUNT = 1
|
2018-04-25 05:59:48 +00:00
|
|
|
endif
|
|
|
|
|
2018-09-28 14:53:20 +00:00
|
|
|
ifneq ($(THREADS_COUNT),)
|
|
|
|
THREADS_COUNT:=-j$(THREADS_COUNT)
|
|
|
|
endif
|
|
|
|
|
2017-04-10 17:43:30 +00:00
|
|
|
%:
|
2019-01-18 15:19:53 +00:00
|
|
|
dh $@ $(DH_FLAGS) --buildsystem=cmake
|
2017-01-10 18:28:24 +00:00
|
|
|
|
2017-04-10 17:43:30 +00:00
|
|
|
override_dh_auto_configure:
|
|
|
|
dh_auto_configure -- $(CMAKE_FLAGS)
|
2017-01-10 18:28:24 +00:00
|
|
|
|
2018-05-07 20:31:50 +00:00
|
|
|
override_dh_auto_build:
|
2018-06-19 18:09:09 +00:00
|
|
|
# Fix for ninja. Do not add -O.
|
2019-01-18 15:19:53 +00:00
|
|
|
$(MAKE) $(THREADS_COUNT) -C $(BUILDDIR) $(MAKE_TARGET)
|
2018-05-07 20:31:50 +00:00
|
|
|
|
2017-04-10 17:43:30 +00:00
|
|
|
override_dh_auto_test:
|
2020-05-21 15:02:52 +00:00
|
|
|
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
|
2020-12-21 22:11:21 +00:00
|
|
|
cd $(BUILDDIR) && ctest $(THREADS_COUNT) -V
|
2020-05-21 15:02:52 +00:00
|
|
|
endif
|
2017-04-10 17:43:30 +00:00
|
|
|
|
|
|
|
override_dh_clean:
|
2018-04-01 12:33:39 +00:00
|
|
|
rm -rf debian/copyright debian/clickhouse-client.docs debian/clickhouse-common-static.docs
|
2020-05-21 15:02:52 +00:00
|
|
|
dh_clean # -X contrib
|
2016-02-07 20:02:44 +00:00
|
|
|
|
2017-04-10 17:43:30 +00:00
|
|
|
override_dh_strip:
|
2020-07-06 11:51:07 +00:00
|
|
|
#https://www.debian.org/doc/debian-policy/ch-source.html#debian-rules-and-deb-build-options
|
2020-05-21 15:02:52 +00:00
|
|
|
ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
|
2018-04-02 18:44:19 +00:00
|
|
|
dh_strip -pclickhouse-common-static --dbg-package=clickhouse-common-static-dbg
|
2020-05-21 15:02:52 +00:00
|
|
|
endif
|
2016-02-07 20:02:44 +00:00
|
|
|
|
2017-04-10 17:43:30 +00:00
|
|
|
override_dh_install:
|
|
|
|
# Making docs
|
|
|
|
cp LICENSE debian/copyright
|
|
|
|
|
2018-04-01 12:33:39 +00:00
|
|
|
ln -sf clickhouse-server.docs debian/clickhouse-client.docs
|
|
|
|
ln -sf clickhouse-server.docs debian/clickhouse-common-static.docs
|
2017-04-10 17:43:30 +00:00
|
|
|
|
2017-11-10 13:52:23 +00:00
|
|
|
# systemd compatibility
|
|
|
|
mkdir -p $(DESTDIR)/etc/systemd/system/
|
|
|
|
cp debian/clickhouse-server.service $(DESTDIR)/etc/systemd/system/
|
|
|
|
|
2017-04-10 17:43:30 +00:00
|
|
|
dh_install --list-missing --sourcedir=$(DESTDIR)
|
2017-04-10 18:13:24 +00:00
|
|
|
|
2018-03-28 12:17:23 +00:00
|
|
|
override_dh_auto_install:
|
2019-01-18 15:19:53 +00:00
|
|
|
env DESTDIR=$(DESTDIR) $(MAKE) $(THREADS_COUNT) -C $(BUILDDIR) install
|
2018-03-28 12:17:23 +00:00
|
|
|
|
2017-04-10 18:13:24 +00:00
|
|
|
override_dh_shlibdeps:
|
2017-09-15 09:18:52 +00:00
|
|
|
true # We depend only on libc and dh_shlibdeps gives us wrong (too strict) dependency.
|
|
|
|
|
|
|
|
override_dh_builddeb:
|
|
|
|
dh_builddeb -- -Z gzip # Older systems don't have "xz", so use "gzip" instead.
|