7ab2c96d6095bc6d2fb9520181d9e6dc6afceff0
[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 $(STAMPS_DIR)/setup_busybox-althist
44 setup: $(STAMPS_DIR)/setup_busybox
45
46 $(STAMPS_DIR)/setup_%: SOURCE_DIR=$(BUILD_DIR)/source
47 $(STAMPS_DIR)/setup_%: DIR=$(BUILD_DIR)/build_$*
48 $(STAMPS_DIR)/setup_%: $(STAMPS_DIR)/source
49         dh_testdir
50         rm -rf '$(DIR)'
51         cp -al '$(SOURCE_DIR)' '$(DIR)'
52         cp debian/config/config.busybox '$(DIR)'/.config
53         if test "$*" == "busybox-althist"; then \
54                 sed -i "s/CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=y/# CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is not set/" '$(DIR)'/.config; fi
55         make -C '$(DIR)' oldconfig
56         touch $@
57
58 #build: $(STAMPS_DIR)/build_busybox $(STAMPS_DIR)/build_busybox-althist
59 build: $(STAMPS_DIR)/build_busybox
60
61 $(STAMPS_DIR)/build_%: DIR=$(BUILD_DIR)/build_$*
62 $(STAMPS_DIR)/build_%: $(STAMPS_DIR)/setup_%
63         dh_testdir
64         make -C '$(DIR)' $(NJOBS) THUMB=$(THUMB) busybox docs/busybox.1 BB_EXTRA_VERSION="$(shell lsb_release -is) $(VERSION_DEBIAN)"
65         make -C '$(DIR)' busybox.links
66         touch $@
67
68 $(BUILD_DIR) $(STAMPS_DIR):
69         @[ -d $@ ] || mkdir $@
70
71 maintainerclean:
72         rm -rf $(filter-out .svn debian, $(wildcard * .[^.]*))
73
74 clean:
75         dh_testdir
76         rm -rf $(BUILD_DIR) $(STAMPS_DIR)
77         dh_clean
78         rm -rf debian/busybox-power-althistory*
79         rm -rf debian/busybox-power-noaegis*
80
81 binary-indep:
82
83 #binary-arch: binary-arch_busybox binary-arch_busybox-noaegis binary-arch_busybox-althist binary-arch_all
84 binary-arch: binary-arch_busybox binary-arch_busybox-noaegis binary-arch_all
85
86 binary-arch_busybox: DIR = $(BUILD_DIR)/build_busybox
87 binary-arch_busybox: DH_OPTIONS = -pbusybox-power
88 binary-arch_busybox: $(STAMPS_DIR)/build_busybox
89         dh_testdir
90         dh_testroot
91         install -D -m644 debian/scripts/applets debian/busybox-power/opt/busybox-power/applets
92         install -D -m644 debian/scripts/functions debian/busybox-power/opt/busybox-power/functions
93         install -D -m755 $(DIR)/busybox_unstripped debian/busybox-power/opt/busybox-power/busybox.power
94
95
96 binary-arch_busybox-noaegis: DIR = $(BUILD_DIR)/build_busybox
97 binary-arch_busybox-noaegis: DH_OPTIONS = -pbusybox-power-noaegis
98 binary-arch_busybox-noaegis: $(STAMPS_DIR)/build_busybox
99         dh_testdir
100         dh_testroot
101         # busybox-power-noaegis == busybox-power, only debian/control differs
102         # Therefore, duplicate busybox-power into busybox-power-noaegis
103         for f in debian/busybox-power*; do cp -a "$$f" "$${f/busybox-power/busybox-power-noaegis}"; done
104         sed -i s/busybox-power/busybox-power-noaegis/ debian/busybox-power-noaegis.aegis
105
106 binary-arch_busybox-althist: DIR = $(BUILD_DIR)/build_busybox-althist
107 binary-arch_busybox-althist: DH_OPTIONS = -pbusybox-power-althist
108 binary-arch_busybox-althist: $(STAMPS_DIR)/build_busybox-althist
109         dh_testdir
110         dh_testroot
111         # busybox-power-althist == busybox-power, only BusyBox' .config differs
112         # Duplicate the maintainer scripts etc. into busybox-power-althist
113         for f in debian/busybox-power.*; do cp -p "$$f" "$${f/busybox-power/busybox-power-althist}"; done
114         install -D -m644 debian/scripts/applets debian/busybox-power-althist/opt/busybox-power/applets
115         install -D -m644 debian/scripts/functions debian/busybox-power-althist/opt/busybox-power/functions
116         install -D -m755 $(DIR)/busybox_unstripped debian/busybox-power-althist/opt/busybox-power/busybox.power
117
118 binary-arch_all:
119         dh_installdirs
120         dh_installdocs
121         dh_installchangelogs
122         dh_strip
123         dh_compress
124
125         dh_link
126         dh_fixperms
127         dh_installdeb
128
129         dh_shlibdeps
130         dh_gencontrol
131         dh_md5sums
132         dh_builddeb
133
134 binary: binary-indep binary-arch
135
136 DIR_ORIG = ../orig/$(SOURCE)-$(VERSION)
137 TAR_ORIG_NAME = $(SOURCE)_$(VERSION).orig.tar.gz
138 TAR_ORIG = $(firstword $(wildcard ../$(TAR_ORIG_NAME)) $(wildcard ../orig/$(TAR_ORIG_NAME)))
139
140 orig: $(DIR_ORIG)
141         rsync --delete --exclude debian --exclude .svk --exclude .svn --link-dest=$(DIR_ORIG)/ -a $(DIR_ORIG)/ .
142
143 $(DIR_ORIG):
144 ifeq ($(TAR_ORIG),)
145         $(error Cannot find orig tarball $(TAR_ORIG_NAME))
146 else
147         mkdir -p ../orig
148         tar -C ../orig -xzf $(TAR_ORIG)
149 endif
150