Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #
  2. # Copyright (C) 2006-2012 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. override MAKEFLAGS=
  12. PKG_OS:=$(word 2,$(subst -, ,$(shell $(HOSTCC) -dumpmachine)))
  13. PKG_CPU:=$(word 1,$(subst -, ,$(shell $(HOSTCC) -dumpmachine)))
  14. IB_NAME:=libreCMC-ImageBuilder-$(BOARD)$(if $(SUBTARGET),_$(SUBTARGET))-for-$(PKG_OS)-$(PKG_CPU)
  15. PKG_BUILD_DIR:=$(BUILD_DIR)/$(IB_NAME)
  16. IB_KDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(KERNEL_BUILD_DIR))
  17. IB_LDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR))
  18. IB_DTSDIR:=$(patsubst $(TOPDIR)/%,$(PKG_BUILD_DIR)/%,$(LINUX_DIR))/arch/$(ARCH)/boot/dts/
  19. all: compile
  20. $(BIN_DIR)/$(IB_NAME).tar.bz2: 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) \
  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. $(VERSION_SED) $(PKG_BUILD_DIR)/repositories.conf
  34. $(CP) $(PACKAGE_DIR) $(PKG_BUILD_DIR)/packages
  35. $(CP) $(TOPDIR)/target/linux $(PKG_BUILD_DIR)/target/
  36. if [ -d $(TOPDIR)/staging_dir/host/lib/grub ]; then \
  37. $(CP) $(TOPDIR)/staging_dir/host/lib/grub/ $(PKG_BUILD_DIR)/staging_dir/host/lib; \
  38. fi
  39. rm -rf \
  40. $(PKG_BUILD_DIR)/target/linux/*/files{,-*} \
  41. $(PKG_BUILD_DIR)/target/linux/*/patches{,-*}
  42. -cp $(KERNEL_BUILD_DIR)/* $(IB_KDIR)/ # don't copy subdirectories here
  43. -cp $(LINUX_DIR)/.config $(IB_LDIR)/
  44. -$(SCRIPT_DIR)/bundle-libraries.sh $(IB_LDIR)/scripts/dtc \
  45. $(LINUX_DIR)/scripts/dtc/dtc
  46. if [ -d $(LINUX_DIR)/arch/$(ARCH)/boot/dts ]; then \
  47. $(CP) $(LINUX_DIR)/arch/$(ARCH)/boot/dts/* $(IB_DTSDIR); \
  48. fi
  49. $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(PKG_BUILD_DIR)/include/version.mk
  50. find $(PKG_BUILD_DIR) -name CVS -o -name .git -o -name .svn \
  51. | $(XARGS) rm -rf
  52. find $(STAGING_DIR_HOST)/bin -maxdepth 1 -type f -perm -u=x \
  53. | $(XARGS) $(SCRIPT_DIR)/bundle-libraries.sh $(PKG_BUILD_DIR)/staging_dir/host/bin
  54. $(MAKE) -C $(PKG_BUILD_DIR) package_index
  55. $(TAR) c -C $(BUILD_DIR) $(IB_NAME) | bzip2 -c > $@
  56. download:
  57. prepare:
  58. compile: $(BIN_DIR)/$(IB_NAME).tar.bz2
  59. install: compile
  60. clean: FORCE
  61. rm -rf $(PKG_BUILD_DIR) $(BIN_DIR)/$(IB_NAME).tar.bz2