IB/SDK/toolchain: use VERSION_DIST_SANITIZED instead of VERSION_DIST
[openwrt/openwrt.git] / target / sdk / Makefile
1 #
2 # Copyright (C) 2006-2014 OpenWrt.org
3 # Copyright (C) 2016 LEDE Project
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 include $(TOPDIR)/rules.mk
10 include $(INCLUDE_DIR)/kernel.mk
11 include $(INCLUDE_DIR)/host.mk
12 include $(INCLUDE_DIR)/version.mk
13
14 override MAKEFLAGS=
15
16 SDK_NAME:=$(VERSION_DIST_SANITIZED)-SDK-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))$(if $(GCCV),_gcc-$(GCCV))$(DIR_SUFFIX).$(HOST_OS)-$(HOST_ARCH)
17 SDK_BUILD_DIR:=$(BUILD_DIR)/$(SDK_NAME)
18
19 STAGING_SUBDIR_HOST := staging_dir/host
20 STAGING_SUBDIR_TOOLCHAIN := staging_dir/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)_$(LIBC)-$(LIBCV)$(if $(CONFIG_arm),_eabi)
21
22 EXCLUDE_DIRS:=*/ccache/* \
23 */stamp \
24 */stampfiles \
25 */man \
26 */info \
27 */root-* \
28 initial \
29 *.install.clean \
30 *.install.flags \
31 *.install \
32 */doc
33
34 SDK_DIRS = \
35 $(STAGING_SUBDIR_HOST) \
36 $(STAGING_SUBDIR_TOOLCHAIN)
37
38 BASE_FEED:=$(shell git config --get remote.origin.url 2>/dev/null | sed -ne 's/^/src-git base /p')
39 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'))
40 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'))
41 BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),src-git base https://git.lede-project.org/source.git$(filter-out ;master,;$(shell git rev-parse --abbrev-ref HEAD)))
42
43 KDIR_BASE = $(patsubst $(TOPDIR)/%,%,$(LINUX_DIR))
44
45 KERNEL_FILES_ARCH = \
46 Makefile* \
47 module.lds \
48 Kbuild.platforms \
49 */Platform \
50 include \
51 */include \
52 scripts \
53 kernel/asm-offsets.s
54
55 KERNEL_FILES_BASE := \
56 .config \
57 Makefile \
58 scripts \
59 include \
60 Module.symvers \
61 modules.builtin \
62 $(addprefix arch/$(LINUX_KARCH)/,$(KERNEL_FILES_ARCH))
63
64 KERNEL_FILES := $(patsubst $(TOPDIR)/%,%,$(wildcard $(addprefix $(LINUX_DIR)/,$(KERNEL_FILES_BASE))))
65
66 all: compile
67
68 $(BIN_DIR)/$(SDK_NAME).tar.bz2: clean
69 mkdir -p $(SDK_BUILD_DIR)/dl $(SDK_BUILD_DIR)/package
70 $(CP) $(INCLUDE_DIR) $(SCRIPT_DIR) $(TOPDIR)/docs $(SDK_BUILD_DIR)/
71 $(TAR) -cf - -C $(TOPDIR) \
72 `cd $(TOPDIR); find $(KDIR_BASE) -name \*.ko` \
73 `cd $(TOPDIR); find $(KDIR_BASE)/firmware/ -newer $(KDIR_BASE)/firmware/Makefile \
74 -type f -name '*.bin' -or -name '*.cis' -or -name '*.csp' -or -name '*.dsp' -or -name '*.fw'` \
75 $(foreach exclude,$(EXCLUDE_DIRS),--exclude="$(exclude)") \
76 $(SDK_DIRS) $(KERNEL_FILES) | \
77 $(TAR) -xf - -C $(SDK_BUILD_DIR)
78
79 @-( \
80 find \
81 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/bin \
82 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/bin \
83 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/bin \
84 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/*/bin \
85 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/libexec \
86 -type f; \
87 find \
88 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/lib \
89 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/lib \
90 -type f -name \*.so\* -or -name \*.a; \
91 ) | xargs strip 2>/dev/null >/dev/null
92
93 mkdir -p $(SDK_BUILD_DIR)/target/linux
94 $(CP) $(GENERIC_PLATFORM_DIR) $(PLATFORM_DIR) $(SDK_BUILD_DIR)/target/linux/
95 rm -rf \
96 $(SDK_BUILD_DIR)/target/linux/*/files* \
97 $(SDK_BUILD_DIR)/target/linux/*/patches*
98 ./convert-config.pl $(TOPDIR)/.config > $(SDK_BUILD_DIR)/Config-build.in
99 $(CP) -L \
100 $(TOPDIR)/LICENSE \
101 $(TOPDIR)/rules.mk \
102 ./files/Config.in \
103 ./files/Makefile \
104 ./files/include/prepare.mk \
105 ./files/README.SDK \
106 $(SDK_BUILD_DIR)/
107 $(CP) \
108 $(TOPDIR)/package/Makefile \
109 $(SDK_BUILD_DIR)/package/
110
111 -rm -f $(SDK_BUILD_DIR)/feeds.conf.default
112 $(if $(BASE_FEED),echo "$(BASE_FEED)" > $(SDK_BUILD_DIR)/feeds.conf.default)
113 if [ -f $(TOPDIR)/feeds.conf ]; then \
114 cat $(TOPDIR)/feeds.conf >> $(SDK_BUILD_DIR)/feeds.conf.default; \
115 else \
116 cat $(TOPDIR)/feeds.conf.default >> $(SDK_BUILD_DIR)/feeds.conf.default; \
117 fi
118 $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(SDK_BUILD_DIR)/include/version.mk
119 $(SED) '/LINUX_VERMAGIC:=/ { s,unknown,$(LINUX_VERMAGIC),g }' $(SDK_BUILD_DIR)/include/kernel.mk
120 find $(SDK_BUILD_DIR) -name .git | $(XARGS) rm -rf
121 find $(SDK_BUILD_DIR) -name .svn | $(XARGS) rm -rf
122 find $(SDK_BUILD_DIR) -name CVS | $(XARGS) rm -rf
123 (cd $(BUILD_DIR); \
124 tar cfj $@ $(SDK_NAME); \
125 )
126
127 download:
128 prepare:
129 compile: $(BIN_DIR)/$(SDK_NAME).tar.bz2
130 install: compile
131
132 clean:
133 rm -rf $(SDK_BUILD_DIR) $(BIN_DIR)/$(SDK_NAME).tar.bz2