gre: add gre specific settings as nested json object
[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)/version.mk
12
13 override MAKEFLAGS=
14
15 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)
16 SDK_BUILD_DIR:=$(BUILD_DIR)/$(SDK_NAME)
17
18 STAGING_SUBDIR_HOST := staging_dir/host
19 STAGING_SUBDIR_TARGET := staging_dir/$(TARGET_DIR_NAME)
20 STAGING_SUBDIR_TOOLCHAIN := staging_dir/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)_$(LIBC)$(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 */share/locale
34
35 SDK_DIRS = \
36 $(STAGING_SUBDIR_HOST) \
37 $(STAGING_SUBDIR_TOOLCHAIN)
38
39 GIT_URL:=$(filter git://% http://% https://%,$(shell git config --get remote.origin.url 2>/dev/null))
40 GIT_COMMIT:=$(shell git rev-parse HEAD 2>/dev/null)
41 GIT_BRANCH:=$(filter-out master HEAD,$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null))
42 GIT_TAGNAME:=$(shell git show-ref --tags --dereference 2>/dev/null | sed -ne '/^$(GIT_COMMIT) / { s|^.*/||; s|\^.*||; p }')
43
44 BASE_FEED:=$(if $(GIT_URL),src-git base $(GIT_URL)$(if $(GIT_BRANCH),;$(GIT_BRANCH),$(if $(GIT_TAGNAME),;$(GIT_TAGNAME))))
45 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'))
46 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'))
47 BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),src-git base https://git.lede-project.org/source.git$(if $(GIT_BRANCH),;$(GIT_BRANCH),$(if $(GIT_TAGNAME),;$(GIT_TAGNAME))))
48
49 KDIR_BASE = $(patsubst $(TOPDIR)/%,%,$(LINUX_DIR))
50
51 KERNEL_FILES_ARCH = \
52 Makefile* \
53 module.lds \
54 Kbuild.platforms \
55 */Platform \
56 include \
57 */include \
58 scripts \
59 kernel/asm-offsets.s
60
61 KERNEL_FILES_BASE := \
62 .config \
63 Makefile \
64 scripts \
65 include \
66 Module.symvers \
67 modules.builtin \
68 $(addprefix arch/$(LINUX_KARCH)/,$(KERNEL_FILES_ARCH))
69
70 KERNEL_FILES := $(patsubst $(TOPDIR)/%,%,$(wildcard $(addprefix $(LINUX_DIR)/,$(KERNEL_FILES_BASE))))
71
72 all: compile
73
74 $(BIN_DIR)/$(SDK_NAME).tar.xz: clean
75 mkdir -p $(SDK_BUILD_DIR)/dl $(SDK_BUILD_DIR)/package
76 $(CP) -L $(INCLUDE_DIR) $(SCRIPT_DIR) $(SDK_BUILD_DIR)/
77 $(TAR) -cf - -C $(TOPDIR) \
78 `cd $(TOPDIR); find $(KDIR_BASE) -name \*.ko` \
79 `cd $(TOPDIR); find $(KDIR_BASE)/firmware/ -newer $(KDIR_BASE)/firmware/Makefile \
80 -type f -name '*.bin' -or -name '*.cis' -or -name '*.csp' -or -name '*.dsp' -or -name '*.fw'` \
81 $(foreach exclude,$(EXCLUDE_DIRS),--exclude="$(exclude)") \
82 $(SDK_DIRS) $(KERNEL_FILES) | \
83 $(TAR) -xf - -C $(SDK_BUILD_DIR)
84
85 (cd $(SDK_BUILD_DIR); find $(STAGING_SUBDIR_HOST)/bin $(STAGING_SUBDIR_HOST)/usr/bin \
86 $(STAGING_SUBDIR_TOOLCHAIN)/bin $(STAGING_SUBDIR_TOOLCHAIN)/*/bin $(STAGING_SUBDIR_TOOLCHAIN)/libexec \
87 -type f | $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST))
88
89 @-( \
90 find \
91 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/bin \
92 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/bin \
93 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/bin \
94 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/*/bin \
95 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/libexec \
96 -type f; \
97 find \
98 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/lib \
99 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/usr/lib \
100 -type f -name \*.so\*; \
101 ) | xargs strip 2>/dev/null >/dev/null
102
103 mkdir -p $(SDK_BUILD_DIR)/target/linux
104 $(CP) $(GENERIC_PLATFORM_DIR) $(PLATFORM_DIR) $(SDK_BUILD_DIR)/target/linux/
105 rm -rf \
106 $(SDK_BUILD_DIR)/target/linux/*/files* \
107 $(SDK_BUILD_DIR)/target/linux/*/patches*
108 ./convert-config.pl $(TOPDIR)/.config > $(SDK_BUILD_DIR)/Config-build.in
109 $(CP) -L \
110 $(TOPDIR)/LICENSE \
111 $(TOPDIR)/rules.mk \
112 ./files/Config.in \
113 ./files/Makefile \
114 ./files/include/prepare.mk \
115 ./files/README.SDK \
116 $(SDK_BUILD_DIR)/
117 $(CP) \
118 $(TOPDIR)/package/Makefile \
119 $(TOPDIR)/package/libs/toolchain \
120 $(TOPDIR)/package/kernel/linux \
121 $(SDK_BUILD_DIR)/package/
122
123 -rm -rf \
124 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_HOST)/ccache \
125 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TARGET)/ccache \
126 $(SDK_BUILD_DIR)/$(STAGING_SUBDIR_TOOLCHAIN)/ccache
127
128 -rm -f $(SDK_BUILD_DIR)/feeds.conf.default
129 $(if $(BASE_FEED),echo "$(BASE_FEED)" > $(SDK_BUILD_DIR)/feeds.conf.default)
130 if [ -f $(TOPDIR)/feeds.conf ]; then \
131 cat $(TOPDIR)/feeds.conf >> $(SDK_BUILD_DIR)/feeds.conf.default; \
132 else \
133 cat $(TOPDIR)/feeds.conf.default >> $(SDK_BUILD_DIR)/feeds.conf.default; \
134 fi
135 $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(SDK_BUILD_DIR)/include/version.mk
136 $(SED) 's,^# SOURCE_DATE_EPOCH:=.*,SOURCE_DATE_EPOCH:=$(SOURCE_DATE_EPOCH),g' $(SDK_BUILD_DIR)/include/version.mk
137 $(SED) '/LINUX_VERMAGIC:=/ { s,unknown,$(LINUX_VERMAGIC),g }' $(SDK_BUILD_DIR)/include/kernel.mk
138 find $(SDK_BUILD_DIR) -name .git | $(XARGS) rm -rf
139 find $(SDK_BUILD_DIR) -name .svn | $(XARGS) rm -rf
140 find $(SDK_BUILD_DIR) -name CVS | $(XARGS) rm -rf
141 -make -C $(SDK_BUILD_DIR)/scripts/config clean
142 (cd $(BUILD_DIR); \
143 tar -I 'xz -7e' -cf $@ $(SDK_NAME); \
144 )
145
146 download:
147 prepare:
148 compile: $(BIN_DIR)/$(SDK_NAME).tar.xz
149 install: compile
150
151 clean:
152 rm -rf $(SDK_BUILD_DIR) $(BIN_DIR)/$(SDK_NAME).tar.xz