Makefile 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # Greatly modified OpenWRT Image Builder Makefile
  2. #
  3. # Copyright (C) 2007-2010 OpenWrt.org
  4. # Copyright (C) 2013 Project Gluon
  5. #
  6. # This is free software, licensed under the GNU General Public License v2.
  7. # See /LICENSE for more information.
  8. #
  9. all: image
  10. include ${CURDIR}/gluon.mk
  11. include $(TOPDIR)/include/host.mk
  12. include $(TOPDIR)/rules.mk
  13. PACKAGE_DIR := $(GLUON_OPENWRTDIR)/bin/$(BOARD)/packages
  14. BIN_DIR := $(GLUON_IMAGEDIR)/$(BOARD)/$(PROFILE)
  15. PROFILE_BUILDDIR := $(BOARD_BUILDDIR)/$(PROFILE)
  16. PROFILE_KDIR := $(PROFILE_BUILDDIR)/kernel
  17. TMP_DIR := $(PROFILE_BUILDDIR)/tmp
  18. TARGET_DIR := $(PROFILE_BUILDDIR)/root
  19. include $(INCLUDE_DIR)/debug.mk
  20. include $(INCLUDE_DIR)/depends.mk
  21. include $(INCLUDE_DIR)/version.mk
  22. REVISION:=$(shell $(GLUON_BUILDERDIR)/openwrt_rev.sh $(GLUONDIR))
  23. export REVISION
  24. include $(INCLUDE_DIR)/package-ipkg.mk
  25. # override variables from rules.mk
  26. OPKG:= \
  27. IPKG_TMP="$(TMP_DIR)/ipkgtmp" \
  28. IPKG_INSTROOT="$(TARGET_DIR)" \
  29. IPKG_CONF_DIR="$(TMP_DIR)" \
  30. IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
  31. $(STAGING_DIR_HOST)/bin/opkg \
  32. -f $(BOARD_BUILDDIR)/opkg.conf \
  33. --force-depends \
  34. --force-overwrite \
  35. --force-postinstall \
  36. --cache $(TMP_DIR)/dl \
  37. --offline-root $(TARGET_DIR) \
  38. --add-dest root:/ \
  39. --add-arch all:100 \
  40. --add-arch $(ARCH_PACKAGES):200
  41. define Profile
  42. $(eval $(call Profile/Default))
  43. $(eval $(call Profile/$(1)))
  44. ifeq ($(PROFILE),)
  45. PROFILE:=$(1)
  46. endif
  47. $(1)_NAME:=$(NAME)
  48. $(1)_PACKAGES:=$(PACKAGES)
  49. endef
  50. include $(INCLUDE_DIR)/target.mk
  51. define GluonProfile
  52. GLUON_$(1)_DEFAULT_PACKAGES := $(2)
  53. endef
  54. include $(GLUONDIR)/profiles.mk
  55. # Generate Gluon package list
  56. $(eval $(call merge-lists,GLUON_PACKAGES,GLUON_DEFAULT_PACKAGES GLUON_SITE_PACKAGES GLUON_$(PROFILE)_DEFAULT_PACKAGES GLUON_$(PROFILE)_SITE_PACKAGES))
  57. include $(INCLUDE_DIR)/image.mk
  58. define EnableInitscript
  59. ( \
  60. grep '#!/bin/sh /etc/rc.common' $(1) >/dev/null && \
  61. IPKG_INSTROOT=$(TARGET_DIR) $(which bash) ./etc/rc.common $(1) enable || \
  62. true \
  63. )
  64. endef
  65. define FileOrigin
  66. $(firstword $(shell $(OPKG) search $(1)))
  67. endef
  68. enable_initscripts: FORCE
  69. cd $(TARGET_DIR) && ( \
  70. $(foreach script,$(wildcard $(TARGET_DIR)/etc/init.d/*), \
  71. $(if $(filter $(ENABLE_INITSCRIPTS_FROM),$(call FileOrigin,$(script))),$(call EnableInitscript,$(script));) \
  72. ) : \
  73. )
  74. package_install: FORCE
  75. $(OPKG) update
  76. $(OPKG) install $(PACKAGE_DIR)/libc_*.ipk
  77. $(OPKG) install $(PACKAGE_DIR)/kernel_*.ipk
  78. $(OPKG) install $(DEFAULT_PACKAGES) $($(PROFILE)_PACKAGES)
  79. $(NO_TRACE_MAKE) enable_initscripts ENABLE_INITSCRIPTS_FROM=%
  80. $(OPKG) install $(GLUON_PACKAGES)
  81. $(NO_TRACE_MAKE) enable_initscripts ENABLE_INITSCRIPTS_FROM="$(GLUON_PACKAGES)"
  82. rm -f $(TARGET_DIR)/usr/lib/opkg/lists/* $(TARGET_DIR)/tmp/opkg.lock
  83. image: FORCE
  84. rm -rf $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(PROFILE_KDIR)
  85. mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(TARGET_DIR)/tmp
  86. cp -r $(BOARD_KDIR) $(PROFILE_KDIR)
  87. $(NO_TRACE_MAKE) package_install
  88. $(call Image/mkfs/prepare)
  89. $(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 IMG_PREFIX="gluon-$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))" \
  90. PROFILE="$(PROFILE)" KDIR="$(PROFILE_KDIR)" TARGET_DIR="$(TARGET_DIR)" BIN_DIR="$(BIN_DIR)" TMP_DIR="$(TMP_DIR)"