ClickHouse/debian/rules

177 lines
7.0 KiB
Makefile
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
ifndef THREADS_COUNT
THREADS_COUNT=`nproc || grep -c ^processor /proc/cpuinfo`
endif
BUILD_TARGETS=clickhouse $(DAEMONS)
DEB_GCC_VERSION ?= -6
DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
CC := gcc$(DEB_GCC_VERSION)
CXX := g++$(DEB_GCC_VERSION)
else
CC := $(DEB_HOST_GNU_TYPE)-gcc$(DEB_GCC_VERSION)
CXX := $(DEB_HOST_GNU_TYPE)-g++$(DEB_GCC_VERSION)
endif
CMAKE_FLAGS ?= -DCMAKE_CXX_COMPILER=`which $(CXX)` -DCMAKE_C_COMPILER=`which $(CC)`
ifdef CMAKE_BUILD_TYPE
CMAKE_FLAGS += -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
endif
ifdef USE_STATIC_LIBRARIES
CMAKE_FLAGS += -DUSE_STATIC_LIBRARIES=$(USE_STATIC_LIBRARIES)
endif
configure-stamp:
dh_testdir
rm -rf build
make clean 1> /dev/null 2>&1 || echo "Nothing to clean"
rm -f CMakeCache.txt
mkdir -p build
touch configure-stamp
build: build-stamp
build-stamp: configure-stamp
dh_testdir
# если не задан тип сборки запускаем cmake без указания типа, если задан - передаём его
# for building Debug run: debuild -e CMAKE_BUILD_TYPE=Debug
# for building with shared libs run: debuild -e USE_STATIC_LIBRARIES=0
cd build && pwd && cmake .. $(CMAKE_FLAGS)
# TODO: возможно надо исправить
# последовательно запускаем make для каждой из целей.
# т.к. при параллельном запуске (make target1 target2) несколько раз одновременно создаются бинарники
# и возникает raise с custom_command, использующие эти бинарники
for target in ${BUILD_TARGETS}; do $(MAKE) -j$(THREADS_COUNT) -C build $$target; done
touch $@
clean:
dh_testdir
dh_testroot
rm -f configure-stamp build-stamp
rm -rf build
# Удалим созданные для dh_installinit файлы
find ./debian/ -name "*.init" -type l -delete
# Удалим созданные для dh_installcron файлы
find ./debian/ -name "*.cron.d" -type f -delete
# Удалим созданные ссылки на файлы документации
find ./debian/ -name "*.docs" -type l -delete
rm -f ./debian/copyright
# Удалим созданные *.install файлы
for DAEMON_PKG in ${DAEMONS}; do AUTO=`grep "# automatically created" debian/$$DAEMON_PKG.install`; if [ "x$$AUTO" != "x" ]; then rm -f debian/$$DAEMON_PKG.install; fi; done
dh_clean
install: build
dh_testdir
dh_testroot
dh_prep
cd build && \
for target in ${BUILD_TARGETS}; do DESTDIR=../debian/tmp cmake -DCOMPONENT=$$target -P cmake_install.cmake; done
# Создаём нужные файлы для dh_installinit, т.к. он их понимает только внутри debian/
for I in debian/tmp/etc/init.d/*; do echo $$I; ln -s tmp/etc/init.d/`basename $$I` debian/`basename $$I`.init; done
# Хотим, чтобы для пакета clickhouse-server-base init file назывался clickhouse-server
if [ -e debian/tmp/etc/init.d/clickhouse-server ]; then ln -s tmp/etc/init.d/clickhouse-server debian/clickhouse-server-base.clickhouse-server.init; fi
# создаем дефолтный cron, если нет крон-файла созданного пользователем
# cron_name имеет вид daemonname
# Для ClickHouse не должно быть лишних зависимостей.
for I in debian/tmp/etc/init.d/*; \
do \
cron_name=`basename $$I`; \
if [ ! -d debian/tmp/etc/cron.d ]; then \
mkdir -p debian/tmp/etc/cron.d; \
fi; \
if [ ! -f debian/tmp/etc/cron.d/$$cron_name ]; then \
echo "#*/10 * * * * root /etc/init.d/$$cron_name condstart 1>/dev/null 2>&1" > debian/tmp/etc/cron.d/$$cron_name; \
fi; \
done; \
# Making necessary *.install files
for DAEMON_PKG in ${DAEMONS}; do \
if [ ! -e "debian/$$DAEMON_PKG.install" ]; then \
echo "# automatically created" > debian/$$DAEMON_PKG.install; \
echo "/etc/$$DAEMON_PKG/config.xml" >> debian/$$DAEMON_PKG.install; \
echo "/usr/bin/$$DAEMON_PKG" >> debian/$$DAEMON_PKG.install; \
echo "/etc/cron.d/$$DAEMON_PKG" >> debian/$$DAEMON_PKG.install; \
if [ -e "debian/tmp/etc/monrun/conf.d/$$DAEMON_PKG.conf" ]; then \
echo "/etc/monrun/conf.d/$$DAEMON_PKG.conf" >> debian/$$DAEMON_PKG.install; \
fi;\
fi; \
done
# Making necessary *.postinst files
for DAEMON_PKG in ${DAEMONS}; do \
if [ ! -e "debian/$$DAEMON_PKG.postinst" ]; then \
echo "# automatically created" > debian/$$DAEMON_PKG.postinst; \
echo "mkdir -p /etc/$$DAEMON_PKG/conf.d" >> debian/$$DAEMON_PKG.postinst; \
echo "chown -R metrika: /etc/$$DAEMON_PKG" >> debian/$$DAEMON_PKG.postinst; \
if [ -e "debian/tmp/etc/init.d/$$DAEMON_PKG" ]; then \
if echo $$DAEMON_PKG | grep server > /dev/null; then\
echo "update-rc.d $$DAEMON_PKG defaults > /dev/null || exit \$$?" >> debian/$$DAEMON_PKG.postinst; \
else\
echo "update-rc.d $$DAEMON_PKG start 30 2 3 4 5 . stop 70 0 1 6 . > /dev/null || exit \$$?" >> debian/$$DAEMON_PKG.postinst; \
fi\
fi\
\
else \
echo >> debian/$$DAEMON_PKG.postinst; \
echo "mkdir -p /etc/$$DAEMON_PKG/conf.d; chown -R metrika: /etc/$$DAEMON_PKG" >> debian/$$DAEMON_PKG.postinst; \
fi; \
done
# В случае сборки clickhouse-server, добавим в пакет бинарник clang-а, ld и заголовочные файлы - для динамической компиляции.
if [ -e debian/tmp/etc/init.d/clickhouse-server ]; then \
mkdir -p debian/tmp/usr/share/clickhouse/bin debian/tmp/usr/share/clickhouse/headers; \
debian/copy_clang_binaries.sh debian/tmp/usr/share/clickhouse/bin/; \
./copy_headers.sh . debian/tmp/usr/share/clickhouse/headers; \
fi;
# Создаём документацию
cp LICENSE debian/copyright
for DAEMON_PKG in ${DAEMONS}; do \
echo "LICENSE" > debian/$$DAEMON_PKG.docs; \
echo "AUTHORS" >> debian/$$DAEMON_PKG.docs; \
echo "README.md" >> debian/$$DAEMON_PKG.docs; \
done
ln -s clickhouse-server.docs debian/clickhouse-server-base.docs
ln -s clickhouse-server.docs debian/clickhouse-server-common.docs
ln -s clickhouse-server.docs debian/clickhouse-server-metrika.docs
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installdocs
dh_installinit --no-start --no-package=clickhouse-server-base
dh_installinit --no-start --package=clickhouse-server-base --name=clickhouse-server
dh_installcron
dh_installdirs
dh_installchangelogs
dh_install --sourcedir=debian/tmp
dh_link
dh_compress
dh_fixperms
dh_installdeb
dh_shlibdeps --exclude=clang --exclude=stdc --exclude=ld
dh_gencontrol
dh_md5sums
dh_builddeb -- -Zgzip -z3
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install