## -----------------------------------------------------------------------
-##
+##
## Copyright 2007 H. Peter Anvin - All Rights Reserved
##
## This program is free software; you can redistribute it and/or modify
# Makefile for MBR
#
-gcc_ok = $(shell if gcc $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; \
- then echo $(1); else echo $(2); fi)
+TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
+
+gcc_ok = $(shell tmpf=$(TMPFILE); if gcc $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
+ then echo $(1); else echo $(2); fi; rm -f $$tmpf)
-M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-ffreestanding,)
+M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-ffreestanding,) $(call gcc_ok,-fno-stack-protector)
CC = gcc
LD = ld -m elf_i386
%.o: %.S
$(CC) $(SFLAGS) -Wa,-a=$*.lst -c -o $@ $<
-mbr.elf: mbr.o
- $(LD) -Ttext 0x600 -e _start -o $@ $^
+mbr.elf: mbr.o mbr.ld
+ $(LD) -T mbr.ld -e _start -o $@ $<
mbr.bin: mbr.elf checksize.pl
$(OBJCOPY) -O binary $< $@
rm -f *.o *.elf *.lst
clean: tidy
+
+spotless: clean
rm -f *.bin