Fix the various '-clean' targets so that they don't fail if the source has not
[buildrom.git] / buildrom-devel / packages / busybox / busybox.mk
blobd81dee0c1c18569f6dea6e2fb55fc0914642b187
1 BUSYBOX_URL=http://busybox.net/downloads
2 BUSYBOX_SOURCE=busybox-1.1.3.tar.bz2
3 BUSYBOX_DIR=$(BUILD_DIR)/busybox
4 BUSYBOX_SRC_DIR=$(BUSYBOX_DIR)/busybox-1.1.3
5 BUSYBOX_STAMP_DIR=$(BUSYBOX_DIR)/stamps
6 BUSYBOX_LOG_DIR=$(BUSYBOX_DIR)/logs
7 BUSYBOX_PATCHES=$(PACKAGE_DIR)/busybox/testfix.patch $(PACKAGE_DIR)/busybox/regex.patch
8 BUSYBOX_PATCHES += $(PACKAGE_DIR)/busybox/ipaddress.patch
10 ifeq ($(CONFIG_VERBOSE),y)
11 BUSYBOX_BUILD_LOG=/dev/stdout
12 BUSYBOX_INSTALL_LOG=/dev/stdout
13 else
14 BUSYBOX_BUILD_LOG=$(BUSYBOX_LOG_DIR)/build.log
15 BUSYBOX_INSTALL_LOG=$(BUSYBOX_LOG_DIR)/install.log
16 endif
18 BUSYBOX_CONFIG ?= defconfig
20 ifeq ($(findstring defconfig,$(BUSYBOX_CONFIG)),defconfig)
21 ifeq ($(shell if [ -f $(PACKAGE_DIR)/busybox/conf/customconfig--$(PAYLOAD)--$(COREBOOT_VENDOR)-$(COREBOOT_BOARD) ]; then echo 1; fi),1)
22 BUSYBOX_CONFIG = customconfig--$(PAYLOAD)--$(COREBOOT_VENDOR)-$(COREBOOT_BOARD)
23 endif
24 endif
26 $(SOURCE_DIR)/$(BUSYBOX_SOURCE):
27 @ echo "Downloading busybox..."
28 @ mkdir -p $(SOURCE_DIR)
29 @ wget -P $(SOURCE_DIR) $(BUSYBOX_URL)/$(BUSYBOX_SOURCE)
31 $(BUSYBOX_STAMP_DIR)/.unpacked: $(SOURCE_DIR)/$(BUSYBOX_SOURCE) | $(BUSYBOX_STAMP_DIR) $(BUSYBOX_DIR)
32 @ echo "Unpacking busybox..."
33 @ tar -C $(BUSYBOX_DIR) -jxf $(SOURCE_DIR)/$(BUSYBOX_SOURCE)
34 @ touch $@
36 $(BUSYBOX_STAMP_DIR)/.patched: $(BUSYBOX_STAMP_DIR)/.unpacked
37 @ echo "Patching busybox..."
38 @ $(BIN_DIR)/doquilt.sh $(BUSYBOX_SRC_DIR) $(BUSYBOX_PATCHES)
39 @ touch $@
41 $(BUSYBOX_SRC_DIR)/.config: $(BUSYBOX_STAMP_DIR)/.patched
42 @ cp -f $(PACKAGE_DIR)/busybox/conf/$(BUSYBOX_CONFIG) $@
44 $(BUSYBOX_SRC_DIR)/busybox: $(BUSYBOX_SRC_DIR)/.config | $(BUSYBOX_LOG_DIR)
45 @ echo "Building busybox..."
46 ifneq ($(findstring defconfig,$(BUSYBOX_CONFIG)),defconfig)
47 @ echo "Using custom config $(PACKAGE_DIR)/busybox/conf/$(BUSYBOX_CONFIG)"
48 endif
49 @ ( unset CFLAGS; unset LDFLAGS; \
50 export EXTRA_CFLAGS="$(CFLAGS)";\
51 export LDFLAGS="$(LDFLAGS_orig)";\
52 $(MAKE) -C $(BUSYBOX_SRC_DIR) VERBOSE=y \
53 LIBRARIES="$(LIBS)" all > $(BUSYBOX_BUILD_LOG) 2>&1)
54 @ mkdir -p $(OUTPUT_DIR)/config/busybox
55 @ cp $(BUSYBOX_SRC_DIR)/.config $(OUTPUT_DIR)/config/busybox/
58 $(INITRD_DIR)/bin/busybox: $(BUSYBOX_SRC_DIR)/busybox | $(BUSYBOX_LOG_DIR)
59 @ $(MAKE) -C $(BUSYBOX_SRC_DIR) \
60 PREFIX=$(INITRD_DIR) install > $(BUSYBOX_INSTALL_LOG) 2>&1
62 $(BUSYBOX_STAMP_DIR) $(BUSYBOX_LOG_DIR) $(BUSYBOX_DIR):
63 @ mkdir -p $@
65 busybox: $(INITRD_DIR)/bin/busybox
67 busybox-clean:
68 @ echo "Cleaning busybox..."
69 ifneq ($(wildcard "$(BUSYBOX_SRC_DIR)/Makefile"),)
70 @ $(MAKE) -C $(BUSYBOX_SRC_DIR) clean > /dev/null 2>&1
71 endif
73 busybox-distclean:
74 @ rm -rf $(BUSYBOX_DIR)/*
76 busybox-bom:
77 @ echo "Package: busybox"
78 @ echo "Source: $(BUSYBOX_URL)/$(BUSYBOX_SOURCE)"
79 @ echo ""
81 busybox-extract: $(BUSYBOX_STAMP_DIR)/.patched
83 busybox-config: | $(BUSYBOX_SRC_DIR)/.config
84 ifeq ($(shell if [ -f $(PACKAGE_DIR)/busybox/conf/customconfig--$(PAYLOAD)--$(COREBOOT_VENDOR)-$(COREBOOT_BOARD) ]; then echo 1; fi),1)
85 @ cp -f $(PACKAGE_DIR)/busybox/conf/customconfig--$(PAYLOAD)--$(COREBOOT_VENDOR)-$(COREBOOT_BOARD) $(BUSYBOX_SRC_DIR)/.config
86 endif
87 ifeq (busybox,$(filter busybox,$(PAYLOAD-y)))
88 @ echo "Configure busybox..."
89 @ $(MAKE) -C $(BUSYBOX_SRC_DIR) menuconfig
90 @ echo
91 ifeq ($(shell if [ -f $(PACKAGE_DIR)/busybox/conf/customconfig--$(PAYLOAD)--$(COREBOOT_VENDOR)-$(COREBOOT_BOARD) ]; then echo 1; fi),1)
92 @ echo "Found an existing custom configuration file:"
93 @ echo " $(PACKAGE_DIR)/busybox/conf/customconfig--$(PAYLOAD)--$(COREBOOT_VENDOR)-$(COREBOOT_BOARD)"
94 @ echo "I've copied it back to the source directory for modification."
95 @ echo "Remove the above file and re-run this command if you want to create a new custom configuration from scratch for this payload/board."
96 @ echo
97 endif
98 @ cp -f $(BUSYBOX_SRC_DIR)/.config $(PACKAGE_DIR)/busybox/conf/customconfig--$(PAYLOAD)--$(COREBOOT_VENDOR)-$(COREBOOT_BOARD)
99 @ echo "Your custom busybox config file has been saved as $(PACKAGE_DIR)/busybox/conf/customconfig--$(PAYLOAD)--$(COREBOOT_VENDOR)-$(COREBOOT_BOARD)."
100 @ echo
101 else
102 @ echo "Your payload does not require busybox."
103 endif