image.mk 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. #
  2. # Copyright (C) 2006-2010 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. override TARGET_BUILD=
  8. include $(INCLUDE_DIR)/prereq.mk
  9. include $(INCLUDE_DIR)/kernel.mk
  10. include $(INCLUDE_DIR)/host.mk
  11. include $(INCLUDE_DIR)/version.mk
  12. override MAKE:=$(_SINGLE)$(SUBMAKE)
  13. override NO_TRACE_MAKE:=$(_SINGLE)$(NO_TRACE_MAKE)
  14. KDIR=$(KERNEL_BUILD_DIR)
  15. DTS_DIR:=$(LINUX_DIR)/arch/$(ARCH)/boot/dts/
  16. IMG_PREFIX:=openwrt-$(if $(CONFIG_VERSION_FILENAMES),$(VERSION_NUMBER)-)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
  17. MKFS_DEVTABLE_OPT := -D $(INCLUDE_DIR)/device_table.txt
  18. ifneq ($(CONFIG_BIG_ENDIAN),)
  19. JFFS2OPTS := --big-endian --squash-uids -v
  20. else
  21. JFFS2OPTS := --little-endian --squash-uids -v
  22. endif
  23. ifeq ($(CONFIG_JFFS2_RTIME),y)
  24. JFFS2OPTS += -X rtime
  25. endif
  26. ifeq ($(CONFIG_JFFS2_ZLIB),y)
  27. JFFS2OPTS += -X zlib
  28. endif
  29. ifeq ($(CONFIG_JFFS2_LZMA),y)
  30. JFFS2OPTS += -X lzma --compression-mode=size
  31. endif
  32. ifneq ($(CONFIG_JFFS2_RTIME),y)
  33. JFFS2OPTS += -x rtime
  34. endif
  35. ifneq ($(CONFIG_JFFS2_ZLIB),y)
  36. JFFS2OPTS += -x zlib
  37. endif
  38. ifneq ($(CONFIG_JFFS2_LZMA),y)
  39. JFFS2OPTS += -x lzma
  40. endif
  41. JFFS2OPTS += $(MKFS_DEVTABLE_OPT)
  42. SQUASHFS_BLOCKSIZE := $(CONFIG_TARGET_SQUASHFS_BLOCK_SIZE)k
  43. SQUASHFSOPT := -b $(SQUASHFS_BLOCKSIZE)
  44. SQUASHFSOPT += -p '/dev d 755 0 0' -p '/dev/console c 600 0 0 5 1'
  45. SQUASHFSCOMP := gzip
  46. LZMA_XZ_OPTIONS := -Xpreset 9 -Xe -Xlc 0 -Xlp 2 -Xpb 2
  47. ifeq ($(CONFIG_SQUASHFS_LZMA),y)
  48. SQUASHFSCOMP := lzma $(LZMA_XZ_OPTIONS)
  49. endif
  50. ifeq ($(CONFIG_SQUASHFS_XZ),y)
  51. ifneq ($(filter arm x86 powerpc sparc,$(LINUX_KARCH)),)
  52. BCJ_FILTER:=-Xbcj $(LINUX_KARCH)
  53. endif
  54. SQUASHFSCOMP := xz $(LZMA_XZ_OPTIONS) $(BCJ_FILTER)
  55. endif
  56. JFFS2_BLOCKSIZE ?= 64k 128k
  57. fs-types-$(CONFIG_TARGET_ROOTFS_SQUASHFS) += squashfs
  58. fs-types-$(CONFIG_TARGET_ROOTFS_JFFS2) += $(addprefix jffs2-,$(JFFS2_BLOCKSIZE))
  59. fs-types-$(CONFIG_TARGET_ROOTFS_JFFS2_NAND) += $(addprefix jffs2-nand-,$(NAND_BLOCKSIZE))
  60. fs-types-$(CONFIG_TARGET_ROOTFS_EXT4FS) += ext4
  61. fs-types-$(CONFIG_TARGET_ROOTFS_ISO) += iso
  62. fs-subtypes-$(CONFIG_TARGET_ROOTFS_JFFS2) += $(addsuffix -raw,$(addprefix jffs2-,$(JFFS2_BLOCKSIZE)))
  63. fs-subtypes-$(CONFIG_TARGET_ROOTFS_CPIOGZ) += cpiogz
  64. fs-subtypes-$(CONFIG_TARGET_ROOTFS_TARGZ) += targz
  65. TARGET_FILESYSTEMS := $(fs-types-y)
  66. FS_64K := $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-64k
  67. FS_128K := $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-128k
  68. FS_256K := $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-256k
  69. define add_jffs2_mark
  70. echo -ne '\xde\xad\xc0\xde' >> $(1)
  71. endef
  72. define toupper
  73. $(shell echo $(1) | tr '[:lower:]' '[:upper:]')
  74. endef
  75. define split_args
  76. $(foreach data, \
  77. $(subst |,$(space),\
  78. $(subst $(space),^,$(1))), \
  79. $(call $(2),$(strip $(subst ^,$(space),$(data)))))
  80. endef
  81. define build_cmd
  82. $(if $(Build/$(word 1,$(1))),,$(error Missing Build/$(word 1,$(1))))
  83. $(call Build/$(word 1,$(1)),$(wordlist 2,$(words $(1)),$(1)))
  84. endef
  85. define concat_cmd
  86. $(call split_args,$(1),build_cmd)
  87. endef
  88. # pad to 4k, 8k, 16k, 64k, 128k, 256k and add jffs2 end-of-filesystem mark
  89. define prepare_generic_squashfs
  90. $(STAGING_DIR_HOST)/bin/padjffs2 $(1) 4 8 16 64 128 256
  91. endef
  92. define Image/BuildKernel/Initramfs
  93. $(call Image/Build/Initramfs)
  94. endef
  95. define Image/BuildKernel/MkuImage
  96. mkimage -A $(ARCH) -O linux -T kernel -C $(1) -a $(2) -e $(3) \
  97. -n '$(call toupper,$(ARCH)) OpenWrt Linux-$(LINUX_VERSION)' -d $(4) $(5)
  98. endef
  99. define Image/BuildKernel/MkFIT
  100. $(TOPDIR)/scripts/mkits.sh \
  101. -D $(1) -o $(KDIR)/fit-$(1).its -k $(2) $(if $(3),-d $(3)) -C $(4) -a $(5) -e $(6) \
  102. -A $(ARCH) -v $(LINUX_VERSION)
  103. PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/fit-$(1).its $(KDIR)/fit-$(1)$(7).itb
  104. endef
  105. define Image/mkfs/jffs2/sub
  106. $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(3) --pad -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(2) -d $(TARGET_DIR) -v 2>&1 1>/dev/null | awk '/^.+$$$$/'
  107. $(call add_jffs2_mark,$(KDIR)/root.jffs2-$(2))
  108. endef
  109. define Image/mkfs/jffs2/sub-raw
  110. $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(3) -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(2)-raw -d $(TARGET_DIR) -v 2>&1 1>/dev/null | awk '/^.+$$$$/'
  111. endef
  112. define Image/mkfs/jffs2/template
  113. Image/mkfs/jffs2-$(1) = $$(call Image/mkfs/jffs2/sub,$(1),$(1),$(JFFS2OPTS))
  114. Image/mkfs/jffs2-$(1)-raw = $$(call Image/mkfs/jffs2/sub-raw,$(1),$(1),$(JFFS2OPTS))
  115. endef
  116. define Image/mkfs/jffs2-nand/template
  117. Image/mkfs/jffs2-nand-$(1) = \
  118. $$(call Image/mkfs/jffs2/sub, \
  119. $(word 2,$(subst -, ,$(1))),nand-$(1), \
  120. $(JFFS2OPTS) --no-cleanmarkers --pagesize=$(word 1,$(subst -, ,$(1))))
  121. endef
  122. $(eval $(foreach S,$(JFFS2_BLOCKSIZE),$(call Image/mkfs/jffs2/template,$(S))))
  123. $(eval $(foreach S,$(NAND_BLOCKSIZE),$(call Image/mkfs/jffs2-nand/template,$(S))))
  124. define Image/mkfs/squashfs
  125. $(STAGING_DIR_HOST)/bin/mksquashfs4 $(TARGET_DIR) $(KDIR)/root.squashfs -nopad -noappend -root-owned -comp $(SQUASHFSCOMP) $(SQUASHFSOPT) -processors $(if $(CONFIG_PKG_BUILD_JOBS),$(CONFIG_PKG_BUILD_JOBS),1)
  126. endef
  127. # $(1): board name
  128. # $(2): rootfs type
  129. # $(3): kernel image
  130. ifneq ($(CONFIG_NAND_SUPPORT),)
  131. define Image/Build/SysupgradeNAND
  132. mkdir -p "$(KDIR_TMP)/sysupgrade-$(1)/"
  133. echo "BOARD=$(1)" > "$(KDIR_TMP)/sysupgrade-$(1)/CONTROL"
  134. [ -z "$(2)" ] || $(CP) "$(KDIR)/root.$(2)" "$(KDIR_TMP)/sysupgrade-$(1)/root"
  135. [ -z "$(3)" ] || $(CP) "$(3)" "$(KDIR_TMP)/sysupgrade-$(1)/kernel"
  136. (cd "$(KDIR_TMP)"; $(TAR) cvf \
  137. "$(BIN_DIR)/$(IMG_PREFIX)-$(1)-$(2)-sysupgrade.tar" sysupgrade-$(1))
  138. endef
  139. # $(1) board name
  140. # $(2) ubinize-image options (e.g. --uboot-env and/or --kernel kernelimage)
  141. # $(3) rootfstype (e.g. squashfs or ubifs)
  142. # $(4) options to pass-through to ubinize (i.e. $($(PROFILE)_UBI_OPTS)))
  143. define Image/Build/UbinizeImage
  144. sh $(TOPDIR)/scripts/ubinize-image.sh $(2) \
  145. "$(KDIR)/root.$(3)" \
  146. "$(KDIR)/$(IMG_PREFIX)-$(1)-$(3)-ubinized.bin" \
  147. $(4)
  148. endef
  149. endif
  150. ifneq ($(CONFIG_TARGET_ROOTFS_UBIFS),)
  151. define Image/mkfs/ubifs/generate
  152. $(CP) ./ubinize$(1).cfg $(KDIR)
  153. ( cd $(KDIR); \
  154. $(STAGING_DIR_HOST)/bin/ubinize \
  155. $(if $($(PROFILE)_UBI_OPTS), \
  156. $(shell echo $($(PROFILE)_UBI_OPTS)), \
  157. $(shell echo $(UBI_OPTS)) \
  158. ) \
  159. -o $(KDIR)/root$(1).ubi \
  160. ubinize$(1).cfg \
  161. )
  162. endef
  163. define Image/mkfs/ubifs
  164. ifneq ($($(PROFILE)_UBIFS_OPTS)$(UBIFS_OPTS),)
  165. $(STAGING_DIR_HOST)/bin/mkfs.ubifs \
  166. $(if $($(PROFILE)_UBIFS_OPTS), \
  167. $(shell echo $($(PROFILE)_UBIFS_OPTS)), \
  168. $(shell echo $(UBIFS_OPTS)) \
  169. ) \
  170. $(if $(CONFIG_TARGET_UBIFS_FREE_SPACE_FIXUP),--space-fixup) \
  171. $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_NONE),--force-compr=none) \
  172. $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_LZO),--force-compr=lzo) \
  173. $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_ZLIB),--force-compr=zlib) \
  174. $(if $(shell echo $(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)),--jrn-size=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)) \
  175. --squash-uids \
  176. -o $(KDIR)/root.ubifs \
  177. -d $(TARGET_DIR)
  178. endif
  179. $(call Image/Build,ubifs)
  180. ifneq ($($(PROFILE)_UBI_OPTS)$(UBI_OPTS),)
  181. $(if $(wildcard ./ubinize.cfg),$(call Image/mkfs/ubifs/generate,))
  182. $(if $(wildcard ./ubinize-overlay.cfg),$(call Image/mkfs/ubifs/generate,-overlay))
  183. endif
  184. $(if $(wildcard ./ubinize.cfg),$(call Image/Build,ubi))
  185. endef
  186. endif
  187. define Image/mkfs/cpiogz
  188. ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9 >$(BIN_DIR)/$(IMG_PREFIX)-rootfs.cpio.gz )
  189. endef
  190. define Image/mkfs/targz
  191. $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE),-$(PROFILE))-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
  192. endef
  193. E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_PARTSIZE)*1024*1024)))
  194. define Image/mkfs/ext4
  195. $(STAGING_DIR_HOST)/bin/make_ext4fs \
  196. -l $(E2SIZE) -b $(CONFIG_TARGET_EXT4_BLOCKSIZE) \
  197. -i $(CONFIG_TARGET_EXT4_MAXINODE) \
  198. -m $(CONFIG_TARGET_EXT4_RESERVED_PCT) \
  199. $(if $(CONFIG_TARGET_EXT4_JOURNAL),,-J) \
  200. $(KDIR)/root.ext4 $(TARGET_DIR)/
  201. endef
  202. define Image/mkfs/prepare/default
  203. # Use symbolic permissions to avoid clobbering SUID/SGID/sticky bits
  204. - $(FIND) $(TARGET_DIR) -type f -not -perm /0100 -not -name 'ssh_host*' -not -name 'shadow' -print0 | $(XARGS) -0 chmod u+rw,g+r,o+r
  205. - $(FIND) $(TARGET_DIR) -type f -perm /0100 -print0 | $(XARGS) -0 chmod u+rwx,g+rx,o+rx
  206. - $(FIND) $(TARGET_DIR) -type d -print0 | $(XARGS) -0 chmod u+rwx,g+rx,o+rx
  207. $(INSTALL_DIR) $(TARGET_DIR)/tmp $(TARGET_DIR)/overlay
  208. chmod 1777 $(TARGET_DIR)/tmp
  209. endef
  210. define Image/mkfs/prepare
  211. $(call Image/mkfs/prepare/default)
  212. endef
  213. define Image/Checksum
  214. ( cd ${BIN_DIR} ; \
  215. $(FIND) -maxdepth 1 -type f \! -name 'md5sums' -printf "%P\n" | sort | xargs $1 > $2 \
  216. )
  217. endef
  218. define BuildImage/mkfs
  219. install: mkfs-$(1)
  220. .PHONY: mkfs-$(1)
  221. mkfs-$(1): mkfs_prepare
  222. $(Image/mkfs/$(1))
  223. $(call Build/mkfs/default,$(1))
  224. $(call Build/mkfs/$(1),$(1))
  225. $(KDIR)/root.$(1): mkfs-$(1)
  226. endef
  227. # Build commands that can be called from Device/* templates
  228. define Build/uImage
  229. mkimage -A $(LINUX_KARCH) \
  230. -O linux -T kernel \
  231. -C $(1) -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
  232. -n '$(call toupper,$(LINUX_KARCH)) OpenWrt Linux-$(LINUX_VERSION)' -d $@ $@.new
  233. @mv $@.new $@
  234. endef
  235. define Build/lzma
  236. $(STAGING_DIR_HOST)/bin/lzma e $@ -lc1 -lp2 -pb2 $(1) $@.new
  237. @mv $@.new $@
  238. endef
  239. define Build/kernel-bin
  240. rm -f $@
  241. cp $^ $@
  242. endef
  243. define Build/patch-cmdline
  244. $(STAGING_DIR_HOST)/bin/patch-cmdline $@ '$(CMDLINE)'
  245. endef
  246. define Build/append-kernel
  247. dd if=$(word 1,$^) $(if $(1),bs=$(1) conv=sync) >> $@
  248. endef
  249. define Build/append-rootfs
  250. dd if=$(word 2,$^) $(if $(1),bs=$(1) conv=sync) >> $@
  251. endef
  252. define Build/pad-rootfs
  253. $(call prepare_generic_squashfs,$@ $(1))
  254. endef
  255. define Build/pad-offset
  256. let \
  257. size="$$(stat -c%s $@)" \
  258. pad="$(word 1, $(1))" \
  259. offset="$(word 2, $(1))" \
  260. pad="(pad - ((size + offset) % pad)) % pad" \
  261. newsize='size + pad'; \
  262. dd if=$@ of=$@.new bs=$$newsize count=1 conv=sync
  263. mv $@.new $@
  264. endef
  265. define Build/check-size
  266. @[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -gt "$$(stat -c%s $@)" ] || { \
  267. echo "WARNING: Image file $@ is too big" >&2; \
  268. rm -f $@; \
  269. }
  270. endef
  271. define Device/Init
  272. PROFILES := $(PROFILE)
  273. KERNEL:=
  274. KERNEL_INITRAMFS = $$(KERNEL)
  275. KERNEL_SIZE:=
  276. CMDLINE:=
  277. IMAGE_PREFIX := $(IMG_PREFIX)-$(1)
  278. IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1)-$$(2)
  279. KERNEL_PREFIX = $(1)
  280. KERNEL_SUFFIX := -kernel.bin
  281. KERNEL_IMAGE = $$(KERNEL_PREFIX)$$(KERNEL_SUFFIX)
  282. KERNEL_INITRAMFS_PREFIX = $$(IMAGE_PREFIX)-initramfs
  283. KERNEL_INITRAMFS_IMAGE = $$(KERNEL_INITRAMFS_PREFIX)$$(KERNEL_SUFFIX)
  284. KERNEL_INSTALL :=
  285. KERNEL_NAME := vmlinux
  286. KERNEL_SIZE :=
  287. FILESYSTEMS := $(TARGET_FILESYSTEMS)
  288. endef
  289. define Device/ExportVar
  290. $(1) : $(2):=$$($(2))
  291. endef
  292. define Device/Export
  293. $(foreach var,$(DEVICE_VARS) KERNEL KERNEL_INITRAMFS,$(call Device/ExportVar,$(1),$(var)))
  294. $(1) : FILESYSTEM:=$(2)
  295. endef
  296. define Device/Check
  297. _TARGET = $$(if $$(filter $(PROFILE),$$(PROFILES)),install,install-disabled)
  298. _COMPILE_TARGET = $$(if $(if $(IB),,$(CONFIG_IB)$$(filter $(PROFILE),$$(PROFILES))),compile,compile-disabled)
  299. endef
  300. ifndef IB
  301. define Device/Build/initramfs
  302. $(call Device/Export,$(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE),$(1))
  303. $$(_TARGET): $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE)
  304. $(KDIR)/$$(KERNEL_NAME)-initramfs: image_prepare
  305. $(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE)
  306. cp $$^ $$@
  307. $(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE): $(KDIR)/$$(KERNEL_NAME)-initramfs
  308. @rm -f $$@
  309. $$(call concat_cmd,$$(KERNEL_INITRAMFS))
  310. endef
  311. endif
  312. define Device/Build/check_size
  313. @[ $$(($(subst k,* 1024,$(subst m, * 1024k,$(1))))) -gt "$$(stat -c%s $@)" ] || { \
  314. echo "WARNING: Image file $@ is too big" >&2; \
  315. rm -f $@; \
  316. }
  317. endef
  318. define Device/Build/compile
  319. $$(_COMPILE_TARGET): $(KDIR)/$(1)
  320. $(eval $(call Device/Export,$(KDIR)/$(1)))
  321. $(KDIR)/$(1):
  322. $$(call concat_cmd,$(COMPILE/$(1)))
  323. endef
  324. define Device/Build/kernel
  325. _KERNEL_IMAGES += $(KDIR)/$$(KERNEL_NAME)
  326. $(KDIR)/$$(KERNEL_NAME): image_prepare
  327. $$(_TARGET): $$(if $$(KERNEL_INSTALL),$(BIN_DIR)/$$(KERNEL_IMAGE))
  328. $(call Device/Export,$(KDIR)/$$(KERNEL_IMAGE),$(1))
  329. $(BIN_DIR)/$$(KERNEL_IMAGE): $(KDIR)/$$(KERNEL_IMAGE)
  330. cp $$^ $$@
  331. ifndef IB
  332. ifdef CONFIG_IB
  333. install: $(KDIR)/$$(KERNEL_IMAGE)
  334. endif
  335. $(KDIR)/$$(KERNEL_IMAGE): $(KDIR)/$$(KERNEL_NAME)
  336. @rm -f $$@
  337. $$(call concat_cmd,$$(KERNEL))
  338. $$(if $$(KERNEL_SIZE),$$(call Device/Build/check_size,$$(KERNEL_SIZE)))
  339. endif
  340. endef
  341. define Device/Build/image
  342. $$(_TARGET): $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))
  343. $(eval $(call Device/Export,$(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2)),$(1)))
  344. $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/$$(KERNEL_IMAGE) $(KDIR)/root.$(1)
  345. @rm -f $$@
  346. [ -f $$(word 1,$$^) -a -f $$(word 2,$$^) ]
  347. $$(call concat_cmd,$(if $(IMAGE/$(2)/$(1)),$(IMAGE/$(2)/$(1)),$(IMAGE/$(2))))
  348. .IGNORE: $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))
  349. $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2))
  350. cp $$^ $$@
  351. endef
  352. define Device/Build
  353. $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(call Device/Build/initramfs,$(1)))
  354. $(call Device/Build/kernel,$(1))
  355. $$(eval $$(foreach compile,$$(COMPILE), \
  356. $$(call Device/Build/compile,$$(compile),$(1))))
  357. $$(eval $$(foreach image,$$(IMAGES), \
  358. $$(foreach fs,$$(filter $(TARGET_FILESYSTEMS),$$(FILESYSTEMS)), \
  359. $$(call Device/Build/image,$$(fs),$$(image),$(1)))))
  360. endef
  361. define Device
  362. $(call Device/Init,$(1))
  363. $(call Device/Default,$(1))
  364. $(call Device/Check,$(1))
  365. $(call Device/$(1),$(1))
  366. $(call Device/Build,$(1))
  367. endef
  368. define BuildImage
  369. download:
  370. prepare:
  371. compile:
  372. clean:
  373. image_prepare:
  374. ifeq ($(IB),)
  375. .PHONY: download prepare compile clean image_prepare mkfs_prepare kernel_prepare install
  376. compile:
  377. $(call Build/Compile)
  378. clean:
  379. $(call Build/Clean)
  380. image_prepare: compile
  381. mkdir -p $(KDIR)/tmp
  382. $(call Image/Prepare)
  383. else
  384. image_prepare:
  385. mkdir -p $(KDIR)/tmp
  386. endif
  387. mkfs_prepare: image_prepare
  388. $(call Image/mkfs/prepare)
  389. kernel_prepare: mkfs_prepare
  390. $(call Image/BuildKernel)
  391. $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(if $(IB),,$(call Image/BuildKernel/Initramfs)))
  392. $(call Image/InstallKernel)
  393. $(foreach device,$(TARGET_DEVICES),$(call Device,$(device)))
  394. $(foreach fs,$(TARGET_FILESYSTEMS) $(fs-subtypes-y),$(call BuildImage/mkfs,$(fs)))
  395. $$(sort $$(_KERNEL_IMAGES)):
  396. @touch $$@
  397. install: kernel_prepare
  398. $(foreach fs,$(TARGET_FILESYSTEMS),
  399. $(call Image/Build,$(fs))
  400. )
  401. $(call Image/mkfs/ubifs)
  402. $(call Image/Checksum,md5sum --binary,md5sums)
  403. $(call Image/Checksum,openssl dgst -sha256,sha256sums)
  404. endef