xref: /unit/pkg/deb/debian/rules.in (revision 1751:a27532e3a17b)
1#!/usr/bin/make -f
2
3# Uncomment this to turn on verbose mode.
4#export DH_VERBOSE=1
5
6export DEB_BUILD_MAINT_OPTIONS=hardening=+all,-pie
7export DEB_CFLAGS_MAINT_APPEND=-Wp,-D_FORTIFY_SOURCE=2 -fPIC
8export DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed -pie
9DPKG_EXPORT_BUILDFLAGS = 1
10include /usr/share/dpkg/buildflags.mk
11
12DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
13
14BUILDDIR_unit = $(CURDIR)/debian/build-unit
15BUILDDIR_unit_debug = $(CURDIR)/debian/build-unit-debug
16INSTALLDIR = $(CURDIR)/debian/unit
17INSTALLDIR_dev = $(CURDIR)/debian/unit-dev
18BASEDIR = $(CURDIR)
19
20DOTESTS = 0
21
22config.env.%:
23	dh_testdir
24	mkdir -p $(BUILDDIR_$*)
25	cp -Pa $(CURDIR)/auto $(BUILDDIR_$*)/
26	cp -Pa $(CURDIR)/configure $(BUILDDIR_$*)/
27	cp -Pa $(CURDIR)/src $(BUILDDIR_$*)/
28	cp -Pa $(CURDIR)/test $(BUILDDIR_$*)/
29	cp -Pa $(CURDIR)/version $(BUILDDIR_$*)/
30	cp -Pa $(CURDIR)/CHANGES $(BUILDDIR_$*)/
31	cp -Pa $(CURDIR)/LICENSE $(BUILDDIR_$*)/
32	cp -Pa $(CURDIR)/NOTICE $(BUILDDIR_$*)/
33	cp -Pa $(CURDIR)/README $(BUILDDIR_$*)/
34	cp -Pa $(CURDIR)/go $(BUILDDIR_$*)/
35	touch $@
36
37configure.unit: config.env.unit
38	cd $(BUILDDIR_unit) && \
39	CFLAGS= ./configure \
40		%%CONFIGURE_ARGS%% \
41		--modules=/usr/lib/unit/modules \
42		--libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
43		--cc-opt="$(CFLAGS)" \
44		--ld-opt="$(LDFLAGS)"
45	touch $@
46
47configure.unit_debug: config.env.unit_debug
48	cd $(BUILDDIR_unit_debug) && \
49	CFLAGS= ./configure \
50		%%CONFIGURE_ARGS%% \
51		--modules=/usr/lib/unit/debug-modules \
52		--libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
53		--cc-opt="$(CFLAGS)" \
54		--ld-opt="$(LDFLAGS)" \
55		--debug
56	touch $@
57
58build-arch.%: configure.%
59	dh_testdir
60	$(MAKE) -C $(BUILDDIR_$*)
61	$(MAKE) -C $(BUILDDIR_$*) build/libunit.a
62ifeq ($(DOTESTS), 1)
63	$(MAKE) -C $(BUILDDIR_$*) tests
64endif
65	touch $@
66
67do.tests: build
68	dh_testdir
69ifeq ($(DOTESTS), 1)
70	cd $(BUILDDIR_unit) && ./build/tests
71	cd $(BUILDDIR_unit_debug) && ./build/tests
72endif
73	touch $@
74
75build-indep:
76	dh_testdir
77	touch $@
78
79build-arch: build-arch.unit build-arch.unit_debug
80	dh_testdir
81	touch $@
82
83build: build-arch build-indep
84	dh_testdir
85	touch $@
86
87clean:
88	dh_testdir
89	dh_testroot
90	dh_clean
91	find $(CURDIR) -maxdepth 1 -size 0 -delete
92	rm -rf $(BUILDDIR_unit) $(BUILDDIR_unit_debug)
93
94install: build do.tests
95	dh_testdir
96	dh_testroot
97	dh_prep
98	dh_installdirs
99	dh_installsystemd
100	dh_installlogrotate
101	cd $(BUILDDIR_unit) && DESTDIR=$(INSTALLDIR) make install
102	cd $(BUILDDIR_unit) && DESTDIR=$(INSTALLDIR_dev) make libunit-install
103	install -m 755 $(BUILDDIR_unit_debug)/build/unitd $(INSTALLDIR)/usr/sbin/unitd-debug
104	install -m 644 $(BUILDDIR_unit_debug)/build/libunit.a $(INSTALLDIR_dev)/usr/lib/$(DEB_HOST_MULTIARCH)/libunit-debug.a
105	mkdir -p $(INSTALLDIR)/usr/share/doc/unit/examples
106	install -m 644 debian/unit.example.config $(INSTALLDIR)/usr/share/doc/unit/examples/example.config
107	install -m 644 CHANGES $(INSTALLDIR)/usr/share/doc/unit/changelog
108	install -m 644 README $(INSTALLDIR)/usr/share/doc/unit/
109	install -m 644 NOTICE $(INSTALLDIR)/usr/share/doc/unit/
110
111binary-indep: build install
112	dh_testdir
113	dh_testroot
114	dh_installdocs
115	dh_installchangelogs
116	dh_link
117	dh_strip --dbg-package=unit-dbg
118	dh_shlibdeps
119	dh_compress
120	dh_fixperms
121	dh_installdeb
122	dh_perl
123	dh_gencontrol
124	dh_md5sums
125	dh_builddeb
126
127binary-arch: install
128
129binary: binary-indep binary-arch
130
131.PHONY: clean binary-indep binary-arch binary install build
132