Stealth whitespace cleanup (automated)
[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 gcc_ok   = $(shell if gcc $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; \
18                    then echo $(1); else echo $(2); fi)
19
20 M32       := $(call gcc_ok,-m32,) $(call gcc_ok,-ffreestanding,) $(call gcc_ok,-fno-stack-protector)
21
22 CC         = gcc
23 LD         = ld -m elf_i386
24 SFLAGS     = $(M32) -march=i386
25 OBJCOPY    = objcopy
26 PERL       = perl
27
28 .SUFFIXES: .S .s .o .elf
29
30 all:    mbr.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) -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 tidy:
44         rm -f *.o *.elf *.lst
45
46 clean: tidy
47         rm -f *.bin