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

From: H. Peter Anvin (hpa@transmeta.com)
Date: Fri Apr 07 2000 - 16:26:47 EST


Followup to: <m366tue1oz.fsf@intrepid.pm.waw.pl>
By author: Krzysztof Halasa <khc@intrepid.pm.waw.pl>
In newsgroup: linux.dev.kernel
>
> greyham@research.canon.com.au (Graham Stoney) writes:
>
> > Krzysztof Halasa writes:
> > > There are two cards which are almost identical but one of them uses
> > > MMIO while the other uses regular IO. Of course, I'd like to have only
> > > one copy of driver source code and I want two binary drivers which can
> > > be selected and compiled independently.
> >
> > I believe the preferred approach is to split it into three modules: MMIO, IO
> > and common stuff, where MMIO and IO depend on the module with the common
> > stuff.
>
> 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).
>
> Of course, having identical (link?) driver-mmio.c and driver-io.c would do.
>

/* driver-mmio.c */
#define DRIVER_USE_MMIO 1
#include "driver-common.h"

/* driver-pio.c */
#define DRIVER_USE_PIO 1
#include "driver-common.h"

         -hpa

-- 
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
"Unix gives you enough rope to shoot yourself in the foot."

- 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:19 EST