ebc7e25c9bc273b151488b2e078a6163da251354
[openwrt/openwrt.git] / target / toolchain / Makefile
1 #
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
5 #
6 # This is free software, licensed under the GNU General Public License v2.
7 # See /LICENSE for more information.
8 #
9
10 include $(TOPDIR)/rules.mk
11 include $(INCLUDE_DIR)/kernel.mk
12 include $(INCLUDE_DIR)/host.mk
13 include $(INCLUDE_DIR)/version.mk
14
15 override MAKEFLAGS=
16
17 TOOLCHAIN_NAME:=OpenWrt-Toolchain-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))_gcc-$(GCCV)$(DIR_SUFFIX).$(HOST_OS)-$(HOST_ARCH)
18 TOOLCHAIN_BUILD_DIR:=$(BUILD_DIR)/$(TOOLCHAIN_NAME)
19 EXCLUDE_DIRS:=*/ccache \
20 */initial \
21 */stamp \
22 */stampfiles \
23 */man \
24 */info
25
26 all: compile
27
28 TOOLCHAIN_PREFIX:=$(TOOLCHAIN_BUILD_DIR)/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX)
29
30 $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2: clean
31 mkdir -p $(TOOLCHAIN_BUILD_DIR)
32 $(TAR) -cf - -C $(TOPDIR)/staging_dir/ \
33 $(foreach exclude,$(EXCLUDE_DIRS),--exclude="$(exclude)") \
34 toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX) | \
35 $(TAR) -xf - -C $(TOOLCHAIN_BUILD_DIR)
36
37 $(CP) $(TOPDIR)/LICENSE ./files/README.TOOLCHAIN \
38 $(TOOLCHAIN_BUILD_DIR)/
39
40 $(CP) ./files/wrapper.sh $(TOOLCHAIN_PREFIX)/bin/$(REAL_GNU_TARGET_NAME)-wrapper.sh
41 chmod +x $(TOOLCHAIN_PREFIX)/bin/$(REAL_GNU_TARGET_NAME)-wrapper.sh
42 (cd $(TOOLCHAIN_PREFIX)/bin; \
43 for app in cc gcc g++ c++ cpp ld as ; do \
44 [ -f $(REAL_GNU_TARGET_NAME)-$${app} ] && mv $(REAL_GNU_TARGET_NAME)-$${app} $(REAL_GNU_TARGET_NAME)-$${app}.bin ; \
45 ln -sf $(REAL_GNU_TARGET_NAME)-wrapper.sh $(REAL_GNU_TARGET_NAME)-$${app} ; \
46 done; \
47 )
48
49 @-( \
50 find \
51 $(TOOLCHAIN_BUILD_DIR)/*/bin \
52 $(TOOLCHAIN_BUILD_DIR)/*/*/bin \
53 $(TOOLCHAIN_BUILD_DIR)/*/libexec \
54 -type f; \
55 ) | xargs strip 2>/dev/null >/dev/null
56
57 echo REVISION:="$(REVISION)" > $(TOOLCHAIN_BUILD_DIR)/version.mk
58 find $(TOOLCHAIN_BUILD_DIR) -name .git | $(XARGS) rm -rf
59 find $(TOOLCHAIN_BUILD_DIR) -name .svn | $(XARGS) rm -rf
60 find $(TOOLCHAIN_BUILD_DIR) -name CVS | $(XARGS) rm -rf
61 (cd $(BUILD_DIR); \
62 tar cfj $@ $(TOOLCHAIN_NAME); \
63 )
64
65 download:
66 prepare:
67 compile: $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2
68 install: compile
69
70 clean:
71 rm -rf $(TOOLCHAIN_BUILD_DIR) $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2