From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC6EEC4332F for ; Mon, 19 Dec 2022 18:36:29 +0000 (UTC) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.96) (envelope-from ) id 1p7Kzn-0004Pb-2D; Mon, 19 Dec 2022 13:36:15 -0500 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1p7Kzj-0004Jf-2q for kernelnewbies@kernelnewbies.org; Mon, 19 Dec 2022 13:36:12 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 6B6783200708; Mon, 19 Dec 2022 13:36:07 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 19 Dec 2022 13:36:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1671474967; x=1671561367; bh=mwXhjeLwLB PG1rrjqt0okI1bPbihG5VlzI2C1MwzEcI=; b=h9vAZZ6ZhEGCYyNXtcJXVnc5Ul zQFXHCagYhIwzM8tRp2wKYZ205dB3Zfv9SZmloGfTSs6EkClEuiP6B8KPefhMA9Y RFA68vXLdaq2URDNrVKP8zdyqG2JmrqwfBb4aVRUZlnQYFFXvt19lE7FaAF0PpJs eYW5UIwOyYs+f6iN8ihy4MWzCDnHVaQU9jAHCf2DSDedUJqOReg4xqbcaHAWwY6Z 8sNqvWHhuqxRO8wSQ0eSljBbS5i0RseM+54ZbcUEtcPK6dtJlxV5BPFERoDMKiG1 Nb18vWeCjKwWwc+9jawIKj3wQmCMHDyAH9ih9ZP13WJv+UTz6OlKy8nLSWoA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1671474967; x=1671561367; bh=mwXhjeLwLBPG1rrjqt0okI1bPbih G5VlzI2C1MwzEcI=; b=Ep/6WTxYXPzO35Rbz8fjnLSjqzOxxUU6AybaG2PrZEiw MbX3dd1TZq4VuFQRhvU/6kZQmQnkRQ50vGCfLAHzScSb32hhhE0qq2TAdHT4SS1I fS2fP7Sh/ThsFifI3bEJ/QboEsdD/CbzqNdbt7CV3UVzh+exMntC/efcxlritBOm q+ARiMptJJuOjODQxwmvnm24yTybPFGh/31ZouV4fFXYGxBxOEjWSlcLf+IB1Zou /UtJo0WGZOa5SD6j8fAiPqDb3JIcF/nm/s3+P2rBw99ETgibA3Bpw1jOo3CLKHX7 XhyNXek7qTTzEkjQOcyfRQ+giredYeuOiHUOFWzpQQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgeefgdekkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvfevuffkfhggtggujgesthdtre dttddtvdenucfhrhhomhepifhrvghgucfmjfcuoehgrhgvgheskhhrohgrhhdrtghomheq necuggftrfgrthhtvghrnhepheegvdevvdeljeeugfdtudduhfekledtiefhveejkeejue fhtdeufefhgfehkeetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghi lhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhm X-ME-Proxy: Feedback-ID: i787e41f1:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 19 Dec 2022 13:36:06 -0500 (EST) Date: Mon, 19 Dec 2022 19:36:03 +0100 From: Greg KH To: jim.cromie@gmail.com Subject: Re: 2 modules from 1 source ? Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Cc: kernelnewbies X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org On Mon, Dec 19, 2022 at 10:02:42AM -0700, jim.cromie@gmail.com wrote: > On Mon, Dec 19, 2022 at 9:37 AM wrote: > > > > Id like to build 2 modules (with different names) > > from a single source file, with 2nd being dependent > > on the 1st. > > > > Specifically, Ive got: > > lib/test_dynamic_debug.c > > > > I want > > A: lib/test_dynamic_debug.ko > > B: lib/test_dynamic_debug_submod.ko > > > > I expect that the code just needs an #ifdef #else #endif > > block to clearly put the dependor & dependee elements > > next to each other. > > > > My question is how to do this in the Makefile ? > > this does most of it > > > > --- a/lib/Makefile > > +++ b/lib/Makefile > > @@ -78,7 +78,8 @@ obj-$(CONFIG_TEST_SORT) += test_sort.o > > obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o > > obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o > > obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o > > -obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o > > +obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o > > test_dynamic_debug_submod.o > > +CFLAGS_test_dynamic_debug_submod.o += -DTEST_DYNAMIC_DEBUG_SUBMOD > > obj-$(CONFIG_TEST_PRINTF) += test_printf.o > > > > but how do I tell it the 2nd target ? > > more to the point, this doesnt work (nor do permutations), I miss something: > > +($obj)/test_dynamic_debug_submod.o: ($obj)/test_dynamic_debug.c Pleaase don't do that :( If you _REALLY_ need to do this, then just #include your .c file into two other .c files. And keep everything in your #included .c file static to make sure you don't have duplicate global symbols. Otherwise it is impossible for the same .o to be linked into two different modules (or into the kernel image itself) as there will be duplicate global symbols (as that .c file had to have something global for you to be able to call into it.) But step back, what is the problem that you really want to solve here that you feel somehow a single .c file built twice would be correct? Especially with code in lib/ that should not be needed at all as you are building "library" functions that only get included if they are actually used in the large kernel image. thanks, greg k-h _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies