2 # Copyright (C) 2006-2012 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 include $(TOPDIR)/rules.mk
9 include $(INCLUDE_DIR)/kernel.mk
10 include $(INCLUDE_DIR)/host.mk
11 include $(INCLUDE_DIR)/version.mk
15 PKG_OS:=$(word 2,$(subst -, ,$(shell $(HOSTCC) -dumpmachine)))
16 PKG_CPU:=$(word 1,$(subst -, ,$(shell $(HOSTCC) -dumpmachine)))
18 IB_NAME:=OpenWrt-ImageBuilder-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),_$(SUBTARGET))-for-$(PKG_OS)-$(PKG_CPU)
19 PKG_BUILD_DIR:=$(BUILD_DIR)/$(IB_NAME)
20 IB_KDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(KERNEL_BUILD_DIR))
21 IB_LDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR))
22 IB_DTSDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR))/arch/$(ARCH)/boot/dts/
26 $(BIN_DIR)/$(IB_NAME).tar.bz2: clean
27 rm -rf $(PKG_BUILD_DIR)
28 mkdir -p $(IB_KDIR) $(IB_LDIR) $(PKG_BUILD_DIR)/staging_dir/host/lib \
29 $(PKG_BUILD_DIR)/target $(PKG_BUILD_DIR)/scripts $(IB_DTSDIR)
30 -cp $(TOPDIR)/.config $(PKG_BUILD_DIR)/.config
32 $(INCLUDE_DIR) $(SCRIPT_DIR) \
35 ./files/repositories.conf \
36 $(TMP_DIR)/.targetinfo \
37 $(TMP_DIR)/.packageinfo \
39 $(VERSION_SED) $(PKG_BUILD_DIR)/repositories.conf
40 $(CP) $(PACKAGE_DIR) $(PKG_BUILD_DIR)/packages
41 $(CP) $(TOPDIR)/target/linux $(PKG_BUILD_DIR)/target/
42 if [ -d $(TOPDIR)/staging_dir/host/lib/grub ]; then \
43 $(CP) $(TOPDIR)/staging_dir/host/lib/grub/ $(PKG_BUILD_DIR)/staging_dir/host/lib; \
46 $(PKG_BUILD_DIR)/target/linux/*/files{,-*} \
47 $(PKG_BUILD_DIR)/target/linux/*/patches{,-*}
48 -cp $(KERNEL_BUILD_DIR)/* $(IB_KDIR)/ # don't copy subdirectories here
49 -cp $(LINUX_DIR)/.config $(IB_LDIR)/
50 -$(SCRIPT_DIR)/bundle-libraries.sh $(IB_LDIR)/scripts/dtc \
51 $(LINUX_DIR)/scripts/dtc/dtc
52 if [ -d $(LINUX_DIR)/arch/$(ARCH)/boot/dts ]; then \
53 $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/* $(IB_DTSDIR); \
55 $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(PKG_BUILD_DIR)/include/version.mk
56 find $(PKG_BUILD_DIR) -name CVS -o -name .git -o -name .svn \
58 find $(STAGING_DIR_HOST)/bin -maxdepth 1 -type f -perm -u=x \
59 | $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(PKG_BUILD_DIR)/staging_dir/host/bin
60 $(MAKE) -C $(PKG_BUILD_DIR) package_index
61 $(TAR) c -C $(BUILD_DIR) $(IB_NAME) | bzip2 -c > $@
65 compile: $(BIN_DIR)/$(IB_NAME).tar.bz2
69 rm -rf $(PKG_BUILD_DIR) $(BIN_DIR)/$(IB_NAME).tar.bz2