1 ## -----------------------------------------------------------------------
3 ## Copyright 2007-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 ## -----------------------------------------------------------------------
17 TMPFILE
= $(shell mktemp
/tmp
/gcc_ok.XXXXXX
)
19 gcc_ok
= $(shell tmpf
=$(TMPFILE
); if
$(CC
) $(1) -c
-x c
/dev
/null
-o
$$tmpf 2>/dev
/null
; \
20 then echo
$(1); else echo
$(2); fi
; rm -f
$$tmpf)
22 M32
:= $(call gcc_ok
,-m32
,) $(call gcc_ok
,-ffreestanding
,) $(call gcc_ok
,-fno-stack-protector
)
27 SFLAGS
= $(M32
) -march
=i386
31 .SUFFIXES
: .S .s .o .elf
33 all: mbr.bin mbr_bin.c gptmbr.bin gptmbr_bin.c
37 $(CC
) $(SFLAGS
) -Wa
,-a
=$*.lst
-c
-o
$@
$<
39 %_bin.c
: %.bin ..
/bin2c.pl
40 $(PERL
) ..
/bin2c.pl syslinux_
$* < $< > $@
43 $(LD
) $(LDFLAGS
) -T mbr.
ld -e _start
-o
$@
$<
45 mbr.bin
: mbr.elf checksize.pl
46 $(OBJCOPY
) -O binary
$< $@
47 $(PERL
) checksize.pl mbr.bin
440
51 gptmbr.elf
: gptmbr.o mbr.
ld
52 $(LD
) $(LDFLAGS
) -T mbr.
ld -e _start
-o
$@
$<
54 gptmbr.bin
: gptmbr.elf checksize.pl
55 $(OBJCOPY
) -O binary
$< $@
56 $(PERL
) checksize.pl gptmbr.bin
424