6ae637196011d6ee0c898feb65208750ecee893b
[profile/ivi/syslinux.git] / mbr / Makefile
1 ## -----------------------------------------------------------------------
2 ##
3 ##   Copyright 2007-2008 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 topdir = ..
18 include $(topdir)/MCONFIG
19
20 GCCOPT    := $(call gcc_ok,-m32,) \
21              $(call gcc_ok,-ffreestanding,) \
22              $(call gcc_ok,-fno-stack-protector) \
23              -march=i386 -Os
24
25 LDFLAGS    = -m elf_i386
26 SFLAGS     = $(GCCOPT)
27
28 .SUFFIXES: .S .s .o .elf
29
30 all:    mbr.bin gptmbr.bin
31
32 .PRECIOUS: %.o
33 %.o: %.S
34         $(CC) $(SFLAGS) -Wa,-a=$*.lst -c -o $@ $<
35
36 mbr.elf: mbr.o mbr.ld
37         $(LD) $(LDFLAGS) -T mbr.ld -e _start -o $@ $<
38
39 mbr.bin: mbr.elf checksize.pl
40         $(OBJCOPY) -O binary $< $@
41         $(PERL) checksize.pl mbr.bin 440
42
43 mbr_bin.c: mbr.bin
44
45 gptmbr.elf: gptmbr.o mbr.ld
46         $(LD) $(LDFLAGS) -T mbr.ld -e _start -o $@ $<
47
48 gptmbr.bin: gptmbr.elf checksize.pl
49         $(OBJCOPY) -O binary $< $@
50         $(PERL) checksize.pl gptmbr.bin 424
51
52 tidy dist:
53         rm -f *.o *.elf *.lst
54
55 clean: tidy
56
57 spotless: clean
58         rm -f *.bin