xref: /unit/pkg/deb/debian/rules.in (revision 2103:6e61a013417e)
1373Sdefan@nginx.com#!/usr/bin/make -f
2373Sdefan@nginx.com
3373Sdefan@nginx.com# Uncomment this to turn on verbose mode.
4373Sdefan@nginx.com#export DH_VERBOSE=1
5373Sdefan@nginx.com
6442Sdefan@nginx.comexport DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie
7442Sdefan@nginx.comexport DEB_CFLAGS_MAINT_APPEND=-Wp,-D_FORTIFY_SOURCE=2 -fPIC
8442Sdefan@nginx.comexport DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed -pie
9442Sdefan@nginx.comDPKG_EXPORT_BUILDFLAGS = 1
10442Sdefan@nginx.cominclude /usr/share/dpkg/buildflags.mk
11442Sdefan@nginx.com
12815Sdefan@nginx.comDEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
131765Sdefan@nginx.comCODENAME := $(shell lsb_release -cs)
14815Sdefan@nginx.com
15373Sdefan@nginx.comBUILDDIR_unit = $(CURDIR)/debian/build-unit
16373Sdefan@nginx.comBUILDDIR_unit_debug = $(CURDIR)/debian/build-unit-debug
17373Sdefan@nginx.comINSTALLDIR = $(CURDIR)/debian/unit
18815Sdefan@nginx.comINSTALLDIR_dev = $(CURDIR)/debian/unit-dev
19373Sdefan@nginx.comBASEDIR = $(CURDIR)
20373Sdefan@nginx.com
21373Sdefan@nginx.comDOTESTS = 0
22373Sdefan@nginx.com
23373Sdefan@nginx.comconfig.env.%:
24373Sdefan@nginx.com	dh_testdir
25373Sdefan@nginx.com	mkdir -p $(BUILDDIR_$*)
26373Sdefan@nginx.com	cp -Pa $(CURDIR)/auto $(BUILDDIR_$*)/
27373Sdefan@nginx.com	cp -Pa $(CURDIR)/configure $(BUILDDIR_$*)/
28373Sdefan@nginx.com	cp -Pa $(CURDIR)/src $(BUILDDIR_$*)/
29373Sdefan@nginx.com	cp -Pa $(CURDIR)/test $(BUILDDIR_$*)/
30957Sdefan@nginx.com	cp -Pa $(CURDIR)/version $(BUILDDIR_$*)/
31980Sdefan@nginx.com	cp -Pa $(CURDIR)/CHANGES $(BUILDDIR_$*)/
32980Sdefan@nginx.com	cp -Pa $(CURDIR)/LICENSE $(BUILDDIR_$*)/
33980Sdefan@nginx.com	cp -Pa $(CURDIR)/NOTICE $(BUILDDIR_$*)/
34*2103Sthresh@nginx.com	cp -Pa $(CURDIR)/README.md $(BUILDDIR_$*)/
35*2103Sthresh@nginx.com	cp -Pa $(CURDIR)/CONTRIBUTING.md $(BUILDDIR_$*)/
361316Smax.romanov@nginx.com	cp -Pa $(CURDIR)/go $(BUILDDIR_$*)/
371826Sthresh@nginx.com	mkdir -p $(BUILDDIR_$*)/docs/man
381826Sthresh@nginx.com	cp -Pa $(CURDIR)/docs/man/unitd.8.in $(BUILDDIR_$*)/docs/man/
39373Sdefan@nginx.com	touch $@
40373Sdefan@nginx.com
41373Sdefan@nginx.comconfigure.unit: config.env.unit
42373Sdefan@nginx.com	cd $(BUILDDIR_unit) && \
43442Sdefan@nginx.com	CFLAGS= ./configure \
44373Sdefan@nginx.com		%%CONFIGURE_ARGS%% \
45442Sdefan@nginx.com		--modules=/usr/lib/unit/modules \
46815Sdefan@nginx.com		--libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
47442Sdefan@nginx.com		--cc-opt="$(CFLAGS)" \
48442Sdefan@nginx.com		--ld-opt="$(LDFLAGS)"
49373Sdefan@nginx.com	touch $@
50373Sdefan@nginx.com
51373Sdefan@nginx.comconfigure.unit_debug: config.env.unit_debug
52373Sdefan@nginx.com	cd $(BUILDDIR_unit_debug) && \
53442Sdefan@nginx.com	CFLAGS= ./configure \
54373Sdefan@nginx.com		%%CONFIGURE_ARGS%% \
55373Sdefan@nginx.com		--modules=/usr/lib/unit/debug-modules \
56815Sdefan@nginx.com		--libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
57442Sdefan@nginx.com		--cc-opt="$(CFLAGS)" \
58442Sdefan@nginx.com		--ld-opt="$(LDFLAGS)" \
59373Sdefan@nginx.com		--debug
60373Sdefan@nginx.com	touch $@
61373Sdefan@nginx.com
62373Sdefan@nginx.combuild-arch.%: configure.%
63373Sdefan@nginx.com	dh_testdir
64373Sdefan@nginx.com	$(MAKE) -C $(BUILDDIR_$*)
65815Sdefan@nginx.com	$(MAKE) -C $(BUILDDIR_$*) build/libunit.a
66373Sdefan@nginx.comifeq ($(DOTESTS), 1)
67373Sdefan@nginx.com	$(MAKE) -C $(BUILDDIR_$*) tests
68373Sdefan@nginx.comendif
69373Sdefan@nginx.com	touch $@
70373Sdefan@nginx.com
71373Sdefan@nginx.comdo.tests: build
72373Sdefan@nginx.com	dh_testdir
73373Sdefan@nginx.comifeq ($(DOTESTS), 1)
74373Sdefan@nginx.com	cd $(BUILDDIR_unit) && ./build/tests
75373Sdefan@nginx.com	cd $(BUILDDIR_unit_debug) && ./build/tests
76373Sdefan@nginx.comendif
77373Sdefan@nginx.com	touch $@
78373Sdefan@nginx.com
79373Sdefan@nginx.combuild-indep:
80373Sdefan@nginx.com	dh_testdir
81373Sdefan@nginx.com	touch $@
82373Sdefan@nginx.com
83373Sdefan@nginx.combuild-arch: build-arch.unit build-arch.unit_debug
84373Sdefan@nginx.com	dh_testdir
85373Sdefan@nginx.com	touch $@
86373Sdefan@nginx.com
87373Sdefan@nginx.combuild: build-arch build-indep
88373Sdefan@nginx.com	dh_testdir
89373Sdefan@nginx.com	touch $@
90373Sdefan@nginx.com
91373Sdefan@nginx.comclean:
92373Sdefan@nginx.com	dh_testdir
93373Sdefan@nginx.com	dh_testroot
94373Sdefan@nginx.com	dh_clean
95373Sdefan@nginx.com	find $(CURDIR) -maxdepth 1 -size 0 -delete
96957Sdefan@nginx.com	rm -rf $(BUILDDIR_unit) $(BUILDDIR_unit_debug)
97373Sdefan@nginx.com
98373Sdefan@nginx.cominstall: build do.tests
99373Sdefan@nginx.com	dh_testdir
100373Sdefan@nginx.com	dh_testroot
101373Sdefan@nginx.com	dh_prep
102373Sdefan@nginx.com	dh_installdirs
1032027Sdefan@nginx.com	dh_installsystemd -punit --name=unit unit.service
1042027Sdefan@nginx.com	dh_installsystemd -punit --name=unit-debug --no-start --no-enable unit-debug.service
105373Sdefan@nginx.com	dh_installlogrotate
106373Sdefan@nginx.com	cd $(BUILDDIR_unit) && DESTDIR=$(INSTALLDIR) make install
107815Sdefan@nginx.com	cd $(BUILDDIR_unit) && DESTDIR=$(INSTALLDIR_dev) make libunit-install
108373Sdefan@nginx.com	install -m 755 $(BUILDDIR_unit_debug)/build/unitd $(INSTALLDIR)/usr/sbin/unitd-debug
109815Sdefan@nginx.com	install -m 644 $(BUILDDIR_unit_debug)/build/libunit.a $(INSTALLDIR_dev)/usr/lib/$(DEB_HOST_MULTIARCH)/libunit-debug.a
110373Sdefan@nginx.com	mkdir -p $(INSTALLDIR)/usr/share/doc/unit/examples
111373Sdefan@nginx.com	install -m 644 debian/unit.example.config $(INSTALLDIR)/usr/share/doc/unit/examples/example.config
1121749Sdefan@nginx.com	install -m 644 CHANGES $(INSTALLDIR)/usr/share/doc/unit/changelog
113*2103Sthresh@nginx.com	install -m 644 README.md $(INSTALLDIR)/usr/share/doc/unit/
114*2103Sthresh@nginx.com	install -m 644 CONTRIBUTING.md $(INSTALLDIR)/usr/share/doc/unit/
1151749Sdefan@nginx.com	install -m 644 NOTICE $(INSTALLDIR)/usr/share/doc/unit/
116373Sdefan@nginx.com
117373Sdefan@nginx.combinary-indep: build install
118373Sdefan@nginx.com	dh_testdir
119373Sdefan@nginx.com	dh_testroot
120373Sdefan@nginx.com	dh_installdocs
1211826Sthresh@nginx.com	dh_installchangelogs
122373Sdefan@nginx.com	dh_link
123373Sdefan@nginx.com	dh_strip --dbg-package=unit-dbg
124373Sdefan@nginx.com	dh_shlibdeps
125373Sdefan@nginx.com	dh_compress
126373Sdefan@nginx.com	dh_fixperms
127373Sdefan@nginx.com	dh_installdeb
128373Sdefan@nginx.com	dh_perl
129373Sdefan@nginx.com	dh_gencontrol
130373Sdefan@nginx.com	dh_md5sums
131373Sdefan@nginx.com	dh_builddeb
132373Sdefan@nginx.com
133373Sdefan@nginx.combinary-arch: install
134373Sdefan@nginx.com
135373Sdefan@nginx.combinary: binary-indep binary-arch
136373Sdefan@nginx.com
137373Sdefan@nginx.com.PHONY: clean binary-indep binary-arch binary install build
138