1CC	=	gcc
2LD	=	ld
3
4KERNEL	=	/usr/src/linux
5#KERNEL	=	/lib/modules/`uname -r`/build
6
7ARCH	=	$(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/)
8
9ifeq ($(KERNEL)/.config,$(wildcard $(KERNEL)/.config))
10include $(KERNEL)/.config
11endif
12
13CFLAGS	=	-D__KERNEL__ -I${KERNEL}/include  -Wall	\
14		-Wstrict-prototypes -Wno-trigraphs -O2	\
15		-fomit-frame-pointer -fno-common	\
16		-fno-strict-aliasing -pipe -DMODULE
17
18# comment this if you don't want debugging information
19CFLAGS += -DDEBUG
20
21# see if we need module versions
22ifdef CONFIG_MODVERSIONS
23CFLAGS += -DMODVERSIONS
24endif
25
26ifeq ($(ARCH),alpha)
27CFLAGS	+=	-mno-fp-regs -ffixed-8 -mcpu=ev5 -Wa,-mev6
28LDFLAGS  =	-m elf64alpha
29endif
30
31ifeq ($(ARCH),sparc64)
32CFLAGS	+=	-mno-fpu -mtune=ultrasparc -mmedlow -ffixed-g4 \
33		-fcall-used-g5 -fcall-used-g7
34LDFLAGS	 =	-m elf_sparc64
35endif
36
37ifeq ($(ARCH),i386)
38CFLAGS	+=	-mpreferred-stack-boundary=2 -march=i586
39LDFLAGS  =	-m elf_i386
40endif
41
42ifeq ($(ARCH), x86_64)
43CFLAGS	+=	-mno-red-zone -mcmodel=kernel -fno-reorder-blocks \
44		-finline-limit=2000 -fno-strength-reduce
45LDFLAGS	 =	-m elf_x86_64
46endif
47
48ifeq ($(ARCH),ia64)
49CFLAGS  +=	-ffixed-r13 -mfixed-range=f10-f15,f32-f127 \
50		-falign-functions=32
51LDFLAGS  =      -m elf64_ia64
52endif
53
54.SUFFIXES: .o .c .h
55
56TARGET	=	bios.o
57OBJS	=	bios_core.o flashchips.o pcisets.o \
58		filesystem.o procfs.o programming.o
59
60all: $(TARGET) comp
61
62$(TARGET): $(OBJS)
63	$(LD) $(LDFLAGS) -r -o $(TARGET) $(OBJS)
64
65clean:
66	-rm -f $(TARGET) $(OBJS) comp *.o
67
68.c.o:
69	$(CC) $(INCLUDES) -c $(INCDIRS) $(CFLAGS) $(X_CFLAGS) $(DEBUGFLAGS) $*.c -o $@
70
71comp:	comp.c
72	$(CC) comp.c -O2 -o comp
73	strip comp
74
75bios_core.o:	bios_core.c bios.h pcisets.h flashchips.h programming.h
76filesystem.o:	filesystem.c bios.h pcisets.h flashchips.h programming.h
77flashchips.o:	flashchips.c bios.h flashchips.h
78pcisets.o:	pcisets.c bios.h pcisets.h flashchips.h programming.h
79procfs.o:	procfs.c bios.h pcisets.h flashchips.h programming.h
80programming.o:	programming.c bios.h pcisets.h flashchips.h programming.h
81
82