All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@kernel.org>
To: Rene Herman <rene.herman@gmail.com>
Cc: Kai Germaschewski <kai@germaschewski.name>,
	ALSA devel <alsa-devel@alsa-project.org>,
	Sam Ravnborg <sam@ravnborg.org>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: Per option CFLAGS?
Date: Sat, 15 Sep 2007 17:52:32 +0200	[thread overview]
Message-ID: <20070915155231.GU3563@stusta.de> (raw)
In-Reply-To: <46EBF774.2030306@gmail.com>

On Sat, Sep 15, 2007 at 05:17:08PM +0200, Rene Herman wrote:
> On 09/15/2007 10:47 AM, Adrian Bunk wrote:
>
>> On Sat, Sep 15, 2007 at 01:30:21AM +0200, Rene Herman wrote:
>>> On 09/15/2007 01:13 AM, H. Peter Anvin wrote:
>>>
>>>> Rene Herman wrote:
>>>>> I have a single file foo.c that I want to generate two (ALSA) modules
>>>>> from, snd-foo2000.ko and snd-foo2001.ko, by compiling with either
>>>>> FOO2000 or FOO2001 defined.
>>>>>
>>>>> I can do this, and ALSA does this a few times, by providing dummy
>>>>> foo2000.c and foo2001.c files, like:
>>>>>
>>>>> === foo2000.c
>>>>> #define FOO2000
>>>>> #include "foo.c"
>>>>> ===
>
> [ ... ]
>
>>>> The stub source file is usually considered a good way to do this.
>>> Mmm. If I'll have to live with it, I can, but thought I'd ask if there 
>>> was some nice build trickery available instead.
>> The usual trick is to create _three_ modules:
>> Two with the foo2000 and foo2001 specific parts, and a third one with all 
>> code used by both.
>> Or if foo2000 and foo2001 differ only in small details, create one 
>> snd-foo200x module supporting both at the same time.
>
> Thanks for the comment. Yes, first would be massive overkill in this case 
> and second somewhat annoying as one of the differences is support for 
> different resources (IRQs) among the two versions, whereas I'm checking the 
> validity of the passed in values at a time I do not know which version I'm 
> looking at yet -- knowing that requires having talked to the hardware.

I'm not getting this point.

Consider both snd-foo2000 and snd-foo2001 are compiled statically into 
the kernel - somehow one of them must realize quite early that it's not 
responsible for the device.

And however this is done, it should similarly work in one module 
supporting both.

> Can do, but for now it seems like the two seperate modules might be 
> cleaner. Can keep things much more straighforward that way by just 
> redefining a bunch of #defines.
>
> I'll just do the split version first and if someone really wants me to, 
> I'll merge them after all...
>
> Rene

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

WARNING: multiple messages have this Message-ID (diff)
From: Adrian Bunk <bunk@kernel.org>
To: Rene Herman <rene.herman@gmail.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Kai Germaschewski <kai@germaschewski.name>,
	Sam Ravnborg <sam@ravnborg.org>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	ALSA devel <alsa-devel@alsa-project.org>
Subject: Re: Per option CFLAGS?
Date: Sat, 15 Sep 2007 17:52:32 +0200	[thread overview]
Message-ID: <20070915155231.GU3563@stusta.de> (raw)
In-Reply-To: <46EBF774.2030306@gmail.com>

On Sat, Sep 15, 2007 at 05:17:08PM +0200, Rene Herman wrote:
> On 09/15/2007 10:47 AM, Adrian Bunk wrote:
>
>> On Sat, Sep 15, 2007 at 01:30:21AM +0200, Rene Herman wrote:
>>> On 09/15/2007 01:13 AM, H. Peter Anvin wrote:
>>>
>>>> Rene Herman wrote:
>>>>> I have a single file foo.c that I want to generate two (ALSA) modules
>>>>> from, snd-foo2000.ko and snd-foo2001.ko, by compiling with either
>>>>> FOO2000 or FOO2001 defined.
>>>>>
>>>>> I can do this, and ALSA does this a few times, by providing dummy
>>>>> foo2000.c and foo2001.c files, like:
>>>>>
>>>>> === foo2000.c
>>>>> #define FOO2000
>>>>> #include "foo.c"
>>>>> ===
>
> [ ... ]
>
>>>> The stub source file is usually considered a good way to do this.
>>> Mmm. If I'll have to live with it, I can, but thought I'd ask if there 
>>> was some nice build trickery available instead.
>> The usual trick is to create _three_ modules:
>> Two with the foo2000 and foo2001 specific parts, and a third one with all 
>> code used by both.
>> Or if foo2000 and foo2001 differ only in small details, create one 
>> snd-foo200x module supporting both at the same time.
>
> Thanks for the comment. Yes, first would be massive overkill in this case 
> and second somewhat annoying as one of the differences is support for 
> different resources (IRQs) among the two versions, whereas I'm checking the 
> validity of the passed in values at a time I do not know which version I'm 
> looking at yet -- knowing that requires having talked to the hardware.

I'm not getting this point.

Consider both snd-foo2000 and snd-foo2001 are compiled statically into 
the kernel - somehow one of them must realize quite early that it's not 
responsible for the device.

And however this is done, it should similarly work in one module 
supporting both.

> Can do, but for now it seems like the two seperate modules might be 
> cleaner. Can keep things much more straighforward that way by just 
> redefining a bunch of #defines.
>
> I'll just do the split version first and if someone really wants me to, 
> I'll merge them after all...
>
> Rene

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


  reply	other threads:[~2007-09-15 15:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-14 23:07 Per option CFLAGS? Rene Herman
2007-09-14 23:07 ` Rene Herman
2007-09-14 23:13 ` H. Peter Anvin
2007-09-14 23:30   ` Rene Herman
2007-09-14 23:30     ` Rene Herman
2007-09-15  8:47     ` Adrian Bunk
2007-09-15 15:17       ` Rene Herman
2007-09-15 15:17         ` Rene Herman
2007-09-15 15:52         ` Adrian Bunk [this message]
2007-09-15 15:52           ` Adrian Bunk
2007-09-15 15:53         ` Denys Vlasenko
2007-09-15 15:59           ` Rene Herman
2007-09-15 15:59             ` Rene Herman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070915155231.GU3563@stusta.de \
    --to=bunk@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=hpa@zytor.com \
    --cc=kai@germaschewski.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rene.herman@gmail.com \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.