prepare busybox-power 1.19.3power3 release
[busybox-power] / 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 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
14         CONFIG_DEBUG = y
15 endif
16 ifneq (,$(findstring thumb,$(DEB_BUILD_OPTIONS)))
17 THUMB := -mthumb
18 endif
19
20 source: $(STAMPS_DIR)/source
21
22 $(STAMPS_DIR)/source: SOURCE_FILES = $(filter-out debian, $(wildcard * .[^.]*))
23 $(STAMPS_DIR)/source: DIR = $(BUILD_DIR)/source
24 $(STAMPS_DIR)/source:
25         dh_testdir
26         rm -rf '$(DIR)'
27         mkdir -p $(STAMPS_DIR) '$(DIR)'
28         cp -al $(SOURCE_FILES) '$(DIR)'
29         cd $(DIR); QUILT_PATCHES=$(CURDIR)/debian/patches quilt --quiltrc /dev/null push -a || test $$? = 2
30         touch $@
31
32 setup: $(STAMPS_DIR)/setup_busybox
33
34 $(STAMPS_DIR)/setup_%: SOURCE_DIR=$(BUILD_DIR)/source
35 $(STAMPS_DIR)/setup_%: DIR=$(BUILD_DIR)/build_$*
36 $(STAMPS_DIR)/setup_%: $(STAMPS_DIR)/source
37         dh_testdir
38         rm -rf '$(DIR)'
39         cp -al '$(SOURCE_DIR)' '$(DIR)'
40         cp debian/config/config.$* '$(DIR)'/.config
41         make -C '$(DIR)' oldconfig
42         touch $@
43
44 build: $(STAMPS_DIR)/build_busybox
45
46 $(STAMPS_DIR)/build_%: DIR=$(BUILD_DIR)/build_$*
47 $(STAMPS_DIR)/build_%: $(STAMPS_DIR)/setup_%
48         dh_testdir
49         make -C '$(DIR)' THUMB=$(THUMB) busybox docs/busybox.1 BB_EXTRA_VERSION="$(shell lsb_release -is) $(VERSION_DEBIAN)"
50         make -C '$(DIR)' busybox.links
51         touch $@
52
53 $(BUILD_DIR) $(STAMPS_DIR):
54         @[ -d $@ ] || mkdir $@
55
56 maintainerclean:
57         rm -rf $(filter-out .svn debian, $(wildcard * .[^.]*))
58
59 clean:
60         dh_testdir
61         rm -rf $(BUILD_DIR) $(STAMPS_DIR)
62         dh_clean
63
64 binary-indep:
65
66 binary-arch: binary-arch_busybox binary-arch_all
67
68 binary-arch_busybox: DIR = $(BUILD_DIR)/build_busybox
69 binary-arch_busybox: DH_OPTIONS = -pbusybox-power
70 binary-arch_busybox: $(STAMPS_DIR)/build_busybox
71         dh_testdir
72         dh_testroot
73         dh_clean -k -d
74         install -D -m644 debian/scripts/functions debian/busybox-power/opt/busybox-power/functions
75         install -D -m755 debian/scripts/install-binary.sh debian/busybox-power/opt/busybox-power/install-binary.sh
76         install -D -m755 debian/scripts/uninstall-binary.sh debian/busybox-power/opt/busybox-power/uninstall-binary.sh
77         install -D -m755 $(DIR)/busybox_unstripped debian/busybox-power/opt/busybox-power/busybox.power
78
79 binary-arch_all:
80         dh_installdirs
81         dh_installdocs -pbusybox-power
82         dh_installchangelogs -pbusybox-power
83         dh_strip -pbusybox-power
84         dh_compress -pbusybox-power
85
86         dh_link
87         dh_fixperms
88         dh_installdeb
89
90         dh_shlibdeps -pbusybox-power
91         dh_gencontrol
92         dh_md5sums
93         dh_builddeb
94
95 binary: binary-indep binary-arch
96
97 DIR_ORIG = ../orig/$(SOURCE)-$(VERSION)
98 TAR_ORIG_NAME = $(SOURCE)_$(VERSION).orig.tar.gz
99 TAR_ORIG = $(firstword $(wildcard ../$(TAR_ORIG_NAME)) $(wildcard ../orig/$(TAR_ORIG_NAME)))
100
101 orig: $(DIR_ORIG)
102         rsync --delete --exclude debian --exclude .svk --exclude .svn --link-dest=$(DIR_ORIG)/ -a $(DIR_ORIG)/ .
103
104 $(DIR_ORIG):
105 ifeq ($(TAR_ORIG),)
106         $(error Cannot find orig tarball $(TAR_ORIG_NAME))
107 else
108         mkdir -p ../orig
109         tar -C ../orig -xzf $(TAR_ORIG)
110 endif
111