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