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

From: Ingo Oeser (ingo.oeser@informatik.tu-chemnitz.de)
Date: Fri Apr 07 2000 - 04:16:46 EST


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>

There are special *.h files with the right defintitions for each
"special" variant of the device. The "vanilla" variant is the
unmodified one and just there to show the default behavior.

<cite src=s5933_iipci44.h>

/*
 * Modified S5933 addresses of the Innovative Integration PCI44 DSP board
 * $Id: s5933_iipci44.h,v 1.3 2000/01/04 08:11:18 ioe Exp $
 *
 * Note: non-existent registers are set to INT_MAX
 */

#ifndef S5933_IIPCI144_H
#include <linux/kernel.h>
#define S5933_IIPCI144_H

#undef S5933_REGS_START
#undef S5933_OMB_START
#undef S5933_IMB_START
#undef S5933_FIFO
#define S5933_MWAR INT_MAX
#undef S5933_MBEF
#undef S5933_INTCSR
#undef S5933_MCSR
#undef S5933_REGS_END
#include "s5933_chip.h"

#endif /* S5933_IIPCI144_H */
</cite>

Problem solved? Questions?

Regards

Ingo Oeser

-- 
Feel the power of the penguin - run linux@your.pc
<esc>:x

- 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