Re: Multiple .o files from single .c file - how?

From: willy@thepuffingroup.com
Date: Fri Apr 07 2000 - 11:01:17 EST


On Fri, Apr 07, 2000 at 11:16:46AM +0200, Ingo Oeser wrote:
> On 7 Apr 2000, Krzysztof Halasa wrote:
>
> > It's not practical - most of driver code use (MM)IO instructions, the
> > common part would be empty and both MMIO and IO modules would be
> > nearly identical.
> >
> > It would be best to:
> > gcc -DUSE_MMIO driver.c -o driver-mmio.o
> > and
> > gcc -DUSE_IO driver.c -o driver-io.o
> >
> > but I don't now if there is a clean way to do it in Makefile(s).
>
> There is a (somewhat) clean way to do that:
>
> <cite src=Makefile>
> # $Id: Makefile,v 1.4 2000/02/20 03:51:43 ioe Exp $
>
> EXTRA_CFLAGS = -DDEBUG
>
> M_OBJS = s5933_vanilla.o s5933_iipci44.o
>
> # Special targets
>
> # need this, because kernel Makefiles are too stupid for this
> clean:
> -rm -f $(MI_OBJS) $(MIX_OBJS) $(M_OBJS) $(MX_OBJS) .*.o.flags *~
> -rm s5933_vanilla.c s5933_iipci44.c
>
> # The basic chip with the full interface implemented
> s5933_vanilla.c: s5933_chip.h s5933_chip.c
> sed 's:\(^#include "\)\(s5933\).h":\1\2_chip.h":' <s5933_chip.c >$@
>
> # The Innovative Integration PCI44 version of this chip
> s5933_iipci44.c: s5933_iipci44.h s5933_chip.h s5933_chip.c
> sed 's:\(^#include "\)\(s5933\).h":\1\2_iipci44.h":' <s5933_chip.c >$@
>
> include $(KERNEL_LOCATION)/Rules.make
>
> </cite>

How horrible. A better way to do this is with the per-file define method
which is already provided:

CFLAGS_init_task0.o = -DALIGN=0
CFLAGS_init_task1.o = -DALIGN=1
CFLAGS_init_task2.o = -DALIGN=2
CFLAGS_init_task3.o = -DALIGN=3

init_task0.o init_task1.o init_task2.o init_task3.o : init_task.c
       $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c -o $@ $<

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Apr 07 2000 - 21:00:18 EST