2 # Copyright (C) 2008-2009 Industrie Dial Face S.p.A.
3 # Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com>
4 # Copyright (C) 2006-2008 OpenWrt.org
6 # This is free software, licensed under the GNU General Public License v2.
7 # See /LICENSE for more information.
10 include $(TOPDIR)/rules.mk
11 include $(INCLUDE_DIR)/kernel.mk
12 include $(INCLUDE_DIR)/host.mk
16 PKG_OS:=$(word 2,$(subst -, ,$(shell $(HOSTCC) -dumpmachine)))
17 PKG_CPU:=$(word 1,$(subst -, ,$(shell $(HOSTCC) -dumpmachine)))
19 TOOLCHAIN_NAME:=OpenWrt-Toolchain-$(BOARD)-for-$(ARCH)$(ARCH_SUFFIX)-gcc-$(GCCV)$(DIR_SUFFIX)
20 TOOLCHAIN_BUILD_DIR:=$(BUILD_DIR)/$(TOOLCHAIN_NAME)
21 EXCLUDE_DIRS:=*/ccache \
29 TOOLCHAIN_PREFIX:=$(TOOLCHAIN_BUILD_DIR)/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX)
31 $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2: clean
32 mkdir -p $(TOOLCHAIN_BUILD_DIR)
33 $(TAR) -cf - -C $(TOPDIR)/staging_dir/ \
34 $(foreach exclude,$(EXCLUDE_DIRS),--exclude="$(exclude)") \
35 toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX) | \
36 $(TAR) -xf - -C $(TOOLCHAIN_BUILD_DIR)
38 $(CP) $(TOPDIR)/LICENSE ./files/README.TOOLCHAIN \
39 $(TOOLCHAIN_BUILD_DIR)/
41 $(CP) ./files/wrapper.sh $(TOOLCHAIN_PREFIX)/bin/$(REAL_GNU_TARGET_NAME)-wrapper.sh
42 chmod +x $(TOOLCHAIN_PREFIX)/bin/$(REAL_GNU_TARGET_NAME)-wrapper.sh
43 (cd $(TOOLCHAIN_PREFIX)/bin; \
44 for app in cc gcc g++ c++ cpp ld as ; do \
45 [ -f $(REAL_GNU_TARGET_NAME)-$${app} ] && mv $(REAL_GNU_TARGET_NAME)-$${app} $(REAL_GNU_TARGET_NAME)-$${app}.bin ; \
46 ln -sf $(REAL_GNU_TARGET_NAME)-wrapper.sh $(REAL_GNU_TARGET_NAME)-$${app} ; \
49 echo REVISION:="$(REVISION)" > $(TOOLCHAIN_BUILD_DIR)/version.mk
50 find $(TOOLCHAIN_BUILD_DIR) -name .git | $(XARGS) rm -rf
51 find $(TOOLCHAIN_BUILD_DIR) -name .svn | $(XARGS) rm -rf
52 find $(TOOLCHAIN_BUILD_DIR) -name CVS | $(XARGS) rm -rf
54 tar cfj $@ $(TOOLCHAIN_NAME); \
59 compile: $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2
63 rm -rf $(TOOLCHAIN_BUILD_DIR) $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2