Merging upstream version 3.60~pre6.
[syslinux-debian/hramrach.git] / sample / Makefile
blob9ad854095e3b30c61f0c4cd0a21a5f46b586d30c
1 ## -----------------------------------------------------------------------
2 ##
3 ## Copyright 2001-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.
11 ## -----------------------------------------------------------------------
14 ## samples for syslinux users
17 TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
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)
22 M32 := $(call gcc_ok,-m32,) $(call gcc_ok,-ffreestanding,) $(call gcc_ok,-fno-stack-protector,)
24 CC = gcc
25 LD = ld -m elf_i386
26 AR = ar
27 NASM = nasm
28 NASMOPT = -O9999
29 RANLIB = ranlib
30 CFLAGS = $(M32) -W -Wall -march=i386 -Os -fomit-frame-pointer -I../com32/include
31 SFLAGS = $(M32) -march=i386
32 LDFLAGS = -s
33 OBJCOPY = objcopy
34 PPMTOLSS16 = ../ppmtolss16
35 LIB = liboldcom32.a
37 LIBOBJS = conio.o atou.o skipatou.o printf.o c32exit.o
39 .SUFFIXES: .lss .c .o .elf .c32
41 all: syslogo.lss comecho.com hello.c32 hello2.c32 filetest.c32 c32echo.c32 \
42 fd.c32 $(LIB)
44 .PRECIOUS: %.o
45 %.o: %.S
46 $(CC) $(SFLAGS) -c -o $@ $<
48 .PRECIOUS: %.o
49 %.o: %.c
50 $(CC) $(CFLAGS) -c -o $@ $<
52 .PRECIOUS: %.elf
53 %.elf: c32entry.o %.o $(LIB)
54 $(LD) -Ttext 0x101000 -e _start -o $@ $^
56 %.c32: %.elf
57 $(OBJCOPY) -O binary $< $@
59 %.com: %.asm
60 $(NASM) $(NASMOPT) -f bin -o $@ -l $*.lst $<
62 $(LIB): $(LIBOBJS)
63 rm -f $@
64 $(AR) cq $@ $^
65 $(RANLIB) $@
67 syslogo.lss: syslogo.png $(PPMTOLSS16)
68 pngtopnm syslogo.png | \
69 $(PPMTOLSS16) \#000000=0 \#d0d0d0=7 \#f6f6f6=15 \
70 > syslogo.lss
72 tidy:
73 rm -f *.o *.a *.lst *.elf
75 # Don't specify *.com since mdiskchk.com can't be built using Linux tools
76 clean: tidy
77 rm -f *.lss *.o *.c32 comecho.com
79 spotless: clean