Tizen 2.1 base
[platform/upstream/sysvinit.git] / debian / rules
1 #! /usr/bin/make -f
2 #
3 #       debian/rules file for sysvinit
4 #
5
6 # Uncomment this to turn on verbose mode.
7 # export DH_VERBOSE=1
8
9 # This has to be exported to make some magic below work.
10 export DH_OPTIONS
11
12 TARGET  = SLP
13
14 tmp     = $(shell pwd)/debian/tmp
15 sysvtmp = $(shell pwd)/debian/sysvinit
16 utiltmp = $(shell pwd)/debian/sysvinit-utils
17 rctmp   = $(shell pwd)/debian/sysv-rc
18 inittmp = $(shell pwd)/debian/initscripts
19 doc     = /usr/share/doc
20
21 LC_ALL  = POSIX
22
23 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
24 DEB_HOST_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
25 DEB_HOST_ARCH       ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
26 DEB_HOST_ARCH_OS    ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
27
28 INSTALL_DATA = install -o root -g root -m 644
29 INSTALL      = install -o root -g root -m 755
30
31 # Handle cross builds
32 ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
33 CROSS=CC=$(DEB_HOST_GNU_TYPE)-gcc
34 # CROSS is passed to make, CC is called directly.
35 CC=$(DEB_HOST_GNU_TYPE)-gcc
36 endif
37
38 ifneq ($(TARGET),SLP)
39 # Set arch specific build flags
40 ifeq ($(DEB_HOST_ARCH_OS),linux)
41 CONFFLAGS = WITH_SELINUX="yes"
42 endif
43 endif
44
45 PATCH_STAMP=debian/stamp-patched
46 patch: $(PATCH_STAMP)
47 $(PATCH_STAMP):
48         dh_testdir debian/patches/series \
49                 debian/startpar/patches/series
50         QUILT_PATCHES=debian/patches quilt --quiltrc /dev/null push -a || test $$? = 2
51         cd debian/startpar && \
52                 QUILT_PATCHES=patches quilt --quiltrc /dev/null push -a || test $$? = 2
53         touch $(PATCH_STAMP)
54
55 unpatch:
56         QUILT_PATCHES=debian/patches quilt --quiltrc /dev/null pop -a -R || test $$? = 2
57         cd debian/startpar && \
58                 QUILT_PATCHES=patches quilt --quiltrc /dev/null pop -a -R || test $$? = 2
59         rm -rf .pc debian/startpar/.pc $(PATCH_STAMP)
60
61 build: build-stamp
62 build-stamp: patch
63 # Builds the binary package.
64         dh_testdir
65         $(MAKE) $(CROSS) $(CONFFLAGS) -C src DISTRO=Debian
66         $(MAKE) $(CROSS) -C debian/startpar
67         touch $@
68
69 # Make a binary package (.deb file)
70 binary-arch: DH_OPTIONS=-a
71 binary-arch: build
72         dh_testroot
73         dh_prep
74         dh_installdirs
75         $(MAKE) -C src $(CROSS) ROOT=$(tmp) DISTRO=Debian install
76         dh_install
77         dh_link
78         # Used by sysvinit and sysvinit-utils
79         cat debian/copyright.in COPYRIGHT > debian/copyright
80         #
81         # sysvinit package
82         #
83         if test -e debian/share/inittab.$(DEB_HOST_GNU_TYPE) ; \
84         then \
85                 $(INSTALL_DATA) \
86                         debian/share/inittab.$(DEB_HOST_GNU_TYPE) \
87                         $(sysvtmp)/usr/share/sysvinit/inittab ; \
88         elif test -e debian/share/inittab.$(DEB_HOST_GNU_SYSTEM) ; \
89         then \
90                 $(INSTALL_DATA) \
91                         debian/share/inittab.$(DEB_HOST_GNU_SYSTEM) \
92                         $(sysvtmp)/usr/share/sysvinit/inittab ; \
93         else \
94                 $(INSTALL_DATA) debian/share/inittab \
95                         $(sysvtmp)/usr/share/sysvinit/inittab ; \
96         fi
97         $(INSTALL) debian/share/update-rc.d $(sysvtmp)/usr/share/sysvinit/
98 ifeq ($(DEB_HOST_ARCH), hurd-i386)
99         # The Hurd has its own halt and reboot commands.
100         rm -f $(sysvtmp)/usr/share/man/man8/halt.8
101         rm -f $(sysvtmp)/usr/share/man/man8/reboot.8
102         rm -f $(sysvtmp)/sbin/halt
103         rm -f $(sysvtmp)/sbin/reboot
104 endif
105         dh_installchangelogs -psysvinit doc/Changelog
106         dh_installdeb -psysvinit
107         #
108         # sysvinit-utils package
109         #
110         $(MAKE) $(CROSS) -C debian/startpar DESTDIR=$(utiltmp) install
111         dh_installchangelogs -psysvinit-utils doc/Changelog
112         sed -i -ne '/sysvinit (2.86.ds1-47)/q' -e p \
113                 $(inittmp)$(doc)/initscripts/changelog.Debian
114         #
115         # initscripts package
116         #
117         $(MAKE) -C debian/src/initscripts install DESTDIR=$(inittmp)
118 ifneq (,$(findstring $(DEB_HOST_ARCH_OS),linux kfreebsd))
119         $(INSTALL) -d $(inittmp)/sys
120 endif
121         dh_installchangelogs -pinitscripts
122         sed -i -ne '/sysvinit (2.86.ds1-47)/q' -e p \
123                 $(inittmp)$(doc)/initscripts/changelog.Debian
124         dh_installdeb -pinitscripts
125         # Override autogenerated conffiles
126         $(INSTALL_DATA) debian/initscripts.conffiles \
127                 $(inittmp)/DEBIAN/conffiles
128         sh debian/deps-mount >> debian/initscripts.substvars
129
130         # Wrap it all up
131         dh_fixperms -X/etc/init.d/skeleton
132         dh_installman
133         dh_installdocs
134         dh_lintian
135         dh_shlibdeps
136         dh_strip
137         dh_compress
138         dh_gencontrol
139         dh_md5sums
140         dh_builddeb
141
142 # Architecture independant files.
143 binary-indep: DH_OPTIONS=-i
144 binary-indep:
145         #
146         # sysv-rc package
147         #
148         dh_testroot
149         dh_prep
150         $(MAKE) -C debian/src/sysv-rc install DESTDIR=$(rctmp)
151         dh_installchangelogs
152         sed -i -ne '/sysvinit (2.86.ds1-47)/q' -e p \
153                 $(rctmp)$(doc)/sysv-rc/changelog.Debian
154         dh_installdeb
155         # Neither rc, rcS nor README are conffiles
156         $(RM) $(rctmp)/DEBIAN/conffiles
157
158         # Wrap it all up
159         dh_fixperms -X/etc/init.d/README
160         dh_installdebconf
161         dh_installdocs
162         dh_installman
163         dh_lintian
164         dh_compress
165         dh_gencontrol
166         dh_md5sums
167         dh_builddeb
168
169 clean:
170         dh_testdir
171         $(MAKE) -C src clobber
172         $(MAKE) -C debian/startpar clean
173         $(MAKE) -f debian/rules unpatch
174         dh_clean build-stamp debian/copyright
175
176 binary: binary-arch binary-indep
177
178 .PHONY: binary binary-arch binary-indep clean