1 ## -----------------------------------------------------------------------
3 ## Copyright 2001-2008 H. Peter Anvin - All Rights Reserved
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 ## Boston MA 02111-1307, USA; either version 2 of the License, or
9 ## (at your option) any later version; incorporated herein by reference.
11 ## -----------------------------------------------------------------------
13 VERSION
:= $(shell cat ..
/version
)
15 TMPFILE
= $(shell mktemp
/tmp
/gcc_ok.XXXXXX
)
17 gcc_ok
= $(shell tmpf
=$(TMPFILE
); if
$(CC
) $(1) -c
-x c
/dev
/null
-o
$$tmpf 2>/dev
/null
; \
18 then echo
$(1); else echo
$(2); fi
; rm -f
$$tmpf)
20 M32
:= $(call gcc_ok
,-m32
,)
21 ALIGN
:= $(call gcc_ok
,-falign-functions
=0 -falign-jumps
=0 -falign-loops
=0,-malign-functions
=0 -malign-jumps
=0 -malign-loops
=0)
22 FREE
:= $(call gcc_ok
,-ffreestanding
,) $(call gcc_ok
,-fno-stack-protector
,)
25 CFLAGS
= $(M32
) $(FREE
) -g
-W
-Wall
-Wno-sign-compare \
26 -Os
-fomit-frame-pointer
-march
=i386
$(ALIGN
) \
27 -DVERSION
='"$(VERSION)"' -DDATE
='"$(DATE)"'
28 SFLAGS
= $(M32
) -march
=i386
-D__ASSEMBLY__
30 INCLUDE
= -I..
/com32
/include
34 NFLAGS
= -dVERSION
='"$(VERSION)"' -dDATE
='"$(DATE)"' -dWITH_EDD
39 # Important: init.o16 must be first!!
40 OBJS16
= init.o16 init32.o
41 OBJS32
= start32.o setup.o msetup.o e820func.o conio.o memcpy.o memset.o \
44 CSRC
= setup.c msetup.c e820func.c conio.c unzip.c
45 SSRC
= start32.S memcpy.S memset.S
46 NASMSRC
= memdisk.asm memdisk16.asm
48 all: memdisk
# e820test
50 # tidy, clean removes everything except the final binary
52 rm -f
*.o
*.s
*.o16
*.s16
*.bin
*.lst
*.elf e820test
56 # spotless also removes the product binary
61 $(NASM
) $(NASMOPT
) $(NFLAGS
) $(NINCLUDE
) -f elf
-l
$*.lst
-o
$@
$<
64 $(CC
) $(SFLAGS
) -c
-o
$@
$<
67 $(CC
) $(INCLUDE
) $(SFLAGS
) -c
-o
$@
$<
70 $(CC
) $(SFLAGS
) -x assembler
-c
-o
$@
$<
73 $(CC
) $(INCLUDE
) $(CFLAGS
) -c
-o
$@
$<
76 echo
'.code16gcc' | cat
- $< > $@
79 $(CC
) $(INCLUDE
) $(SFLAGS
) -E
-o
$@
$<
82 $(CC
) $(INCLUDE
) $(SFLAGS
) -x assembler-with-cpp
-E
-o
$@
$<
85 $(CC
) $(INCLUDE
) $(CFLAGS
) -S
-o
$@
$<
88 $(CC
) $(INCLUDE
) $(CFLAGS
) -E
-o
$@
$<
94 $(NASM
) -f bin
$(NASMOPT
) $(NFLAGS
) $(NINCLUDE
) -o
$@
-l
$*.lst
$<
96 memdisk16.elf
: $(OBJS16
)
97 $(LD
) -Ttext
0 -o
$@
$^
99 memdisk32.elf
: $(OBJS32
)
100 $(LD
) -Ttext
0x100000 -o
$@
$^
103 $(OBJCOPY
) -O binary
$< $@
105 memdisk
: memdisk16.bin memdisk32.bin postprocess.pl
106 $(PERL
) postprocess.pl
$@ memdisk16.bin memdisk32.bin
108 e820test
: e820func.o msetup.o e820test.o memdisk.o
109 $(CC
) $(LDFLAGS
) -o
$@
$^
111 memdisk.o
: memdisk.bin
112 $(LD
) -r
-b binary
-o
$@
$<
116 for csrc in
*.c
; do
$(CC
) $(INCLUDE
) $(CFLAGS
) -MM
$$csrc >> .depend
; done
117 for ssrc in
*.S
; do
$(CC
) $(INCLUDE
) $(SFLAGS
) -MM
$$ssrc >> .depend
; done
118 for nsrc in
$(NASMSRC
) ; do
$(NASM
) -DDEPEND
$(NINCLUDE
) -o
`echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M
$$nsrc >> .depend
; done
124 # This file contains the version number, so add a dependency for it
127 # Include dependencies file