1
0

Makefile 3.9 KB

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