targets: Use configured distribution name for SDK, IB, and Toolchain tarball names
targets: Use configured distribution name for SDK, IB, and Toolchain tarball names

We allow to configure the version distribution name;
let's also use it for the tarballs (SDK, ImageBuilder,
and SDK).

Signed-off-by: Daniel Dickinson <openwrt@daniel.thecshore.com>

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@48081 3c298f89-4303-0410-b956-a3cf2f4a3e73

# #
# Copyright (C) 2006-2015 OpenWrt.org # Copyright (C) 2006-2015 OpenWrt.org
# #
# This is free software, licensed under the GNU General Public License v2. # This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information. # See /LICENSE for more information.
# #
   
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/host.mk include $(INCLUDE_DIR)/host.mk
include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/version.mk
include $(INCLUDE_DIR)/feeds.mk include $(INCLUDE_DIR)/feeds.mk
   
override MAKEFLAGS= override MAKEFLAGS=
   
IB_NAME:=OpenWrt-ImageBuilder-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET)).$(HOST_OS)-$(HOST_ARCH) IB_NAME:=$(VERSION_DIST)-ImageBuilder-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET)).$(HOST_OS)-$(HOST_ARCH)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(IB_NAME) PKG_BUILD_DIR:=$(BUILD_DIR)/$(IB_NAME)
IB_KDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(KERNEL_BUILD_DIR)) IB_KDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(KERNEL_BUILD_DIR))
IB_LDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR)) IB_LDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR))
IB_DTSDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR))/arch/$(ARCH)/boot/dts/ IB_DTSDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR))/arch/$(ARCH)/boot/dts/
   
all: compile all: compile
   
$(BIN_DIR)/$(IB_NAME).tar.bz2: clean $(BIN_DIR)/$(IB_NAME).tar.bz2: clean
rm -rf $(PKG_BUILD_DIR) rm -rf $(PKG_BUILD_DIR)
mkdir -p $(IB_KDIR) $(IB_LDIR) $(PKG_BUILD_DIR)/staging_dir/host/lib \ mkdir -p $(IB_KDIR) $(IB_LDIR) $(PKG_BUILD_DIR)/staging_dir/host/lib \
$(PKG_BUILD_DIR)/target $(PKG_BUILD_DIR)/scripts $(IB_DTSDIR) $(PKG_BUILD_DIR)/target $(PKG_BUILD_DIR)/scripts $(IB_DTSDIR)
-cp $(TOPDIR)/.config $(PKG_BUILD_DIR)/.config -cp $(TOPDIR)/.config $(PKG_BUILD_DIR)/.config
$(CP) \ $(CP) \
$(INCLUDE_DIR) $(SCRIPT_DIR) \ $(INCLUDE_DIR) $(SCRIPT_DIR) \
$(TOPDIR)/rules.mk \ $(TOPDIR)/rules.mk \
./files/Makefile \ ./files/Makefile \
./files/repositories.conf \ ./files/repositories.conf \
$(TMP_DIR)/.targetinfo \ $(TMP_DIR)/.targetinfo \
$(TMP_DIR)/.packageinfo \ $(TMP_DIR)/.packageinfo \
$(PKG_BUILD_DIR)/ $(PKG_BUILD_DIR)/
   
ifeq ($(CONFIG_IB_STANDALONE),) ifeq ($(CONFIG_IB_STANDALONE),)
echo '## Remote package repositories' >> $(PKG_BUILD_DIR)/repositories.conf echo '## Remote package repositories' >> $(PKG_BUILD_DIR)/repositories.conf
$(call FeedSourcesAppend,$(PKG_BUILD_DIR)/repositories.conf) $(call FeedSourcesAppend,$(PKG_BUILD_DIR)/repositories.conf)
endif endif
   
echo '' >> $(PKG_BUILD_DIR)/repositories.conf echo '' >> $(PKG_BUILD_DIR)/repositories.conf
echo '## This is the local package repository, do not remove!' >> $(PKG_BUILD_DIR)/repositories.conf echo '## This is the local package repository, do not remove!' >> $(PKG_BUILD_DIR)/repositories.conf
echo 'src imagebuilder file:packages' >> $(PKG_BUILD_DIR)/repositories.conf echo 'src imagebuilder file:packages' >> $(PKG_BUILD_DIR)/repositories.conf
   
$(VERSION_SED) $(PKG_BUILD_DIR)/repositories.conf $(VERSION_SED) $(PKG_BUILD_DIR)/repositories.conf
   
ifeq ($(CONFIG_IB_STANDALONE),) ifeq ($(CONFIG_IB_STANDALONE),)
(cd $(PACKAGE_DIR); $(FIND) -type f -name 'libc_*.ipk' -or -name 'kernel_*.ipk' -or -name 'kmod-*.ipk') | \ (cd $(PACKAGE_DIR); $(FIND) -type f -name 'libc_*.ipk' -or -name 'kernel_*.ipk' -or -name 'kmod-*.ipk') | \
while read path; do \ while read path; do \
mkdir -p "$(PKG_BUILD_DIR)/packages/$${path%/*}"; \ mkdir -p "$(PKG_BUILD_DIR)/packages/$${path%/*}"; \
cp "$(PACKAGE_DIR)/$$path" "$(PKG_BUILD_DIR)/packages/$$path"; \ cp "$(PACKAGE_DIR)/$$path" "$(PKG_BUILD_DIR)/packages/$$path"; \
done done
else else
$(CP) $(PACKAGE_DIR) $(PKG_BUILD_DIR)/packages $(CP) $(PACKAGE_DIR) $(PKG_BUILD_DIR)/packages
endif endif
   
$(CP) $(TOPDIR)/target/linux $(PKG_BUILD_DIR)/target/ $(CP) $(TOPDIR)/target/linux $(PKG_BUILD_DIR)/target/
if [ -d $(TOPDIR)/staging_dir/host/lib/grub ]; then \ if [ -d $(TOPDIR)/staging_dir/host/lib/grub ]; then \
$(CP) $(TOPDIR)/staging_dir/host/lib/grub/ $(PKG_BUILD_DIR)/staging_dir/host/lib; \ $(CP) $(TOPDIR)/staging_dir/host/lib/grub/ $(PKG_BUILD_DIR)/staging_dir/host/lib; \
fi fi
rm -rf \ rm -rf \
$(PKG_BUILD_DIR)/target/linux/*/files{,-*} \ $(PKG_BUILD_DIR)/target/linux/*/files{,-*} \
$(PKG_BUILD_DIR)/target/linux/*/patches{,-*} $(PKG_BUILD_DIR)/target/linux/*/patches{,-*}
-cp $(KERNEL_BUILD_DIR)/* $(IB_KDIR)/ # don't copy subdirectories here -cp $(KERNEL_BUILD_DIR)/* $(IB_KDIR)/ # don't copy subdirectories here
-cp $(LINUX_DIR)/.config $(IB_LDIR)/ -cp $(LINUX_DIR)/.config $(IB_LDIR)/
-$(SCRIPT_DIR)/bundle-libraries.sh $(IB_LDIR)/scripts/dtc \ -$(SCRIPT_DIR)/bundle-libraries.sh $(IB_LDIR)/scripts/dtc \
$(LINUX_DIR)/scripts/dtc/dtc $(LINUX_DIR)/scripts/dtc/dtc
if [ -d $(LINUX_DIR)/arch/$(ARCH)/boot/dts ]; then \ if [ -d $(LINUX_DIR)/arch/$(ARCH)/boot/dts ]; then \
$(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/* $(IB_DTSDIR); \ $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/* $(IB_DTSDIR); \
fi fi
$(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(PKG_BUILD_DIR)/include/version.mk $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(PKG_BUILD_DIR)/include/version.mk
find $(PKG_BUILD_DIR) -name CVS -o -name .git -o -name .svn \ find $(PKG_BUILD_DIR) -name CVS -o -name .git -o -name .svn \
| $(XARGS) rm -rf | $(XARGS) rm -rf
find $(STAGING_DIR_HOST)/bin -maxdepth 1 -type f -perm -u=x \ find $(STAGING_DIR_HOST)/bin -maxdepth 1 -type f -perm -u=x \
| $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(PKG_BUILD_DIR)/staging_dir/host/bin/ | $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(PKG_BUILD_DIR)/staging_dir/host/bin/
STRIP=sstrip $(SCRIPT_DIR)/rstrip.sh $(PKG_BUILD_DIR)/staging_dir/host/bin/ STRIP=sstrip $(SCRIPT_DIR)/rstrip.sh $(PKG_BUILD_DIR)/staging_dir/host/bin/
$(TAR) -cf - -C $(BUILD_DIR) $(IB_NAME) | bzip2 -c > $@ $(TAR) -cf - -C $(BUILD_DIR) $(IB_NAME) | bzip2 -c > $@
   
download: download:
prepare: prepare:
compile: $(BIN_DIR)/$(IB_NAME).tar.bz2 compile: $(BIN_DIR)/$(IB_NAME).tar.bz2
install: compile install: compile
   
clean: FORCE clean: FORCE
rm -rf $(PKG_BUILD_DIR) $(BIN_DIR)/$(IB_NAME).tar.bz2 rm -rf $(PKG_BUILD_DIR) $(BIN_DIR)/$(IB_NAME).tar.bz2
   
# #
# Copyright (C) 2006-2014 OpenWrt.org # Copyright (C) 2006-2014 OpenWrt.org
# #
# This is free software, licensed under the GNU General Public License v2. # This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information. # See /LICENSE for more information.
# #
   
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/host.mk include $(INCLUDE_DIR)/host.mk
include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/version.mk
   
override MAKEFLAGS= override MAKEFLAGS=
   
SDK_NAME:=OpenWrt-SDK-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))_gcc-$(GCCV)$(DIR_SUFFIX).$(HOST_OS)-$(HOST_ARCH) SDK_NAME:=$(VERSION_DIST)-SDK-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))_gcc-$(GCCV)$(DIR_SUFFIX).$(HOST_OS)-$(HOST_ARCH)
SDK_BUILD_DIR:=$(BUILD_DIR)/$(SDK_NAME) SDK_BUILD_DIR:=$(BUILD_DIR)/$(SDK_NAME)
   
STAGING_SUBDIR_HOST := staging_dir/host STAGING_SUBDIR_HOST := staging_dir/host
STAGING_SUBDIR_TARGET := staging_dir/target-$(ARCH)$(ARCH_SUFFIX)_$(LIBC)-$(LIBCV)$(if $(CONFIG_arm),_eabi) STAGING_SUBDIR_TARGET := staging_dir/target-$(ARCH)$(ARCH_SUFFIX)_$(LIBC)-$(LIBCV)$(if $(CONFIG_arm),_eabi)
STAGING_SUBDIR_TOOLCHAIN := staging_dir/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)_$(LIBC)-$(LIBCV)$(if $(CONFIG_arm),_eabi) STAGING_SUBDIR_TOOLCHAIN := staging_dir/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)_$(LIBC)-$(LIBCV)$(if $(CONFIG_arm),_eabi)
   
EXCLUDE_DIRS:=*/ccache \ EXCLUDE_DIRS:=*/ccache \
*/stamp \ */stamp \
*/stampfiles \ */stampfiles \
*/man \ */man \
*/info \ */info \
*/root-* \ */root-* \
initial \ initial \
*.install.clean \ *.install.clean \
*.install.flags \ *.install.flags \
*.install \ *.install \
*/doc */doc
   
SDK_DIRS = \ SDK_DIRS = \
$(STAGING_SUBDIR_HOST) \ $(STAGING_SUBDIR_HOST) \
$(STAGING_SUBDIR_TARGET) \ $(STAGING_SUBDIR_TARGET) \
$(STAGING_SUBDIR_TOOLCHAIN) $(STAGING_SUBDIR_TOOLCHAIN)
   
BASE_FEED:=$(shell git config --get remote.origin.url 2>/dev/null | sed -ne 's/^/src-git base /p') BASE_FEED:=$(shell git config --get remote.origin.url 2>/dev/null | sed -ne 's/^/src-git base /p')
BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),$(shell cd $(TOPDIR); LC_ALL=C git svn info 2>/dev/null | sed -ne 's/^URL: /src-gitsvn base /p')) BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),$(shell cd $(TOPDIR); LC_ALL=C git svn info 2>/dev/null | sed -ne 's/^URL: /src-gitsvn base /p'))
BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),$(shell cd $(TOPDIR); LC_ALL=C svn info 2>/dev/null | sed -ne 's/^URL: /src-svn base /p')) BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),$(shell cd $(TOPDIR); LC_ALL=C svn info 2>/dev/null | sed -ne 's/^URL: /src-svn base /p'))
   
KDIR_BASE = $(patsubst $(TOPDIR)/%,%,$(LINUX_DIR)) KDIR_BASE = $(patsubst $(TOPDIR)/%,%,$(LINUX_DIR))
   
KERNEL_FILES_ARCH = \ KERNEL_FILES_ARCH = \
Makefile* \ Makefile* \
module.lds \ module.lds \
Kbuild.platforms \ Kbuild.platforms \
*/Platform \ */Platform \
include \ include \
*/include \ */include \
scripts \ scripts \
kernel/asm-offsets.s kernel/asm-offsets.s
   
KERNEL_FILES_BASE := \ KERNEL_FILES_BASE := \
.config \ .config \
Makefile \ Makefile \
scripts \ scripts \
include \ include \
Module.symvers \ Module.symvers \
$(addprefix arch/$(LINUX_KARCH)/,$(KERNEL_FILES_ARCH)) $(addprefix arch/$(LINUX_KARCH)/,$(KERNEL_FILES_ARCH))
   
KERNEL_FILES := $(patsubst $(TOPDIR)/%,%,$(wildcard $(addprefix $(LINUX_DIR)/,$(KERNEL_FILES_BASE)))) KERNEL_FILES := $(patsubst $(TOPDIR)/%,%,$(wildcard $(addprefix $(LINUX_DIR)/,$(KERNEL_FILES_BASE))))
   
all: compile all: compile
   
$(BIN_DIR)/$(SDK_NAME).tar.bz2: clean $(BIN_DIR)/$(SDK_NAME).tar.bz2: clean
mkdir -p $(SDK_BUILD_DIR)/dl $(SDK_BUILD_DIR)/package mkdir -p $(SDK_BUILD_DIR)/dl $(SDK_BUILD_DIR)/package
$(CP) $(INCLUDE_DIR) $(SCRIPT_DIR) $(TOPDIR)/docs $(SDK_BUILD_DIR)/ $(CP) $(INCLUDE_DIR) $(SCRIPT_DIR) $(TOPDIR)/docs $(SDK_BUILD_DIR)/
$(TAR) -cf - -C $(TOPDIR) \ $(TAR) -cf - -C $(TOPDIR) \
$(foreach exclude,$(EXCLUDE_DIRS),--exclude="$(exclude)") \ $(foreach exclude,$(EXCLUDE_DIRS),--exclude="$(exclude)") \
$(SDK_DIRS) $(KERNEL_FILES) | \ $(SDK_DIRS) $(KERNEL_FILES) | \
$(TAR) -xf - -C $(SDK_BUILD_DIR) $(TAR) -xf - -C $(SDK_BUILD_DIR)
   
@-( \ @-( \
find \ find \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/bin \ $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/bin \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/bin \ $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/bin \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/bin \ $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/bin \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/*/bin \ $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/*/bin \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/libexec \ $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/libexec \
-type f; \ -type f; \
find \ find \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/lib \ $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/lib \
$(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/lib \ $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/lib \
-type f -name \*.so\* -or -name \*.a; \ -type f -name \*.so\* -or -name \*.a; \
) | xargs strip 2>/dev/null >/dev/null ) | xargs strip 2>/dev/null >/dev/null
   
mkdir -p $(SDK_BUILD_DIR)/target/linux mkdir -p $(SDK_BUILD_DIR)/target/linux
$(CP) $(GENERIC_PLATFORM_DIR) $(PLATFORM_DIR) $(SDK_BUILD_DIR)/target/linux/ $(CP) $(GENERIC_PLATFORM_DIR) $(PLATFORM_DIR) $(SDK_BUILD_DIR)/target/linux/
rm -rf \ rm -rf \
$(SDK_BUILD_DIR)/target/linux/*/files* \ $(SDK_BUILD_DIR)/target/linux/*/files* \
$(SDK_BUILD_DIR)/target/linux/*/patches* $(SDK_BUILD_DIR)/target/linux/*/patches*
./convert-config.pl $(TOPDIR)/.config > $(SDK_BUILD_DIR)/Config-build.in ./convert-config.pl $(TOPDIR)/.config > $(SDK_BUILD_DIR)/Config-build.in
$(CP) -L \ $(CP) -L \
$(TOPDIR)/LICENSE \ $(TOPDIR)/LICENSE \
$(TOPDIR)/rules.mk \ $(TOPDIR)/rules.mk \
$(TOPDIR)/.config \ $(TOPDIR)/.config \
./files/Config.in \ ./files/Config.in \
./files/Makefile \ ./files/Makefile \
./files/include/prepare.mk \ ./files/include/prepare.mk \
./files/README.SDK \ ./files/README.SDK \
$(SDK_BUILD_DIR)/ $(SDK_BUILD_DIR)/
$(CP) \ $(CP) \
$(TOPDIR)/package/Makefile \ $(TOPDIR)/package/Makefile \
$(SDK_BUILD_DIR)/package/ $(SDK_BUILD_DIR)/package/
   
-rm -f $(SDK_BUILD_DIR)/feeds.conf.default -rm -f $(SDK_BUILD_DIR)/feeds.conf.default
$(if $(BASE_FEED),echo "$(BASE_FEED)" > $(SDK_BUILD_DIR)/feeds.conf.default) $(if $(BASE_FEED),echo "$(BASE_FEED)" > $(SDK_BUILD_DIR)/feeds.conf.default)
if [ -f $(TOPDIR)/feeds.conf ]; then \ if [ -f $(TOPDIR)/feeds.conf ]; then \
cat $(TOPDIR)/feeds.conf >> $(SDK_BUILD_DIR)/feeds.conf.default; \ cat $(TOPDIR)/feeds.conf >> $(SDK_BUILD_DIR)/feeds.conf.default; \
else \ else \
cat $(TOPDIR)/feeds.conf.default >> $(SDK_BUILD_DIR)/feeds.conf.default; \ cat $(TOPDIR)/feeds.conf.default >> $(SDK_BUILD_DIR)/feeds.conf.default; \
fi fi
$(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(SDK_BUILD_DIR)/include/version.mk $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(SDK_BUILD_DIR)/include/version.mk
$(SED) '/LINUX_VERMAGIC:=/ { s,unknown,$(LINUX_VERMAGIC),g }' $(SDK_BUILD_DIR)/include/kernel.mk $(SED) '/LINUX_VERMAGIC:=/ { s,unknown,$(LINUX_VERMAGIC),g }' $(SDK_BUILD_DIR)/include/kernel.mk
find $(SDK_BUILD_DIR) -name .git | $(XARGS) rm -rf find $(SDK_BUILD_DIR) -name .git | $(XARGS) rm -rf
find $(SDK_BUILD_DIR) -name .svn | $(XARGS) rm -rf find $(SDK_BUILD_DIR) -name .svn | $(XARGS) rm -rf
find $(SDK_BUILD_DIR) -name CVS | $(XARGS) rm -rf find $(SDK_BUILD_DIR) -name CVS | $(XARGS) rm -rf
(cd $(BUILD_DIR); \ (cd $(BUILD_DIR); \
tar cfj $@ $(SDK_NAME); \ tar cfj $@ $(SDK_NAME); \
) )
   
download: download:
prepare: prepare:
compile: $(BIN_DIR)/$(SDK_NAME).tar.bz2 compile: $(BIN_DIR)/$(SDK_NAME).tar.bz2
install: compile install: compile
   
clean: clean:
rm -rf $(SDK_BUILD_DIR) $(BIN_DIR)/$(SDK_NAME).tar.bz2 rm -rf $(SDK_BUILD_DIR) $(BIN_DIR)/$(SDK_NAME).tar.bz2
   
# #
# Copyright (C) 2008-2009 Industrie Dial Face S.p.A. # Copyright (C) 2008-2009 Industrie Dial Face S.p.A.
# Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com> # Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com>
# Copyright (C) 2006-2008 OpenWrt.org # Copyright (C) 2006-2008 OpenWrt.org
# #
# This is free software, licensed under the GNU General Public License v2. # This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information. # See /LICENSE for more information.
# #
   
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/host.mk include $(INCLUDE_DIR)/host.mk
include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/version.mk
   
override MAKEFLAGS= override MAKEFLAGS=
   
TOOLCHAIN_NAME:=OpenWrt-Toolchain-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))_gcc-$(GCCV)$(DIR_SUFFIX).$(HOST_OS)-$(HOST_ARCH) TOOLCHAIN_NAME:=$(VERSION_DIST)-Toolchain-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))_gcc-$(GCCV)$(DIR_SUFFIX).$(HOST_OS)-$(HOST_ARCH)
TOOLCHAIN_BUILD_DIR:=$(BUILD_DIR)/$(TOOLCHAIN_NAME) TOOLCHAIN_BUILD_DIR:=$(BUILD_DIR)/$(TOOLCHAIN_NAME)
EXCLUDE_DIRS:=*/ccache \ EXCLUDE_DIRS:=*/ccache \
*/initial \ */initial \
*/stamp \ */stamp \
*/stampfiles \ */stampfiles \
*/man \ */man \
*/info */info
   
all: compile all: compile
   
TOOLCHAIN_PREFIX:=$(TOOLCHAIN_BUILD_DIR)/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX) TOOLCHAIN_PREFIX:=$(TOOLCHAIN_BUILD_DIR)/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX)
   
$(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2: clean $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2: clean
mkdir -p $(TOOLCHAIN_BUILD_DIR) mkdir -p $(TOOLCHAIN_BUILD_DIR)
$(TAR) -cf - -C $(TOPDIR)/staging_dir/ \ $(TAR) -cf - -C $(TOPDIR)/staging_dir/ \
$(foreach exclude,$(EXCLUDE_DIRS),--exclude="$(exclude)") \ $(foreach exclude,$(EXCLUDE_DIRS),--exclude="$(exclude)") \
toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX) | \ toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX) | \
$(TAR) -xf - -C $(TOOLCHAIN_BUILD_DIR) $(TAR) -xf - -C $(TOOLCHAIN_BUILD_DIR)
   
$(CP) $(TOPDIR)/LICENSE ./files/README.TOOLCHAIN \ $(CP) $(TOPDIR)/LICENSE ./files/README.TOOLCHAIN \
$(TOOLCHAIN_BUILD_DIR)/ $(TOOLCHAIN_BUILD_DIR)/
   
$(CP) ./files/wrapper.sh $(TOOLCHAIN_PREFIX)/bin/$(REAL_GNU_TARGET_NAME)-wrapper.sh $(CP) ./files/wrapper.sh $(TOOLCHAIN_PREFIX)/bin/$(REAL_GNU_TARGET_NAME)-wrapper.sh
chmod +x $(TOOLCHAIN_PREFIX)/bin/$(REAL_GNU_TARGET_NAME)-wrapper.sh chmod +x $(TOOLCHAIN_PREFIX)/bin/$(REAL_GNU_TARGET_NAME)-wrapper.sh
(cd $(TOOLCHAIN_PREFIX)/bin; \ (cd $(TOOLCHAIN_PREFIX)/bin; \
for app in cc gcc g++ c++ cpp ld as ; do \ for app in cc gcc g++ c++ cpp ld as ; do \
[ -f $(REAL_GNU_TARGET_NAME)-$${app} ] && mv $(REAL_GNU_TARGET_NAME)-$${app} $(REAL_GNU_TARGET_NAME)-$${app}.bin ; \ [ -f $(REAL_GNU_TARGET_NAME)-$${app} ] && mv $(REAL_GNU_TARGET_NAME)-$${app} $(REAL_GNU_TARGET_NAME)-$${app}.bin ; \
ln -sf $(REAL_GNU_TARGET_NAME)-wrapper.sh $(REAL_GNU_TARGET_NAME)-$${app} ; \ ln -sf $(REAL_GNU_TARGET_NAME)-wrapper.sh $(REAL_GNU_TARGET_NAME)-$${app} ; \
done; \ done; \
) )
   
@-( \ @-( \
find \ find \
$(TOOLCHAIN_BUILD_DIR)/*/bin \ $(TOOLCHAIN_BUILD_DIR)/*/bin \
$(TOOLCHAIN_BUILD_DIR)/*/*/bin \ $(TOOLCHAIN_BUILD_DIR)/*/*/bin \
$(TOOLCHAIN_BUILD_DIR)/*/libexec \ $(TOOLCHAIN_BUILD_DIR)/*/libexec \
-type f; \ -type f; \
) | xargs strip 2>/dev/null >/dev/null ) | xargs strip 2>/dev/null >/dev/null
   
echo REVISION:="$(REVISION)" > $(TOOLCHAIN_BUILD_DIR)/version.mk echo REVISION:="$(REVISION)" > $(TOOLCHAIN_BUILD_DIR)/version.mk
find $(TOOLCHAIN_BUILD_DIR) -name .git | $(XARGS) rm -rf find $(TOOLCHAIN_BUILD_DIR) -name .git | $(XARGS) rm -rf
find $(TOOLCHAIN_BUILD_DIR) -name .svn | $(XARGS) rm -rf find $(TOOLCHAIN_BUILD_DIR) -name .svn | $(XARGS) rm -rf
find $(TOOLCHAIN_BUILD_DIR) -name CVS | $(XARGS) rm -rf find $(TOOLCHAIN_BUILD_DIR) -name CVS | $(XARGS) rm -rf
(cd $(BUILD_DIR); \ (cd $(BUILD_DIR); \
tar cfj $@ $(TOOLCHAIN_NAME); \ tar cfj $@ $(TOOLCHAIN_NAME); \
) )
   
download: download:
prepare: prepare:
compile: $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2 compile: $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2
install: compile install: compile
   
clean: clean:
rm -rf $(TOOLCHAIN_BUILD_DIR) $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2 rm -rf $(TOOLCHAIN_BUILD_DIR) $(BIN_DIR)/$(TOOLCHAIN_NAME).tar.bz2
   
comments