kernel: Copy patches from kernel 4.14 to 4.19
[openwrt/staging/chunkeey.git] / target / imagebuilder / Makefile
1 #
2 # Copyright (C) 2006-2015 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)/version.mk
11 include $(INCLUDE_DIR)/feeds.mk
12
13 override MAKEFLAGS=
14
15 IB_NAME:=$(VERSION_DIST_SANITIZED)-imagebuilder-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET)).$(HOST_OS)-$(HOST_ARCH)
16 PKG_BUILD_DIR:=$(BUILD_DIR)/$(IB_NAME)
17 IB_KDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(KERNEL_BUILD_DIR))
18 IB_LDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR))
19 IB_DTSDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR))/arch/$(LINUX_KARCH)/boot/dts/
20 IB_IDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(STAGING_DIR_IMAGE))
21
22 all: compile
23
24 $(BIN_DIR)/$(IB_NAME).tar.xz: clean
25 rm -rf $(PKG_BUILD_DIR)
26 mkdir -p $(IB_KDIR) $(IB_LDIR) $(PKG_BUILD_DIR)/staging_dir/host/lib \
27 $(PKG_BUILD_DIR)/target $(PKG_BUILD_DIR)/scripts $(IB_DTSDIR)
28 -cp $(TOPDIR)/.config $(PKG_BUILD_DIR)/.config
29 $(CP) -L \
30 $(INCLUDE_DIR) $(SCRIPT_DIR) \
31 $(TOPDIR)/rules.mk \
32 ./files/Makefile \
33 ./files/repositories.conf \
34 $(TMP_DIR)/.targetinfo \
35 $(TMP_DIR)/.packageinfo \
36 $(PKG_BUILD_DIR)/
37
38 ifeq ($(CONFIG_IB_STANDALONE),)
39 echo '## Remote package repositories' >> $(PKG_BUILD_DIR)/repositories.conf
40 $(call FeedSourcesAppend,$(PKG_BUILD_DIR)/repositories.conf)
41 endif
42
43 echo '' >> $(PKG_BUILD_DIR)/repositories.conf
44 echo '## This is the local package repository, do not remove!' >> $(PKG_BUILD_DIR)/repositories.conf
45 echo 'src imagebuilder file:packages' >> $(PKG_BUILD_DIR)/repositories.conf
46
47 $(VERSION_SED_SCRIPT) $(PKG_BUILD_DIR)/repositories.conf
48
49 ifeq ($(CONFIG_IB_STANDALONE),)
50 (cd $(call FeedPackageDir,libc); $(FIND) -type f -name 'libc_*.ipk' -or -name 'kernel_*.ipk' -or -name 'kmod-*.ipk') | \
51 while read path; do \
52 mkdir -p "$(PKG_BUILD_DIR)/packages/$${path%/*}"; \
53 cp "$(call FeedPackageDir,libc)/$$path" "$(PKG_BUILD_DIR)/packages/$$path"; \
54 done
55 else
56 $(INSTALL_DIR) $(PKG_BUILD_DIR)/packages
57 find $(wildcard $(PACKAGE_SUBDIRS)) -type f -name '*.ipk' -exec $(CP) {} $(PKG_BUILD_DIR)/packages/ \;
58 endif
59
60 $(CP) $(TOPDIR)/target/linux $(PKG_BUILD_DIR)/target/
61 if [ -d $(TOPDIR)/staging_dir/host/lib/grub ]; then \
62 $(CP) $(TOPDIR)/staging_dir/host/lib/grub/ $(PKG_BUILD_DIR)/staging_dir/host/lib; \
63 fi
64 rm -rf \
65 $(PKG_BUILD_DIR)/target/linux/*/files{,-*} \
66 $(PKG_BUILD_DIR)/target/linux/*/patches{,-*} \
67 $(PKG_BUILD_DIR)/target/linux/generic/{pending,backport,hack}{,-*}
68 -cp $(KERNEL_BUILD_DIR)/* $(IB_KDIR)/ # don't copy subdirectories here
69 -cp $(LINUX_DIR)/.config $(IB_LDIR)/
70 rm -f $(IB_KDIR)/root.*
71 rm -f $(IB_KDIR)/vmlinux.debug
72 if [ -x $(LINUX_DIR)/scripts/dtc/dtc ]; then \
73 $(INSTALL_DIR) $(IB_LDIR)/scripts/dtc; \
74 $(INSTALL_BIN) $(LINUX_DIR)/scripts/dtc/dtc $(IB_LDIR)/scripts/dtc/dtc; \
75 fi
76 if [ -d $(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/dts ]; then \
77 $(CP) -L $(LINUX_DIR)/arch/$(LINUX_KARCH)/boot/dts/* $(IB_DTSDIR); \
78 fi
79 $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(PKG_BUILD_DIR)/include/version.mk
80 find $(PKG_BUILD_DIR) -name CVS -o -name .git -o -name .svn \
81 | $(XARGS) rm -rf
82 $(INSTALL_DIR) $(IB_IDIR)
83 -$(CP) $(STAGING_DIR_IMAGE)/* $(IB_IDIR)/
84 $(INSTALL_DIR) $(PKG_BUILD_DIR)/staging_dir/host/bin
85 $(CP) $(STAGING_DIR_HOST)/bin/* $(PKG_BUILD_DIR)/staging_dir/host/bin/
86 (cd $(PKG_BUILD_DIR); find staging_dir/host/bin/ $(IB_LDIR)/scripts/dtc/ -type f | \
87 $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(PKG_BUILD_DIR)/staging_dir/host)
88 STRIP=sstrip $(SCRIPT_DIR)/rstrip.sh $(PKG_BUILD_DIR)/staging_dir/host/bin/
89 $(TAR) -cf - -C $(BUILD_DIR) $(IB_NAME) | xz -zc -7e > $@
90
91 download:
92 prepare:
93 compile: $(BIN_DIR)/$(IB_NAME).tar.xz
94 install: compile
95
96 clean: FORCE
97 rm -rf $(PKG_BUILD_DIR) $(BIN_DIR)/$(IB_NAME).tar.xz