1 #ident "$Id: Makefile,v 1.29 2004/12/29 01:58:02 hpa Exp $"
2 ## -----------------------------------------------------------------------
4 ## Copyright 2001-2004 H. Peter Anvin - All Rights Reserved
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 ## Boston MA 02111-1307, USA; either version 2 of the License, or
10 ## (at your option) any later version; incorporated herein by reference.
12 ## -----------------------------------------------------------------------
14 VERSION := $(shell cat ../version)
16 gcc_ok = $(shell if gcc $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; \
17 then echo $(1); else echo $(2); fi)
19 M32 := $(call gcc_ok,-m32,)
20 ALIGN := $(call gcc_ok,-falign-functions=0 -falign-jumps=0 -falign-loops=0,-malign-functions=0 -malign-jumps=0 -malign-loops=0)
23 CFLAGS = -g -W -Wall -Wno-sign-compare \
24 -Os -fomit-frame-pointer -march=i386 $(ALIGN) \
25 -DVERSION='"$(VERSION)"' -DDATE='"$(DATE)"'
27 INCLUDE = -I../com32/include
30 NFLAGS = -dVERSION='"$(VERSION)"' -dDATE='"$(DATE)"'
35 # Important: init.o16 must be first!!
36 OBJS16 = init.o16 init32.o
37 OBJS32 = start32.o setup.o msetup.o e820func.o conio.o memcpy.o memset.o \
40 CSRC = setup.c msetup.c e820func.c conio.c unzip.c
42 NASMSRC = memdisk.asm memdisk16.asm
46 # tidy, clean removes everything except the final binary
48 rm -f *.o *.s *.o16 *.s16 *.bin *.lst *.elf e820test
52 # spotless also removes the product binary
57 $(NASM) $(NFLAGS) -f elf -l $*.lst -o $@ $<
60 $(CC) -x assembler -c -o $@ $<
63 $(CC) -x assembler -c -o $@ $<
66 $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $<
69 echo '.code16gcc' | cat - $< > $@
72 $(CC) -x c $(INCLUDE) $(CFLAGS) -traditional -E -o $@ $<
75 $(CC) -x c $(INCLUDE) $(CFLAGS) -traditional -E -o $@ $<
78 $(CC) $(INCLUDE) $(CFLAGS) -S -o $@ $<
81 $(CC) $(INCLUDE) $(CFLAGS) -E -o $@ $<
87 $(NASM) -f bin $(NFLAGS) $(NINCLUDE) -o $@ -l $*.lst $<
89 memdisk16.elf: $(OBJS16)
90 $(LD) -Ttext 0 -o $@ $^
92 memdisk32.elf: $(OBJS32)
93 $(LD) -Ttext 0x100000 -o $@ $^
96 $(OBJCOPY) -O binary $< $@
98 memdisk: memdisk16.bin memdisk32.bin postprocess.pl
99 $(PERL) postprocess.pl $@ memdisk16.bin memdisk32.bin
101 e820test: e820func.o msetup.o e820test.o memdisk.o
102 $(CC) $(LDFLAGS) -o $@ $^
104 memdisk.o: memdisk.bin
105 $(LD) -r -b binary -o $@ $<
109 for csrc in *.c ; do $(CC) $(INCLUDE) -MM $$csrc | sed -e 's/\.o/\.s/' >> .depend ; done
110 for ssrc in $(SSRC) ; do $(CC) $(INCLUDE) -x c -traditional -MM $$ssrc | sed -e 's/\.S16\.o/\.o16/' >> .depend ; done
111 for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
117 # This file contains the version number, so add a dependency for it
120 # Include dependencies file