Makefile 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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)/host.mk
  10. include $(INCLUDE_DIR)/version.mk
  11. include $(INCLUDE_DIR)/feeds.mk
  12. override MAKEFLAGS=
  13. IB_NAME:=$(VERSION_DIST_SANITIZED)-imagebuilder-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET)).$(HOST_OS)-$(HOST_ARCH)
  14. PKG_BUILD_DIR:=$(BUILD_DIR)/$(IB_NAME)
  15. IB_KDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(KERNEL_BUILD_DIR))
  16. IB_LDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR))
  17. IB_DTSDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR))/arch/$(ARCH)/boot/dts/
  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) $(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. -cp $(KERNEL_BUILD_DIR)/* $(IB_KDIR)/ # don't copy subdirectories here
  58. -cp $(LINUX_DIR)/.config $(IB_LDIR)/
  59. rm -f $(IB_KDIR)/root.*
  60. rm -f $(IB_KDIR)/vmlinux.debug
  61. if [ -x $(LINUX_DIR)/scripts/dtc/dtc ]; then \
  62. $(INSTALL_DIR) $(IB_LDIR)/scripts/dtc; \
  63. $(INSTALL_BIN) $(LINUX_DIR)/scripts/dtc/dtc $(IB_LDIR)/scripts/dtc/dtc; \
  64. fi
  65. if [ -d $(LINUX_DIR)/arch/$(ARCH)/boot/dts ]; then \
  66. $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/* $(IB_DTSDIR); \
  67. fi
  68. $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(PKG_BUILD_DIR)/include/version.mk
  69. find $(PKG_BUILD_DIR) -name CVS -o -name .git -o -name .svn \
  70. | $(XARGS) rm -rf
  71. $(INSTALL_DIR) $(PKG_BUILD_DIR)/staging_dir/host/bin
  72. $(CP) $(STAGING_DIR_HOST)/bin/* $(PKG_BUILD_DIR)/staging_dir/host/bin/
  73. (cd $(PKG_BUILD_DIR); find staging_dir/host/bin/ $(IB_LDIR)/scripts/dtc/ -type f | \
  74. $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(PKG_BUILD_DIR)/staging_dir/host)
  75. STRIP=sstrip $(SCRIPT_DIR)/rstrip.sh $(PKG_BUILD_DIR)/staging_dir/host/bin/
  76. $(TAR) -cf - -C $(BUILD_DIR) $(IB_NAME) | xz -zc -7e > $@
  77. download:
  78. prepare:
  79. compile: $(BIN_DIR)/$(IB_NAME).tar.xz
  80. install: compile
  81. clean: FORCE
  82. rm -rf $(PKG_BUILD_DIR) $(BIN_DIR)/$(IB_NAME).tar.xz