Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. # Makefile for libreCMC
  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. TOPDIR:=${CURDIR}
  9. LC_ALL:=C
  10. LANG:=C
  11. export TOPDIR LC_ALL LANG
  12. export LIBRECMC_VERBOSE=s
  13. all: help
  14. include $(TOPDIR)/include/host.mk
  15. ifneq ($(LIBRECMC_BUILD),1)
  16. override LIBRECMC_BUILD=1
  17. export LIBRECMC_BUILD
  18. endif
  19. include rules.mk
  20. include $(INCLUDE_DIR)/debug.mk
  21. include $(INCLUDE_DIR)/depends.mk
  22. include $(INCLUDE_DIR)/version.mk
  23. export REVISION
  24. define Helptext
  25. Available Commands:
  26. help: This help text
  27. info: Show a list of available target profiles
  28. clean: Remove images and temporary build files
  29. image: Build an image (see below for more information).
  30. Building images:
  31. By default 'make image' will create an image with the default
  32. target profile and package set. You can use the following parameters
  33. to change that:
  34. make image PROFILE="<profilename>" # override the default target profile
  35. make image PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages
  36. make image FILES="<path>" # include extra files from <path>
  37. make image BIN_DIR="<path>" # alternative output directory for the images
  38. endef
  39. $(eval $(call shexport,Helptext))
  40. help: FORCE
  41. echo "$$$(call shvar,Helptext)"
  42. # override variables from rules.mk
  43. PACKAGE_DIR:=$(TOPDIR)/packages
  44. OPKG:= \
  45. IPKG_NO_SCRIPT=1 \
  46. IPKG_TMP="$(TOPDIR)/tmp/ipkgtmp" \
  47. IPKG_INSTROOT="$(TARGET_DIR)" \
  48. IPKG_CONF_DIR="$(TOPDIR)/tmp" \
  49. IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
  50. $(STAGING_DIR_HOST)/bin/opkg \
  51. -f $(TOPDIR)/repositories.conf \
  52. --force-depends \
  53. --force-overwrite \
  54. --force-postinstall \
  55. --cache $(TOPDIR)/dl \
  56. --offline-root $(TARGET_DIR) \
  57. --add-dest root:/ \
  58. --add-arch all:100 \
  59. --add-arch $(ARCH_PACKAGES):200
  60. define Profile
  61. $(eval $(call Profile/Default))
  62. $(eval $(call Profile/$(1)))
  63. ifeq ($(USER_PROFILE),)
  64. USER_PROFILE:=$(1)
  65. endif
  66. $(1)_NAME:=$(NAME)
  67. $(1)_PACKAGES:=$(PACKAGES)
  68. PROFILE_LIST += \
  69. echo '$(1):'; [ -z '$(NAME)' ] || echo ' $(NAME)'; echo ' Packages: $(PACKAGES)';
  70. endef
  71. include $(INCLUDE_DIR)/target.mk
  72. _call_info: FORCE
  73. echo 'Current Target: "$(BOARD)$(if $(SUBTARGET), ($(BOARDNAME)))"'
  74. echo 'Default Packages: $(DEFAULT_PACKAGES)'
  75. echo 'Available Profiles:'
  76. echo; $(PROFILE_LIST)
  77. BUILD_PACKAGES:=$(sort $(DEFAULT_PACKAGES) $(USER_PACKAGES) $($(USER_PROFILE)_PACKAGES) kernel)
  78. # "-pkgname" in the package list means remove "pkgname" from the package list
  79. BUILD_PACKAGES:=$(filter-out $(filter -%,$(BUILD_PACKAGES)) $(patsubst -%,%,$(filter -%,$(BUILD_PACKAGES))),$(BUILD_PACKAGES))
  80. PACKAGES:=
  81. _call_image:
  82. echo 'Building images for $(BOARD)$(if $($(USER_PROFILE)_NAME), - $($(USER_PROFILE)_NAME))'
  83. echo 'Packages: $(BUILD_PACKAGES)'
  84. echo
  85. rm -rf $(TARGET_DIR)
  86. mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR)
  87. if [ ! -f "$(PACKAGE_DIR)/Packages" ] || [ ! -f "$(PACKAGE_DIR)/Packages.gz" ] || [ "`find $(PACKAGE_DIR) -cnewer $(PACKAGE_DIR)/Packages.gz`" ]; then \
  88. echo "Package list missing or not up-to-date, generating it.";\
  89. $(MAKE) package_index; \
  90. else \
  91. mkdir -p $(TARGET_DIR)/tmp; \
  92. $(OPKG) update; \
  93. fi
  94. $(MAKE) package_install
  95. ifneq ($(USER_FILES),)
  96. $(MAKE) copy_files
  97. endif
  98. $(MAKE) package_postinst
  99. $(MAKE) build_image
  100. package_index: FORCE
  101. @echo
  102. @echo Building package index...
  103. @mkdir -p $(TOPDIR)/tmp $(TOPDIR)/dl $(TARGET_DIR)/tmp
  104. (cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages && \
  105. gzip -9c Packages > Packages.gz \
  106. ) >/dev/null 2>/dev/null
  107. $(OPKG) update
  108. package_install: FORCE
  109. @echo
  110. @echo Installing packages...
  111. $(OPKG) install $(firstword $(wildcard $(PACKAGE_DIR)/libc_*.ipk $(PACKAGE_DIR)/base/libc_*.ipk))
  112. $(OPKG) install $(firstword $(wildcard $(PACKAGE_DIR)/kernel_*.ipk $(PACKAGE_DIR)/base/kernel_*.ipk))
  113. $(OPKG) install $(BUILD_PACKAGES)
  114. rm -f $(TARGET_DIR)/usr/lib/opkg/lists/*
  115. copy_files: FORCE
  116. @echo
  117. @echo Copying extra files
  118. @$(call file_copy,$(USER_FILES)/*,$(TARGET_DIR)/)
  119. package_postinst: FORCE
  120. @echo
  121. @echo Cleaning up
  122. @rm -f $(TARGET_DIR)/tmp/opkg.lock
  123. @echo
  124. @echo Activating init scripts
  125. @mkdir -p $(TARGET_DIR)/etc/rc.d
  126. @( \
  127. cd $(TARGET_DIR); \
  128. for script in ./usr/lib/opkg/info/*.postinst; do \
  129. IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) $$script; \
  130. done || true \
  131. )
  132. rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.postinst
  133. $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
  134. build_image: FORCE
  135. @echo
  136. @echo Building images...
  137. $(NO_TRACE_MAKE) -C target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 \
  138. $(if $(USER_PROFILE),PROFILE="$(USER_PROFILE)")
  139. clean:
  140. rm -rf $(TOPDIR)/tmp $(TOPDIR)/dl $(TARGET_DIR) $(BIN_DIR)
  141. info:
  142. (unset PROFILE FILES PACKAGES MAKEFLAGS; $(MAKE) -s _call_info)
  143. image:
  144. (unset PROFILE FILES PACKAGES MAKEFLAGS; \
  145. $(MAKE) _call_image \
  146. $(if $(PROFILE),USER_PROFILE="$(PROFILE)") \
  147. $(if $(FILES),USER_FILES="$(FILES)") \
  148. $(if $(PACKAGES),USER_PACKAGES="$(PACKAGES)") \
  149. $(if $(BIN_DIR),BIN_DIR="$(BIN_DIR)"))
  150. .SILENT: help info image