xref: /unit/pkg/deb/debian/rules.in (revision 980:e1c4434c1060)
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	touch $@
35
36configure.unit: config.env.unit
37	cd $(BUILDDIR_unit) && \
38	CFLAGS= ./configure \
39		%%CONFIGURE_ARGS%% \
40		--modules=/usr/lib/unit/modules \
41		--libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
42		--cc-opt="$(CFLAGS)" \
43		--ld-opt="$(LDFLAGS)"
44	touch $@
45
46configure.unit_debug: config.env.unit_debug
47	cd $(BUILDDIR_unit_debug) && \
48	CFLAGS= ./configure \
49		%%CONFIGURE_ARGS%% \
50		--modules=/usr/lib/unit/debug-modules \
51		--libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
52		--cc-opt="$(CFLAGS)" \
53		--ld-opt="$(LDFLAGS)" \
54		--debug
55	touch $@
56
57build-arch.%: configure.%
58	dh_testdir
59	$(MAKE) -C $(BUILDDIR_$*)
60	$(MAKE) -C $(BUILDDIR_$*) build/libunit.a
61ifeq ($(DOTESTS), 1)
62	$(MAKE) -C $(BUILDDIR_$*) tests
63endif
64	touch $@
65
66do.tests: build
67	dh_testdir
68ifeq ($(DOTESTS), 1)
69	cd $(BUILDDIR_unit) && ./build/tests
70	cd $(BUILDDIR_unit_debug) && ./build/tests
71endif
72	touch $@
73
74build-indep:
75	dh_testdir
76	touch $@
77
78build-arch: build-arch.unit build-arch.unit_debug
79	dh_testdir
80	touch $@
81
82build: build-arch build-indep
83	dh_testdir
84	touch $@
85
86clean:
87	dh_testdir
88	dh_testroot
89	dh_clean
90	find $(CURDIR) -maxdepth 1 -size 0 -delete
91	rm -rf $(BUILDDIR_unit) $(BUILDDIR_unit_debug)
92
93install: build do.tests
94	dh_testdir
95	dh_testroot
96	dh_prep
97	dh_installdirs
98	dh_installinit
99	dh_installlogrotate
100	cd $(BUILDDIR_unit) && DESTDIR=$(INSTALLDIR) make install
101	cd $(BUILDDIR_unit) && DESTDIR=$(INSTALLDIR_dev) make libunit-install
102	install -m 755 $(BUILDDIR_unit_debug)/build/unitd $(INSTALLDIR)/usr/sbin/unitd-debug
103	install -m 644 $(BUILDDIR_unit_debug)/build/libunit.a $(INSTALLDIR_dev)/usr/lib/$(DEB_HOST_MULTIARCH)/libunit-debug.a
104	mkdir -p $(INSTALLDIR)/usr/share/doc/unit/examples
105	install -m 644 debian/unit.example.config $(INSTALLDIR)/usr/share/doc/unit/examples/example.config
106	install -m 644 CHANGES $(INSTALLDIR)/usr/share/doc/unit/
107	install -m 644 README $(INSTALLDIR)/usr/share/doc/unit/
108
109binary-indep: build install
110	dh_testdir
111	dh_testroot
112	dh_installdocs
113	dh_installchangelogs
114	dh_link
115	dh_strip --dbg-package=unit-dbg
116	dh_shlibdeps
117	dh_compress
118	dh_fixperms
119	dh_installdeb
120	dh_perl
121	dh_gencontrol
122	dh_md5sums
123	dh_builddeb
124
125binary-arch: install
126
127binary: binary-indep binary-arch
128
129.PHONY: clean binary-indep binary-arch binary install build
130