From nobody Fri Nov 29 19:28:00 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3F43185E6A; Tue, 17 Sep 2024 14:18:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582699; cv=none; b=CDNDtlma+90n3GYW+xss4MjsYgduoqGtYrFYTFfnW93Sz8WWvvl+G4kAzdXp+rB40D6JhuFFhh0JMd+Z/fhHDDAHAp6oQI9FfVIqKViWwTYgLCsa4I0cpvQoU+GkdeeM9mNHV9QxfrKh4ryiModMON7v8FmNrzm6WAugwejY/zo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582699; c=relaxed/simple; bh=Ra2sKRWgqwv0KIZWzt1FwqFPZ+ccaJpIfL/OUlJKdGk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jIHYCiAFO3fTOqAg75Z1Nnjn2Hp4ZUduODcjLb06IdLk9nm3Vd6ECKU/2DeSdxZ6wgMi9obiWILmjUqxidebriwKZ0hjs1GgVb01AvGsAr7sxM7LgbhYX7nwyVtppdhV/kvNrvvFmf1tR80R8GiNBYxn7fEnLKmIT6jcPFF1h8Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gMyHmEtB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gMyHmEtB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F184DC4CEC5; Tue, 17 Sep 2024 14:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726582699; bh=Ra2sKRWgqwv0KIZWzt1FwqFPZ+ccaJpIfL/OUlJKdGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gMyHmEtBAND0LFpuaHHdvm0IL6/fXRl36eFKyQbZChRo2vlMflHk4XQ3s8gwIs8Ox G27dtJKz1R+zGfW9Y7vcs6rALMqJ3rGtHrZDkOoB3Js89lsHKyUaTlZNLEe3u9gDL+ QY/q84LuowH3vg7iunMQo/iAWsbjsXly2MgNK3O30VdX98lqlrSeAuseLjudBUlKlr FR2EQJsH/fiLABxt6Xni3qSQRQWjwCzyuDlesg18H4l+9169Gop4dT9xl07m5PSfLr l8rluzKhKEeaAfwDmtLIiglXraNgKkA5eEWoRLLf2lXQWPnnMbgrSfiwd6ebgZC6ku ZeWgf4Uqhk0bQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Miguel Ojeda , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Nicolas Schier , Masahiro Yamada Subject: [PATCH 22/23] kbuild: make wrapper Makefile more convenient for external modules Date: Tue, 17 Sep 2024 23:16:50 +0900 Message-ID: <20240917141725.466514-23-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917141725.466514-1-masahiroy@kernel.org> References: <20240917141725.466514-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When Kbuild starts building in a separate output directory, it generates a wrapper Makefile, allowing you to invoke 'make' from the output directory. This commit makes it more convenient, so you can invoke 'make' without M=3D or MO=3D. First, you need to build external modules in a separate directory: $ make M=3D/path/to/module/source/dir MO=3D/path/to/module/build/dir Once the wrapper Makefile is generated in /path/to/module/build/dir, you can proceed as follows: $ cd /path/to/module/build/dir $ make Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9f0ba07e8f25..81603a50c757 100644 --- a/Makefile +++ b/Makefile @@ -641,10 +641,20 @@ ifdef building_out_of_srctree # At the same time when output Makefile generated, generate .gitignore to # ignore whole output directory =20 +ifdef KBUILD_EXTMOD +print_env_for_makefile =3D \ + echo "export KBUILD_OUTPUT =3D $(objtree)"; \ + echo "export KBUILD_EXTMOD =3D $(_vpath)" ; \ + echo "export KBUILD_EXTMOD_OUTPUT =3D $(CURDIR)" +else +print_env_for_makefile =3D \ + echo "export KBUILD_OUTPUT =3D $(CURDIR)" +endif + quiet_cmd_makefile =3D GEN Makefile cmd_makefile =3D { \ echo "\# Automatically generated by $(abs_srctree)/Makefile: don't edit";= \ - echo "export KBUILD_OUTPUT =3D $(CURDIR)"; \ + $(print_env_for_makefile); \ echo "include $(abs_srctree)/Makefile"; \ } > Makefile =20 --=20 2.43.0