ar71xx: rb2011: use board name from the hardware config
[openwrt.git] / target / imagebuilder / Makefile
1
2 # Copyright (C) 2006-2012 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9 include $(INCLUDE_DIR)/kernel.mk
10 include $(INCLUDE_DIR)/host.mk
11 include $(INCLUDE_DIR)/version.mk
12
13 override MAKEFLAGS=
14
15 PKG_OS:=$(word 2,$(subst -, ,$(shell $(HOSTCC) -dumpmachine)))
16 PKG_CPU:=$(word 1,$(subst -, ,$(shell $(HOSTCC) -dumpmachine)))
17
18 IB_NAME:=OpenWrt-ImageBuilder-$(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
23 all: compile
24
25 $(BIN_DIR)/$(IB_NAME).tar.bz2: clean
26         rm -rf $(PKG_BUILD_DIR)
27         mkdir -p $(IB_KDIR) $(IB_LDIR) $(PKG_BUILD_DIR)/staging_dir/host \
28                 $(PKG_BUILD_DIR)/target $(PKG_BUILD_DIR)/scripts
29         -cp $(TOPDIR)/.config $(PKG_BUILD_DIR)/.config
30         $(CP) \
31                 $(INCLUDE_DIR) $(SCRIPT_DIR) \
32                 $(TOPDIR)/rules.mk \
33                 ./files/Makefile \
34                 ./files/repositories.conf \
35                 $(TMP_DIR)/.targetinfo \
36                 $(TMP_DIR)/.packageinfo \
37                 $(PKG_BUILD_DIR)/
38         $(VERSION_SED) $(PKG_BUILD_DIR)/repositories.conf
39         $(CP) $(PACKAGE_DIR) $(PKG_BUILD_DIR)/packages
40         $(CP) $(TOPDIR)/target/linux $(PKG_BUILD_DIR)/target/
41         rm -rf \
42                 $(PKG_BUILD_DIR)/target/linux/*/files{,-*} \
43                 $(PKG_BUILD_DIR)/target/linux/*/patches{,-*}
44         -cp $(KERNEL_BUILD_DIR)/* $(IB_KDIR)/ # don't copy subdirectories here
45         -cp $(LINUX_DIR)/.config $(IB_LDIR)/
46         $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(PKG_BUILD_DIR)/include/version.mk
47         find $(PKG_BUILD_DIR) -name CVS -o -name .git -o -name .svn \
48           | $(XARGS) rm -rf
49         find $(STAGING_DIR_HOST)/bin -maxdepth 1 -type f -perm -u=x \
50           | $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(PKG_BUILD_DIR)/staging_dir/host/bin
51         $(TAR) c -C $(BUILD_DIR) $(IB_NAME) | bzip2 -c > $@
52
53 download:
54 prepare:
55 compile: $(BIN_DIR)/$(IB_NAME).tar.bz2
56 install: compile
57
58 clean: FORCE
59         rm -rf $(PKG_BUILD_DIR) $(BIN_DIR)/$(IB_NAME).tar.bz2