sdk: do not exclude ccache executable
[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)-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 $(foreach exclude,$(EXCLUDE_DIRS),--exclude="$(exclude)") \
74 $(SDK_DIRS) $(KERNEL_FILES) | \
75 $(TAR) -xf - -C $(SDK_BUILD_DIR)
76
77 @-( \
78 find \
79 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/bin \
80 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/bin \
81 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/bin \
82 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/*/bin \
83 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/libexec \
84 -type f; \
85 find \
86 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/lib \
87 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/lib \
88 -type f -name \*.so\* -or -name \*.a; \
89 ) | xargs strip 2>/dev/null >/dev/null
90
91 mkdir -p $(SDK_BUILD_DIR)/target/linux
92 $(CP) $(GENERIC_PLATFORM_DIR) $(PLATFORM_DIR) $(SDK_BUILD_DIR)/target/linux/
93 rm -rf \
94 $(SDK_BUILD_DIR)/target/linux/*/files* \
95 $(SDK_BUILD_DIR)/target/linux/*/patches*
96 ./convert-config.pl $(TOPDIR)/.config > $(SDK_BUILD_DIR)/Config-build.in
97 $(CP) -L \
98 $(TOPDIR)/LICENSE \
99 $(TOPDIR)/rules.mk \
100 $(TOPDIR)/.config \
101 ./files/Config.in \
102 ./files/Makefile \
103 ./files/include/prepare.mk \
104 ./files/README.SDK \
105 $(SDK_BUILD_DIR)/
106 $(CP) \
107 $(TOPDIR)/package/Makefile \
108 $(SDK_BUILD_DIR)/package/
109
110 -rm -f $(SDK_BUILD_DIR)/feeds.conf.default
111 $(if $(BASE_FEED),echo "$(BASE_FEED)" > $(SDK_BUILD_DIR)/feeds.conf.default)
112 if [ -f $(TOPDIR)/feeds.conf ]; then \
113 cat $(TOPDIR)/feeds.conf >> $(SDK_BUILD_DIR)/feeds.conf.default; \
114 else \
115 cat $(TOPDIR)/feeds.conf.default >> $(SDK_BUILD_DIR)/feeds.conf.default; \
116 fi
117 $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(SDK_BUILD_DIR)/include/version.mk
118 $(SED) '/LINUX_VERMAGIC:=/ { s,unknown,$(LINUX_VERMAGIC),g }' $(SDK_BUILD_DIR)/include/kernel.mk
119 find $(SDK_BUILD_DIR) -name .git | $(XARGS) rm -rf
120 find $(SDK_BUILD_DIR) -name .svn | $(XARGS) rm -rf
121 find $(SDK_BUILD_DIR) -name CVS | $(XARGS) rm -rf
122 (cd $(BUILD_DIR); \
123 tar cfj $@ $(SDK_NAME); \
124 )
125
126 download:
127 prepare:
128 compile: $(BIN_DIR)/$(SDK_NAME).tar.bz2
129 install: compile
130
131 clean:
132 rm -rf $(SDK_BUILD_DIR) $(BIN_DIR)/$(SDK_NAME).tar.bz2