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