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