Makefile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # Makefile for OpenWrt
  2. #
  3. # Copyright (C) 2007-2010 OpenWrt.org
  4. #
  5. # This is free software, licensed under the GNU General Public License v2.
  6. # See /LICENSE for more information.
  7. #
  8. GLUONDIR:=${CURDIR}/..
  9. include ${CURDIR}/gluon.mk
  10. TOPDIR:=$(GLUON_OPENWRTDIR)
  11. LC_ALL:=C
  12. LANG:=C
  13. export TOPDIR LC_ALL LANG
  14. export OPENWRT_VERBOSE=s
  15. all: image
  16. include $(TOPDIR)/include/host.mk
  17. ifneq ($(OPENWRT_BUILD),1)
  18. override OPENWRT_BUILD=1
  19. export OPENWRT_BUILD
  20. endif
  21. include rules.mk
  22. include $(INCLUDE_DIR)/debug.mk
  23. include $(INCLUDE_DIR)/depends.mk
  24. include $(INCLUDE_DIR)/version.mk
  25. REVISION:=$(shell $(GLUON_BUILDERDIR)/openwrt_rev.sh $(GLUONDIR))
  26. export REVISION
  27. include $(INCLUDE_DIR)/package-ipkg.mk
  28. # override variables from rules.mk
  29. OPKG:= \
  30. IPKG_TMP="$(TOPDIR)/tmp/ipkgtmp" \
  31. IPKG_INSTROOT="$(TARGET_DIR)" \
  32. IPKG_CONF_DIR="$(TOPDIR)/tmp" \
  33. IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
  34. $(STAGING_DIR_HOST)/bin/opkg \
  35. -f $(GLUONDIR)/build/opkg-$(BOARD).conf \
  36. --force-depends \
  37. --force-overwrite \
  38. --force-postinstall \
  39. --cache $(TOPDIR)/dl \
  40. --offline-root $(TARGET_DIR) \
  41. --add-dest root:/ \
  42. --add-arch all:100 \
  43. --add-arch $(ARCH_PACKAGES):200
  44. define Profile
  45. $(eval $(call Profile/Default))
  46. $(eval $(call Profile/$(1)))
  47. ifeq ($(USER_PROFILE),)
  48. USER_PROFILE:=$(1)
  49. endif
  50. $(1)_NAME:=$(NAME)
  51. $(1)_PACKAGES:=$(PACKAGES)
  52. endef
  53. include $(INCLUDE_DIR)/target.mk
  54. BUILD_PACKAGES:=$(sort $(DEFAULT_PACKAGES) $(USER_PACKAGES) $($(USER_PROFILE)_PACKAGES) kernel)
  55. # "-pkgname" in the package list means remove "pkgname" from the package list
  56. BUILD_PACKAGES:=$(filter-out $(filter -%,$(BUILD_PACKAGES)) $(patsubst -%,%,$(filter -%,$(BUILD_PACKAGES))),$(BUILD_PACKAGES))
  57. PACKAGES:=
  58. include $(INCLUDE_DIR)/kernel-build.mk
  59. kernel: FORCE
  60. $(Kernel/CompileImage)
  61. _call_image:
  62. echo 'Building images for $(BOARD)$(if $($(USER_PROFILE)_NAME), - $($(USER_PROFILE)_NAME))'
  63. echo 'Packages: $(BUILD_PACKAGES)'
  64. echo
  65. rm -rf $(TARGET_DIR)
  66. mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR)
  67. if [ ! -f "$(PACKAGE_DIR)/Packages" ] || [ ! -f "$(PACKAGE_DIR)/Packages.gz" ] || [ "`find $(PACKAGE_DIR) -cnewer $(PACKAGE_DIR)/Packages.gz`" ]; then \
  68. echo "Package list missing or not up-to-date, generating it.";\
  69. $(MAKE) package_index; \
  70. else \
  71. mkdir -p $(TARGET_DIR)/tmp; \
  72. $(OPKG) update; \
  73. fi
  74. $(MAKE) package_install
  75. ifneq ($(USER_FILES),)
  76. $(MAKE) copy_files
  77. endif
  78. $(MAKE) package_postinst
  79. $(MAKE) build_image
  80. package_index: FORCE
  81. @echo
  82. @echo Building package index...
  83. @mkdir -p $(TOPDIR)/tmp $(TOPDIR)/dl $(TARGET_DIR)/tmp
  84. (cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages && \
  85. gzip -9c Packages > Packages.gz \
  86. ) >/dev/null 2>/dev/null
  87. $(OPKG) update
  88. package_install: FORCE
  89. @echo
  90. @echo Installing packages...
  91. $(OPKG) install $(PACKAGE_DIR)/libc_*.ipk
  92. $(OPKG) install $(PACKAGE_DIR)/kernel_*.ipk
  93. $(OPKG) install $(BUILD_PACKAGES)
  94. rm -f $(TARGET_DIR)/usr/lib/opkg/lists/*
  95. copy_files: FORCE
  96. @echo
  97. @echo Copying extra files
  98. @( cd $(USER_FILES); find -type f ) | \
  99. ( cd $(TARGET_DIR); while :; do \
  100. read FILE; \
  101. [ -z "$$FILE" ] && break; \
  102. [ -L "$$FILE" ] || continue; \
  103. echo "Removing symlink $(TARGET_DIR)/$$FILE"; \
  104. rm -f "$$FILE"; \
  105. done; )
  106. $(CP) $(USER_FILES)/* $(TARGET_DIR)/
  107. package_postinst: FORCE
  108. @echo
  109. @echo Cleaning up
  110. @rm -f $(TARGET_DIR)/tmp/opkg.lock
  111. @echo
  112. @echo Activating init scripts
  113. @( \
  114. cd $(TARGET_DIR); \
  115. for script in ./etc/init.d/*; do \
  116. grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
  117. IPKG_INSTROOT=$(TARGET_DIR) $(which bash) ./etc/rc.common $$script enable; \
  118. done || true; \
  119. )
  120. $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
  121. build_image: FORCE
  122. @echo
  123. @echo Building images...
  124. $(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD)/image install TARGET_BUILD=1 IMG_PREFIX="gluon-$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))" \
  125. $(if $(USER_PROFILE),PROFILE="$(USER_PROFILE)")
  126. image:
  127. (unset PROFILE FILES PACKAGES MAKEFLAGS; \
  128. $(MAKE) _call_image \
  129. $(if $(PROFILE),USER_PROFILE="$(PROFILE)") \
  130. $(if $(FILES),USER_FILES="$(FILES)") \
  131. $(if $(PACKAGES),USER_PACKAGES="$(PACKAGES)") \
  132. BIN_DIR="$(GLUON_IMAGEDIR)" \
  133. $(if $(PACKAGE_DIR),PACKAGE_DIR="$(PACKAGE_DIR)"))
  134. .SILENT: kernel image