Added debian/ from 1:1.10.2-1 debian package
[busybox4maemo] / debian / rules
1 #!/usr/bin/make -f
2
3 SHELL := sh -e
4 DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
5 DEB_BUILD_ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
6 SOURCE := $(shell dpkg-parsechangelog | sed -ne 's,^Source: *\(.*\)$$,\1,p')
7 VERSION_DEBIAN := $(shell dpkg-parsechangelog | sed -ne 's,^Version: *\(.*\)$$,\1,p')
8 VERSION := $(shell echo "$(VERSION_DEBIAN)" | sed -e 's,^[^:]*:,,' -e 's,-[^-]*$$,,')
9  
10 BUILD_DIR = debian/build
11 STAMPS_DIR = debian/stamps
12
13 source: $(STAMPS_DIR)/source
14
15 $(STAMPS_DIR)/source: SOURCE_FILES = $(filter-out debian, $(wildcard * .[^.]*))
16 $(STAMPS_DIR)/source: DIR = $(BUILD_DIR)/source
17 $(STAMPS_DIR)/source:
18         dh_testdir
19         rm -rf '$(DIR)'
20         mkdir -p $(STAMPS_DIR) '$(DIR)'
21         cp -al $(SOURCE_FILES) '$(DIR)'
22         cd $(DIR); QUILT_PATCHES=$(CURDIR)/debian/patches quilt --quiltrc /dev/null push -a || test $$? = 2
23         touch $@
24
25 setup: $(STAMPS_DIR)/setup_deb $(STAMPS_DIR)/setup_udeb
26
27 $(STAMPS_DIR)/setup_%: SOURCE_DIR=$(BUILD_DIR)/source
28 $(STAMPS_DIR)/setup_%: DIR=$(BUILD_DIR)/build_$*
29 $(STAMPS_DIR)/setup_%: $(STAMPS_DIR)/source
30         dh_testdir
31         rm -rf '$(DIR)'
32         cp -al '$(SOURCE_DIR)' '$(DIR)'
33         cp debian/config/config.$* '$(DIR)'/.config
34         make -C '$(DIR)' oldconfig
35         touch $@
36
37 build: $(STAMPS_DIR)/build_deb $(STAMPS_DIR)/build_static $(STAMPS_DIR)/build_udeb
38
39 $(STAMPS_DIR)/build_%: DIR=$(BUILD_DIR)/build_$*
40 $(STAMPS_DIR)/build_%: $(STAMPS_DIR)/setup_%
41         dh_testdir
42         make -C '$(DIR)' busybox docs/busybox.1 BB_EXTRA_VERSION="$(shell lsb_release -is) $(VERSION_DEBIAN)"
43         touch $@
44
45 $(BUILD_DIR) $(STAMPS_DIR):
46         @[ -d $@ ] || mkdir $@
47
48 maintainerclean:
49         rm -rf $(filter-out .svn debian, $(wildcard * .[^.]*))
50
51 clean:
52         dh_testdir
53         rm -rf $(BUILD_DIR) $(STAMPS_DIR)
54         dh_clean
55
56 binary-indep:
57
58 binary-arch: binary-arch_deb binary-arch_static binary-arch_udeb
59
60 binary-arch_deb: DIR = $(BUILD_DIR)/build_deb
61 binary-arch_deb: export DH_OPTIONS = -pbusybox
62 binary-arch_deb: $(STAMPS_DIR)/build_deb
63         dh_testdir
64         dh_testroot
65         dh_clean -k -d
66         dh_install --sourcedir=$(DIR)
67         $(MAKE) -f debian/rules binary-arch_all
68
69 binary-arch_static: PACKAGE = busybox-static
70 binary-arch_static: DIR = $(BUILD_DIR)/build_static
71 binary-arch_static: export DH_OPTIONS = -p$(PACKAGE)
72 binary-arch_static: $(STAMPS_DIR)/build_static
73         dh_testdir
74         dh_testroot
75         dh_clean -k -d
76         dh_install --sourcedir=$(DIR)
77         install -D -m644 debian/$(PACKAGE).override \
78                 debian/$(PACKAGE)/usr/share/lintian/overrides/$(PACKAGE)
79         $(MAKE) -f debian/rules binary-arch_all
80
81 binary-arch_udeb: PACKAGE = busybox-udeb
82 binary-arch_udeb: DIR = $(BUILD_DIR)/build_udeb
83 binary-arch_udeb: OUT_DIR = $(CURDIR)/debian/$(PACKAGE)
84 binary-arch_udeb: export DH_OPTIONS = -p$(PACKAGE)
85 binary-arch_udeb: $(STAMPS_DIR)/build_udeb
86         dh_testdir
87         dh_testroot
88         dh_clean -k -d
89         make -C $(DIR) install CONFIG_PREFIX=$(OUT_DIR)
90         # Remove init link, but init support is still compiled in to be
91         # used.
92         rm -f $(OUT_DIR)/sbin/init
93         $(MAKE) -f debian/rules binary-arch_all
94
95 binary-arch_all:
96         dh_installdirs
97         dh_installdocs
98         dh_installchangelogs
99         dh_strip
100         dh_link
101         dh_compress
102         dh_fixperms
103         dh_installdeb
104         dh_shlibdeps
105         dh_gencontrol
106         dh_md5sums
107         dh_builddeb
108
109 binary: binary-indep binary-arch
110
111 DIR_ORIG = ../orig/$(SOURCE)-$(VERSION)
112 TAR_ORIG_NAME = $(SOURCE)_$(VERSION).orig.tar.gz
113 TAR_ORIG = $(firstword $(wildcard ../$(TAR_ORIG_NAME)) $(wildcard ../orig/$(TAR_ORIG_NAME)))
114
115 orig: $(DIR_ORIG)
116         rsync --delete --exclude debian --exclude .svk --exclude .svn --link-dest=$(DIR_ORIG)/ -a $(DIR_ORIG)/ .
117
118 $(DIR_ORIG):
119 ifeq ($(TAR_ORIG),)
120         $(error Cannot find orig tarball $(TAR_ORIG_NAME))
121 else
122         mkdir -p ../orig
123         tar -C ../orig -xzf $(TAR_ORIG)
124 endif
125