* Per option CFLAGS? @ 2007-09-14 23:07 Rene Herman 2007-09-14 23:13 ` H. Peter Anvin 0 siblings, 1 reply; 8+ messages in thread From: Rene Herman @ 2007-09-14 23:07 UTC (permalink / raw) To: Kai Germaschewski, Sam Ravnborg; +Cc: Linux Kernel, ALSA devel Hi Kai, Sam. 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" === and a regular Makefile === foo2000-objs := foo2000.o foo2001-objs := foo2001.o obj-$(CONFIG_SND_FOO2000) += snd-foo2000.o obj-$(CONFIG_SND_F002001) += snd-foo2001.o === That #include is a little lame though. Is there a nicer way? I noticed the per-file CFLAGS, but given that it's one source file for both, that doesn't fit. Rene. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Per option CFLAGS? 2007-09-14 23:07 Per option CFLAGS? Rene Herman @ 2007-09-14 23:13 ` H. Peter Anvin 2007-09-14 23:30 ` Rene Herman 0 siblings, 1 reply; 8+ messages in thread From: H. Peter Anvin @ 2007-09-14 23:13 UTC (permalink / raw) To: Rene Herman; +Cc: Kai Germaschewski, Sam Ravnborg, Linux Kernel, ALSA devel Rene Herman wrote: > Hi Kai, Sam. > > 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" > === > > and a regular Makefile > > === > foo2000-objs := foo2000.o > foo2001-objs := foo2001.o > > obj-$(CONFIG_SND_FOO2000) += snd-foo2000.o > obj-$(CONFIG_SND_F002001) += snd-foo2001.o > === > > That #include is a little lame though. Is there a nicer way? I noticed > the per-file CFLAGS, but given that it's one source file for both, that > doesn't fit. > The stub source file is usually considered a good way to do this. -hpa ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Per option CFLAGS? 2007-09-14 23:13 ` H. Peter Anvin @ 2007-09-14 23:30 ` Rene Herman 2007-09-15 8:47 ` Adrian Bunk 0 siblings, 1 reply; 8+ messages in thread From: Rene Herman @ 2007-09-14 23:30 UTC (permalink / raw) To: H. Peter Anvin; +Cc: Kai Germaschewski, Sam Ravnborg, Linux Kernel, ALSA devel 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" >> === >> >> and a regular Makefile >> >> === >> foo2000-objs := foo2000.o >> foo2001-objs := foo2001.o >> >> obj-$(CONFIG_SND_FOO2000) += snd-foo2000.o >> obj-$(CONFIG_SND_F002001) += snd-foo2001.o >> === >> >> That #include is a little lame though. Is there a nicer way? I noticed >> the per-file CFLAGS, but given that it's one source file for both, that >> doesn't fit. >> > > 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. Rene. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Per option CFLAGS? 2007-09-14 23:30 ` Rene Herman @ 2007-09-15 8:47 ` Adrian Bunk 2007-09-15 15:17 ` Rene Herman 0 siblings, 1 reply; 8+ messages in thread From: Adrian Bunk @ 2007-09-15 8:47 UTC (permalink / raw) To: Rene Herman Cc: H. Peter Anvin, Kai Germaschewski, Sam Ravnborg, Linux Kernel, ALSA devel 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" >>> === >>> >>> and a regular Makefile >>> >>> === >>> foo2000-objs := foo2000.o >>> foo2001-objs := foo2001.o >>> >>> obj-$(CONFIG_SND_FOO2000) += snd-foo2000.o >>> obj-$(CONFIG_SND_F002001) += snd-foo2001.o >>> === >>> >>> That #include is a little lame though. Is there a nicer way? I noticed >>> the per-file CFLAGS, but given that it's one source file for both, that >>> doesn't fit. >>> >> 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. > 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Per option CFLAGS? 2007-09-15 8:47 ` Adrian Bunk @ 2007-09-15 15:17 ` Rene Herman 2007-09-15 15:52 ` Adrian Bunk 2007-09-15 15:53 ` Denys Vlasenko 0 siblings, 2 replies; 8+ messages in thread From: Rene Herman @ 2007-09-15 15:17 UTC (permalink / raw) To: Adrian Bunk Cc: H. Peter Anvin, Kai Germaschewski, Sam Ravnborg, Linux Kernel, ALSA devel 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. 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Per option CFLAGS? 2007-09-15 15:17 ` Rene Herman @ 2007-09-15 15:52 ` Adrian Bunk 2007-09-15 15:53 ` Denys Vlasenko 1 sibling, 0 replies; 8+ messages in thread From: Adrian Bunk @ 2007-09-15 15:52 UTC (permalink / raw) To: Rene Herman Cc: H. Peter Anvin, Kai Germaschewski, Sam Ravnborg, Linux Kernel, ALSA devel 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Per option CFLAGS? 2007-09-15 15:17 ` Rene Herman 2007-09-15 15:52 ` Adrian Bunk @ 2007-09-15 15:53 ` Denys Vlasenko 2007-09-15 15:59 ` Rene Herman 1 sibling, 1 reply; 8+ messages in thread From: Denys Vlasenko @ 2007-09-15 15:53 UTC (permalink / raw) To: Rene Herman Cc: Adrian Bunk, H. Peter Anvin, Kai Germaschewski, Sam Ravnborg, Linux Kernel, ALSA devel On Saturday 15 September 2007 16:17, Rene Herman wrote: > On 09/15/2007 10:47 AM, Adrian Bunk wrote: > >>> 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. If I understood you right, this is PCI, USB or other kind of devices where module is selected according to PCI/USB/whatever IDs. You thinking is - if module foo2000 is loaded, this is definitely a 2000 device and you can "check the validity of the passed in values" for the device 2000 now. Correct me if I'm wrong. But you can do absolutely the same at runtime in unified driver, since PCI/USB/whatever IDs are accessible to the driver. Two drivers will most likely have code duplication. Unified driver will be harder to read and maintain because of all ifs/switch's/function pointers you need. The choice depends on *how much* maintainability pain you can tolerate by taking "unified code" path. > Can do, but for now it seems like the two seperate modules might be cleaner. Can you give a bit more info what the dirrefences between devices are in this particular cases? -- vda ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Per option CFLAGS? 2007-09-15 15:53 ` Denys Vlasenko @ 2007-09-15 15:59 ` Rene Herman 0 siblings, 0 replies; 8+ messages in thread From: Rene Herman @ 2007-09-15 15:59 UTC (permalink / raw) To: Denys Vlasenko Cc: Adrian Bunk, H. Peter Anvin, Kai Germaschewski, Sam Ravnborg, Linux Kernel, ALSA devel On 09/15/2007 05:53 PM, Denys Vlasenko wrote: > Can you give a bit more info what the dirrefences between devices are > in this particular cases? It's ISA. Thanks, but never mind guys, I only wanted to know something about kbuild. Rene. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-09-15 15:59 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-09-14 23:07 Per option CFLAGS? Rene Herman 2007-09-14 23:13 ` H. Peter Anvin 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:52 ` Adrian Bunk 2007-09-15 15:53 ` Denys Vlasenko 2007-09-15 15:59 ` Rene Herman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).