From d0f4f95e390bcb1c953efa125f5277a8a235396e Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Fri, 23 Nov 2018 15:58:08 +0100 Subject: Makefile: rework main directory creation logic In the current code, the creation of the main output directories (BUILD_DIR, STAGING_DIR, HOST_DIR, TARGET_DIR, etc.) is done by a global "dirs" target. While this works fine in the current situation, it doesn't work well in a context where per-package host and target directories are used. For example, with the current code and per-package host directories, the output/staging symbolic link ends up being created as a link to the per-package package sysroot directory of the first package being built, instead of the global sysroot. This commit reworks the creation of those directories by having the package/pkg-generic.mk code ensure that the build directory, target directory, host directory, staging directory and binaries directory exist before they are needed. Two new targets, host-finalize and staging-finalize are added in the main Makefile to create the compatibility symlinks for host and staging directories. They will be extended later with additional logic for per-package directories. Thanks to those changes, the global "dirs" target is entirely removed. Signed-off-by: Thomas Petazzoni Reviewed-by: "Yann E. MORIN" Signed-off-by: Peter Korsgaard --- fs/common.mk | 1 + 1 file changed, 1 insertion(+) (limited to 'fs') diff --git a/fs/common.mk b/fs/common.mk index 2a5a202a89..96658428ba 100644 --- a/fs/common.mk +++ b/fs/common.mk @@ -145,6 +145,7 @@ $$(BINARIES_DIR)/rootfs.$(1): ROOTFS=$(2) $$(BINARIES_DIR)/rootfs.$(1): FAKEROOT_SCRIPT=$$(ROOTFS_$(2)_DIR)/fakeroot $$(BINARIES_DIR)/rootfs.$(1): $$(ROOTFS_$(2)_DEPENDENCIES) @$$(call MESSAGE,"Generating root filesystem image rootfs.$(1)") + mkdir -p $$(@D) rm -rf $$(ROOTFS_$(2)_DIR) mkdir -p $$(ROOTFS_$(2)_DIR) echo '#!/bin/sh' > $$(FAKEROOT_SCRIPT) -- cgit v1.2.1 From 21c6fb2589fb36d0d9367efe906c94da67cbf009 Mon Sep 17 00:00:00 2001 From: Carlos Santos Date: Sat, 1 Dec 2018 10:14:36 +0100 Subject: fs/common: allow filesystems to set the name of their output file Some filesystems may want to tweak their output names, rather than using the fixed "rootfs.foo" scheme. Add a ROOTFS_FOO_IMAGE_NAME variable for this purpose. Signed-off-by: Carlos Santos [yann.morin.1998@free.fr: fix the patch] Signed-off-by: "Yann E. MORIN" Signed-off-by: Thomas Petazzoni --- fs/common.mk | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'fs') diff --git a/fs/common.mk b/fs/common.mk index 96658428ba..d49e615447 100644 --- a/fs/common.mk +++ b/fs/common.mk @@ -107,6 +107,8 @@ rootfs-common-show-depends: # all variable references except the arguments must be $$-quoted. define inner-rootfs +ROOTFS_$(2)_IMAGE_NAME ?= rootfs.$(1) +ROOTFS_$(2)_FINAL_IMAGE_NAME = $$(strip $$(ROOTFS_$(2)_IMAGE_NAME)) ROOTFS_$(2)_DIR = $$(FS_DIR)/$(1) ROOTFS_$(2)_TARGET_DIR = $$(ROOTFS_$(2)_DIR)/target @@ -141,10 +143,10 @@ ROOTFS_$(2)_COMPRESS_EXT = .xz ROOTFS_$(2)_COMPRESS_CMD = xz -9 -C crc32 -c endif -$$(BINARIES_DIR)/rootfs.$(1): ROOTFS=$(2) -$$(BINARIES_DIR)/rootfs.$(1): FAKEROOT_SCRIPT=$$(ROOTFS_$(2)_DIR)/fakeroot -$$(BINARIES_DIR)/rootfs.$(1): $$(ROOTFS_$(2)_DEPENDENCIES) - @$$(call MESSAGE,"Generating root filesystem image rootfs.$(1)") +$$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): ROOTFS=$(2) +$$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): FAKEROOT_SCRIPT=$$(ROOTFS_$(2)_DIR)/fakeroot +$$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES) + @$$(call MESSAGE,"Generating filesystem image $$(ROOTFS_$(2)_FINAL_IMAGE_NAME)") mkdir -p $$(@D) rm -rf $$(ROOTFS_$(2)_DIR) mkdir -p $$(ROOTFS_$(2)_DIR) @@ -166,7 +168,7 @@ endif rootfs-$(1)-show-depends: @echo $$(ROOTFS_$(2)_DEPENDENCIES) -rootfs-$(1): $$(BINARIES_DIR)/rootfs.$(1) +rootfs-$(1): $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME) .PHONY: rootfs-$(1) rootfs-$(1)-show-depends -- cgit v1.2.1