CC	=	gcc
LD	=	ld

KERNEL	=	/usr/src/linux
#KERNEL  =	/lib/modules/`uname -r`/build

CFLAGS	=	-D__KERNEL__ -I${KERNEL}/include  \
		-Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
		-fomit-frame-pointer -fno-common -DMODULE \
		-DDEBUG

ARCH	=	$(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/)

ifeq ($(ARCH),alpha)
CFLAGS	+=	-pipe -mno-fp-regs -ffixed-8 -Wno-uninitialized -mcpu=ev5 -Wa,-mev6
LDFLAGS =	-m elf64alpha
endif

ifeq ($(ARCH),sparc64)
CFLAGS	+=	-pipe -mno-fpu -mtune=ultrasparc -mmedlow \
		-ffixed-g4 -fcall-used-g5 -fcall-used-g7 -Wno-sign-compare
LDFLAGS	=	-m elf_sparc 
endif

ifeq ($(ARCH),i386)
CFLAGS	+=	-pipe -mpreferred-stack-boundary=2 -march=i686 
LDFLAGS +=	-m elf_i386
endif

ifeq ($(ARCH),ia64)
LDFLAGS +=      -m elf64_ia64
endif

.SUFFIXES: .o .c .h

# INCLUDES	+=	-I./include

TARGET	=	bios.o
OBJS	=	bios_core.o flashchips.o pcisets.o filesystem.o procfs.o programming.o

all: $(TARGET) comp

$(TARGET): $(OBJS)
	$(LD) $(LDFLAGS) -r -o $(TARGET) $(OBJS)

clean:
	-rm -f $(TARGET) $(OBJS) comp *.o

.c.o:
	$(CC) $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $*.c -o $@

comp:	comp.c
	$(CC) comp.c -O2 -o comp
	strip comp
