rules.mk 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # invoke ipkg with configuration in $(STAGING_DIR)/etc/ipkg.conf
  2. IPKG := IPKG_INSTROOT=$(TARGET_DIR) IPKG_CONF_DIR=$(STAGING_DIR)/etc $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
  3. IPKG_STATE_DIR := $(TARGET_DIR)/usr/lib/ipkg
  4. # invoke ipkg-build with some default options
  5. IPKG_BUILD := PATH="$(TARGET_PATH)" ipkg-build -c -o root -g root
  6. # where to build (and put) .ipk packages
  7. IPKG_TARGET_DIR := $(PACKAGE_DIR)
  8. ifneq ($(DUMP),)
  9. dump:
  10. .PHONY: dump
  11. endif
  12. define PKG_template
  13. IPKG_$(1):=$(PACKAGE_DIR)/$(2)_$(3)_$(4).ipk
  14. IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(2)
  15. INFO_$(1):=$(IPKG_STATE_DIR)/info/$(2).list
  16. ifneq ($(BR2_PACKAGE_$(1)),)
  17. compile-targets: $$(IPKG_$(1))
  18. endif
  19. ifneq ($(DEVELOPER)$(SDK),)
  20. compile-targets: $$(IPKG_$(1))
  21. endif
  22. ifeq ($(BR2_PACKAGE_$(1)),y)
  23. install-targets: $$(INFO_$(1))
  24. endif
  25. IDEPEND_$(1):=$$(strip $(5))
  26. $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.prepared
  27. $(SCRIPT_DIR)/make-ipkg-dir.sh $$(IDIR_$(1)) ./ipkg/$(2).control $(3) $(4)
  28. if [ "$$(IDEPEND_$(1))" != "" ]; then echo "Depends: $$(IDEPEND_$(1))" >> $$(IDIR_$(1))/CONTROL/control; fi
  29. for file in conffiles preinst postinst prerm postrm; do \
  30. [ -f ./ipkg/$(2).$$$$file ] && cp ./ipkg/$(2).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file || true; \
  31. done
  32. $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $(PKG_BUILD_DIR)/.built $(PACKAGE_DIR)
  33. $$(INFO_$(1)): $$(IPKG_$(1))
  34. $(IPKG) install $$(IPKG_$(1))
  35. $(2)-clean:
  36. rm -f $$(IPKG_$(1))
  37. clean-targets: $(2)-clean
  38. endef
  39. ifeq ($(DUMP),)
  40. ifneq ($(strip $(PKG_SOURCE)),)
  41. $(DL_DIR)/$(PKG_SOURCE):
  42. $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
  43. endif
  44. ifneq ($(strip $(PKG_CAT)),)
  45. $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
  46. rm -rf $(PKG_BUILD_DIR)
  47. mkdir -p $(PKG_BUILD_DIR)
  48. $(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS)
  49. if [ -d ./patches ]; then \
  50. $(PATCH) $(PKG_BUILD_DIR) ./patches ; \
  51. fi
  52. touch $(PKG_BUILD_DIR)/.prepared
  53. endif
  54. all: compile
  55. compile-targets:
  56. install-targets:
  57. clean-targets:
  58. source: $(DL_DIR)/$(PKG_SOURCE)
  59. prepare: $(PKG_BUILD_DIR)/.prepared
  60. compile: compile-targets
  61. install: install-targets
  62. mostlyclean:
  63. rebuild:
  64. -$(MAKE) mostlyclean
  65. if [ -f $(PKG_BUILD_DIR)/.built ]; then \
  66. $(MAKE) clean; \
  67. fi
  68. $(MAKE) compile
  69. $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
  70. $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
  71. $(PACKAGE_DIR):
  72. mkdir -p $@
  73. clean: clean-targets
  74. rm -rf $(PKG_BUILD_DIR)
  75. .PHONY: all source prepare compile install clean
  76. endif