Merge commit 'syslinux-3.60-pre6' into gpxe-support
[profile/ivi/syslinux.git] / mbr / Makefile
1 ## -----------------------------------------------------------------------
2 ##
3 ##   Copyright 2007 H. Peter Anvin - All Rights Reserved
4 ##
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.
10 ##
11 ## -----------------------------------------------------------------------
12
13 #
14 # Makefile for MBR
15 #
16
17 TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
18
19 gcc_ok   = $(shell tmpf=$(TMPFILE); if gcc $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
20                    then echo $(1); else echo $(2); fi; rm -f $$tmpf)
21
22 M32       := $(call gcc_ok,-m32,) $(call gcc_ok,-ffreestanding,) $(call gcc_ok,-fno-stack-protector)
23
24 CC         = gcc
25 LD         = ld -m elf_i386
26 SFLAGS     = $(M32) -march=i386
27 OBJCOPY    = objcopy
28 PERL       = perl
29
30 .SUFFIXES: .S .s .o .elf
31
32 all:    mbr.bin
33
34 .PRECIOUS: %.o
35 %.o: %.S
36         $(CC) $(SFLAGS) -Wa,-a=$*.lst -c -o $@ $<
37
38 mbr.elf: mbr.o mbr.ld
39         $(LD) -T mbr.ld -e _start -o $@ $<
40
41 mbr.bin: mbr.elf checksize.pl
42         $(OBJCOPY) -O binary $< $@
43         $(PERL) checksize.pl mbr.bin 440
44
45 tidy:
46         rm -f *.o *.elf *.lst
47
48 clean: tidy
49
50 spotless: clean
51         rm -f *.bin