summaryrefslogtreecommitdiffstats
path: root/busybox.mk
blob: 25a22c7db6d5fdc6a45b7c18c00b3845f19d73fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
TARGETS += busybox
TARGETS_CLEAN += busybox_clean
TARGETS_MRPROPER += busybox_mrproper
TARGETS_DISTCLEAN += busybox_distclean

BUSYBOX_VERSION=0.60.2

# Don't alter below this line unless you (think) you know
# what you are doing! Danger, Danger!

BUSYBOX_URI=http://www.busybox.net/downloads/
BUSYBOX_SOURCE=busybox-$(BUSYBOX_VERSION).tar.gz
BUSYBOX_DIR=$(BASE_DIR)/${shell basename $(BUSYBOX_SOURCE) .tar.gz}
BUSYBOX_WORKDIR=$(BASE_DIR)/busybox_workdir

IMAGE_SIZE += +500

$(SOURCE_DIR)/$(BUSYBOX_SOURCE):
	while [ ! -f $(SOURCE_DIR)/$(BUSYBOX_SOURCE) ] ; do \
	    wget -P $(SOURCE_DIR) --passive $(BUSYBOX_URI)/$(BUSYBOX_SOURCE) ; \
	done

$(BUSYBOX_DIR)/.unpacked:	$(SOURCE_DIR)/$(BUSYBOX_SOURCE)
	rm -rf $(BUSYBOX_DIR) # Make sure no older version interferes
	tar -xzf $(SOURCE_DIR)/$(BUSYBOX_SOURCE)
	touch $(BUSYBOX_DIR)/.unpacked
	
$(BUSYBOX_WORKDIR)/.config:	$(BUSYBOX_DIR)/.unpacked
	rm -rf $(BUSYBOX_WORKDIR) # Make sure no half-configured busybox interferes
	mkdir -p $(BUSYBOX_WORKDIR)
	(cd $(BUSYBOX_WORKDIR) && sh $(BUSYBOX_DIR)/pristine_setup.sh)
	@perl -i -p \
		-e 's|//(#define\s+BB_)(?!FEATURE)|$$1|;' \
		-e 's|//(#define\s+BB_FEATURE_VERBOSE_USAGE)|$$1|;' \
		-e 's|//(#define\s+BB_FEATURE_NEW_MODULE_INTERFACE)|$$1|;' \
		-e 's|//(#define\s+BB_FEATURE_COMMAND_USERNAME_COMPLETION)|$$1|;' \
		-e 's|//(#define\s+BB_FEATURE_SH_FANCY_PROMPT)|$$1|;' \
		-e 's|//(#define\s+BB_FEATURE_INSMOD_VERSION_CHECKING)|$$1|;' \
		-e 's|//(#define\s+BB_FEATURE_IFCONFIG)|$$1|;' \
		-e 's|//(#define\s+BB_FEATURE_DEVFS)|$$1|;' \
		$(BUSYBOX_WORKDIR)/Config.h
	touch $(BUSYBOX_WORKDIR)/.config

$(BUSYBOX_WORKDIR)/.built:	$(TARGET_CC) $(BUSYBOX_WORKDIR)/.config
	make CROSS="$(TARGET_CROSS)" -C $(BUSYBOX_WORKDIR)
	touch $(BUSYBOX_WORKDIR)/.built

$(TARGET_DIR)/bin/busybox:	$(BUSYBOX_WORKDIR)/.built
	make PREFIX=$(TARGET_DIR) -C $(BUSYBOX_WORKDIR) install

busybox: $(TARGET_DIR)/bin/busybox

busybox_clean:
	@if [ -d $(BUSYBOX_WORKDIR)/Makefile ] ; then \
		make -C $(BUSYBOX_WORKDIR) clean ; \
	fi;

busybox_mrproper:
	rm -rf $(BUSYBOX_DIR) $(BUSYBOX_WORKDIR)

busybox_distclean:	busybox_mrproper
	rm -f $(SOURCE_DIR)/$(BUSYBOX_SOURCE)