Makefile 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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}/../include/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 $(GLUONDIR)/scripts/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)/include/profiles.mk
  55. # Generate package list s
  56. $(eval $(call merge-lists,BASE_PACKAGES,DEFAULT_PACKAGES $(PROFILE)_PACKAGES))
  57. $(eval $(call merge-lists,GLUON_PACKAGES,GLUON_DEFAULT_PACKAGES GLUON_SITE_PACKAGES GLUON_$(PROFILE)_DEFAULT_PACKAGES GLUON_$(PROFILE)_SITE_PACKAGES))
  58. include $(INCLUDE_DIR)/image.mk
  59. EnableInitscript = ! grep -q '\#!/bin/sh /etc/rc.common' $(1) || bash ./etc/rc.common $(1) enable
  60. FileOrigin = $(firstword $(shell $(OPKG) search $(1)))
  61. enable_initscripts: FORCE
  62. cd $(TARGET_DIR) && ( export IPKG_INSTROOT=$(TARGET_DIR); \
  63. $(foreach script,$(wildcard $(TARGET_DIR)/etc/init.d/*), \
  64. $(if $(filter $(ENABLE_INITSCRIPTS_FROM),$(call FileOrigin,$(script))),$(call EnableInitscript,$(script));) \
  65. ) : \
  66. )
  67. package_install: FORCE
  68. $(OPKG) update
  69. $(OPKG) install $(PACKAGE_DIR)/libc_*.ipk
  70. $(OPKG) install $(PACKAGE_DIR)/kernel_*.ipk
  71. $(OPKG) install $(BASE_PACKAGES)
  72. $(NO_TRACE_MAKE) enable_initscripts ENABLE_INITSCRIPTS_FROM=%
  73. $(OPKG) install $(GLUON_PACKAGES)
  74. $(NO_TRACE_MAKE) enable_initscripts ENABLE_INITSCRIPTS_FROM="$(GLUON_PACKAGES)"
  75. rm -f $(TARGET_DIR)/usr/lib/opkg/lists/* $(TARGET_DIR)/tmp/opkg.lock
  76. image: FORCE
  77. rm -rf $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(PROFILE_KDIR)
  78. mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(TARGET_DIR)/tmp
  79. cp -r $(BOARD_KDIR) $(PROFILE_KDIR)
  80. $(NO_TRACE_MAKE) package_install
  81. $(call Image/mkfs/prepare)
  82. $(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 IMG_PREFIX="gluon-$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))" \
  83. PROFILE="$(PROFILE)" KDIR="$(PROFILE_KDIR)" TARGET_DIR="$(TARGET_DIR)" BIN_DIR="$(BIN_DIR)" TMP_DIR="$(TMP_DIR)"