1
0

Makefile 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. IB_IDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(STAGING_DIR_IMAGE))
  19. all: compile
  20. $(BIN_DIR)/$(IB_NAME).tar.xz: clean
  21. rm -rf $(PKG_BUILD_DIR)
  22. mkdir -p $(IB_KDIR) $(IB_LDIR) $(PKG_BUILD_DIR)/staging_dir/host/lib \
  23. $(PKG_BUILD_DIR)/target $(PKG_BUILD_DIR)/scripts $(IB_DTSDIR)
  24. -cp $(TOPDIR)/.config $(PKG_BUILD_DIR)/.config
  25. $(CP) -L \
  26. $(INCLUDE_DIR) $(SCRIPT_DIR) \
  27. $(TOPDIR)/rules.mk \
  28. ./files/Makefile \
  29. ./files/repositories.conf \
  30. $(TMP_DIR)/.targetinfo \
  31. $(TMP_DIR)/.packageinfo \
  32. $(PKG_BUILD_DIR)/
  33. ifeq ($(CONFIG_IB_STANDALONE),)
  34. echo '## Remote package repositories' >> $(PKG_BUILD_DIR)/repositories.conf
  35. $(call FeedSourcesAppend,$(PKG_BUILD_DIR)/repositories.conf)
  36. endif
  37. echo '' >> $(PKG_BUILD_DIR)/repositories.conf
  38. echo '## This is the local package repository, do not remove!' >> $(PKG_BUILD_DIR)/repositories.conf
  39. echo 'src imagebuilder file:packages' >> $(PKG_BUILD_DIR)/repositories.conf
  40. $(VERSION_SED) $(PKG_BUILD_DIR)/repositories.conf
  41. ifeq ($(CONFIG_IB_STANDALONE),)
  42. (cd $(call FeedPackageDir,libc); $(FIND) -type f -name 'libc_*.ipk' -or -name 'kernel_*.ipk' -or -name 'kmod-*.ipk') | \
  43. while read path; do \
  44. mkdir -p "$(PKG_BUILD_DIR)/packages/$${path%/*}"; \
  45. cp "$(call FeedPackageDir,libc)/$$path" "$(PKG_BUILD_DIR)/packages/$$path"; \
  46. done
  47. else
  48. $(INSTALL_DIR) $(PKG_BUILD_DIR)/packages
  49. find $(wildcard $(PACKAGE_SUBDIRS)) -type f -name '*.ipk' -exec $(CP) {} $(PKG_BUILD_DIR)/packages/ \;
  50. endif
  51. $(CP) $(TOPDIR)/target/linux $(PKG_BUILD_DIR)/target/
  52. if [ -d $(TOPDIR)/staging_dir/host/lib/grub ]; then \
  53. $(CP) $(TOPDIR)/staging_dir/host/lib/grub/ $(PKG_BUILD_DIR)/staging_dir/host/lib; \
  54. fi
  55. rm -rf \
  56. $(PKG_BUILD_DIR)/target/linux/*/files{,-*} \
  57. $(PKG_BUILD_DIR)/target/linux/*/patches{,-*}
  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) $(PKG_BUILD_DIR)/staging_dir/host/bin
  73. $(CP) $(STAGING_DIR_HOST)/bin/* $(PKG_BUILD_DIR)/staging_dir/host/bin/
  74. (cd $(PKG_BUILD_DIR); find staging_dir/host/bin/ $(IB_LDIR)/scripts/dtc/ -type f | \
  75. $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(PKG_BUILD_DIR)/staging_dir/host)
  76. STRIP=sstrip $(SCRIPT_DIR)/rstrip.sh $(PKG_BUILD_DIR)/staging_dir/host/bin/
  77. $(TAR) -cf - -C $(BUILD_DIR) $(IB_NAME) | xz -zc -7e > $@
  78. download:
  79. prepare:
  80. compile: $(BIN_DIR)/$(IB_NAME).tar.xz
  81. install: compile
  82. clean: FORCE
  83. rm -rf $(PKG_BUILD_DIR) $(BIN_DIR)/$(IB_NAME).tar.xz