Makefile 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. # Makefile for libreCMC
  2. #
  3. # Copyright (C) 2007-2015 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. export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
  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)/rootfs.mk
  23. include $(INCLUDE_DIR)/version.mk
  24. export REVISION
  25. define Helptext
  26. Available Commands:
  27. help: This help text
  28. info: Show a list of available target profiles
  29. clean: Remove images and temporary build files
  30. image: Build an image (see below for more information).
  31. Building images:
  32. By default 'make image' will create an image with the default
  33. target profile and package set. You can use the following parameters
  34. to change that:
  35. make image PROFILE="<profilename>" # override the default target profile
  36. make image PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages
  37. make image FILES="<path>" # include extra files from <path>
  38. make image BIN_DIR="<path>" # alternative output directory for the images
  39. make image EXTRA_IMAGE_NAME="<string>" # Add this to the output image filename (sanitized)
  40. make image DISABLED_SERVICES="<svc1> [<svc2> [<svc3> ..]]" # Which services in /etc/init.d/ should be disabled
  41. Print manifest:
  42. List "all" packages which get installed into the image.
  43. You can use the following parameters:
  44. make manifest PROFILE="<profilename>" # override the default target profile
  45. make manifest PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages
  46. endef
  47. $(eval $(call shexport,Helptext))
  48. help: FORCE
  49. echo "$$$(call shvar,Helptext)"
  50. # override variables from rules.mk
  51. PACKAGE_DIR:=$(TOPDIR)/packages
  52. LISTS_DIR:=$(subst $(space),/,$(patsubst %,..,$(subst /,$(space),$(TARGET_DIR))))$(DL_DIR)
  53. OPKG:=$(call opkg,$(TARGET_DIR)) \
  54. -f $(TOPDIR)/repositories.conf \
  55. --cache $(DL_DIR) \
  56. --lists-dir $(LISTS_DIR)
  57. include $(INCLUDE_DIR)/target.mk
  58. -include .profiles.mk
  59. USER_PROFILE ?= $(firstword $(PROFILE_NAMES))
  60. PROFILE_LIST = $(foreach p,$(PROFILE_NAMES), \
  61. echo '$(patsubst DEVICE_%,%,$(p)):'; $(if $($(p)_NAME),echo ' $(subst ','"'"',$($(p)_NAME))'; ) \
  62. echo ' Packages: $($(p)_PACKAGES)'; echo ' hasImageMetadata: $($(p)_HAS_IMAGE_METADATA)'; \
  63. $(if $($(p)_SUPPORTED_DEVICES),echo ' SupportedDevices: $($(p)_SUPPORTED_DEVICES)';) )
  64. .profiles.mk: .targetinfo
  65. @$(SCRIPT_DIR)/target-metadata.pl profile_mk $< '$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET))' > $@
  66. staging_dir/host/.prereq-build: include/prereq-build.mk
  67. mkdir -p tmp
  68. @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
  69. echo "Prerequisite check failed. Use FORCE=1 to override."; \
  70. false; \
  71. }
  72. ifneq ($(realpath $(TOPDIR)/include/prepare.mk),)
  73. @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prepare.mk prepare 2>/dev/null || { \
  74. echo "Preparation failed."; \
  75. false; \
  76. }
  77. endif
  78. touch $@
  79. _call_info: FORCE
  80. echo 'Current Target: "$(TARGETID)"'
  81. echo 'Current Revision: "$(REVISION)"'
  82. echo 'Default Packages: $(DEFAULT_PACKAGES)'
  83. echo 'Available Profiles:'
  84. echo; $(PROFILE_LIST)
  85. BUILD_PACKAGES:=$(USER_PACKAGES) $(sort $(DEFAULT_PACKAGES) $($(USER_PROFILE)_PACKAGES) kernel)
  86. # "-pkgname" in the package list means remove "pkgname" from the package list
  87. BUILD_PACKAGES:=$(filter-out $(filter -%,$(BUILD_PACKAGES)) $(patsubst -%,%,$(filter -%,$(BUILD_PACKAGES))),$(BUILD_PACKAGES))
  88. PACKAGES:=
  89. _call_image: staging_dir/host/.prereq-build
  90. echo 'Building images for $(BOARD)$(if $($(USER_PROFILE)_NAME), - $($(USER_PROFILE)_NAME))'
  91. echo 'Packages: $(BUILD_PACKAGES)'
  92. echo
  93. rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
  94. mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(DL_DIR)
  95. $(MAKE) package_reload
  96. $(MAKE) package_install
  97. $(MAKE) -s prepare_rootfs
  98. $(MAKE) -s build_image
  99. $(MAKE) -s checksum
  100. _call_manifest: FORCE
  101. rm -rf $(TARGET_DIR)
  102. mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(DL_DIR)
  103. $(MAKE) package_reload >/dev/null
  104. $(MAKE) package_install >/dev/null
  105. $(OPKG) list-installed
  106. package_index: FORCE
  107. @echo >&2
  108. @echo Building package index... >&2
  109. @mkdir -p $(TMP_DIR) $(TARGET_DIR)/tmp
  110. (cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages && \
  111. gzip -9nc Packages > Packages.gz \
  112. ) >/dev/null 2>/dev/null
  113. $(OPKG) update >&2 || true
  114. package_reload:
  115. if [ ! -f "$(PACKAGE_DIR)/Packages" ] || [ ! -f "$(PACKAGE_DIR)/Packages.gz" ] || [ "`find $(PACKAGE_DIR) -cnewer $(PACKAGE_DIR)/Packages.gz`" ]; then \
  116. echo "Package list missing or not up-to-date, generating it." >&2 ;\
  117. $(MAKE) package_index; \
  118. else \
  119. mkdir -p $(TARGET_DIR)/tmp; \
  120. $(OPKG) update >&2 || true; \
  121. fi
  122. package_list: FORCE
  123. @$(MAKE) -s package_reload
  124. @$(OPKG) list --size 2>/dev/null
  125. package_install: FORCE
  126. @echo
  127. @echo Installing packages...
  128. $(OPKG) install $(firstword $(wildcard $(PACKAGE_DIR)/libc_*.ipk $(PACKAGE_DIR)/base/libc_*.ipk))
  129. $(OPKG) install $(firstword $(wildcard $(PACKAGE_DIR)/kernel_*.ipk $(PACKAGE_DIR)/base/kernel_*.ipk))
  130. $(OPKG) install $(BUILD_PACKAGES)
  131. prepare_rootfs: FORCE
  132. @echo
  133. @echo Finalizing root filesystem...
  134. $(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
  135. $(call prepare_rootfs,$(TARGET_DIR),$(USER_FILES),$(DISABLED_SERVICES))
  136. build_image: FORCE
  137. @echo
  138. @echo Building images...
  139. $(NO_TRACE_MAKE) -C target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 EXTRA_IMAGE_NAME="$(EXTRA_IMAGE_NAME)" \
  140. $(if $(USER_PROFILE),PROFILE="$(USER_PROFILE)")
  141. checksum: FORCE
  142. @echo
  143. @echo Calculating checksums...
  144. @$(call sha256sums,$(BIN_DIR))
  145. clean:
  146. rm -rf $(TMP_DIR) $(DL_DIR) $(TARGET_DIR) $(BIN_DIR)
  147. info:
  148. (unset PROFILE FILES PACKAGES MAKEFLAGS; $(MAKE) -s _call_info)
  149. PROFILE_FILTER = $(filter DEVICE_$(PROFILE) $(PROFILE),$(PROFILE_NAMES))
  150. _check_profile: FORCE
  151. ifneq ($(PROFILE),)
  152. ifeq ($(PROFILE_FILTER),)
  153. @echo 'Profile "$(PROFILE)" does not exist!'
  154. @echo 'Use "make info" to get a list of available profile names.'
  155. @exit 1
  156. endif
  157. endif
  158. image:
  159. $(MAKE) -s _check_profile
  160. (unset PROFILE FILES PACKAGES MAKEFLAGS; \
  161. $(MAKE) -s _call_image \
  162. $(if $(PROFILE),USER_PROFILE="$(PROFILE_FILTER)") \
  163. $(if $(FILES),USER_FILES="$(FILES)") \
  164. $(if $(PACKAGES),USER_PACKAGES="$(PACKAGES)") \
  165. $(if $(BIN_DIR),BIN_DIR="$(BIN_DIR)") \
  166. $(if $(DISABLED_SERVICES),DISABLED_SERVICES="$(DISABLED_SERVICES)"))
  167. manifest: FORCE
  168. $(MAKE) -s _check_profile
  169. (unset PROFILE FILES PACKAGES MAKEFLAGS; \
  170. $(MAKE) -s _call_manifest \
  171. $(if $(PROFILE),USER_PROFILE="$(PROFILE_FILTER)") \
  172. $(if $(PACKAGES),USER_PACKAGES="$(PACKAGES)"))
  173. .SILENT: help info image manifest