syslinux-3.08-2 sources from FC4
[bootcd.git] / syslinux / sample / Makefile
1 #ident "$Id: Makefile,v 1.23 2005/01/03 08:23:16 hpa Exp $"
2 ## -----------------------------------------------------------------------
3 ##   
4 ##   Copyright 2001-2004 H. Peter Anvin - All Rights Reserved
5 ##
6 ##   This program is free software; you can redistribute it and/or modify
7 ##   it under the terms of the GNU General Public License as published by
8 ##   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 ##   Boston MA 02111-1307, USA; either version 2 of the License, or
10 ##   (at your option) any later version; incorporated herein by reference.
11 ##
12 ## -----------------------------------------------------------------------
13
14 ##
15 ## samples for syslinux users
16 ##
17
18 gcc_ok   = $(shell if gcc $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; \
19                    then echo $(1); else echo $(2); fi)
20
21 M32       := $(call gcc_ok,-m32,) $(call gcc_ok,-ffreestanding,)
22
23 CC         = gcc $(M32)
24 LD         = ld -m elf_i386
25 AR         = ar
26 NASM       = nasm
27 RANLIB     = ranlib
28 CFLAGS     = -W -Wall -march=i386 -Os -fomit-frame-pointer -I../com32/include
29 SFLAGS     = -march=i386
30 LDFLAGS    = -s
31 OBJCOPY    = objcopy
32 PPMTOLSS16 =    ../ppmtolss16
33 LIB        = liboldcom32.a
34
35 LIBOBJS    = conio.o atou.o skipatou.o printf.o c32exit.o
36
37 ARCH := $(shell uname -m)
38 ifneq (x86_64, $ARCH)
39 CFLAGS += -m32
40 SFLAGS += -m32
41 LDFLAGS += -m elf_i386
42 endif
43
44 .SUFFIXES: .lss .c .o .elf .c32
45
46 all: syslogo.lss comecho.com hello.c32 hello2.c32 filetest.c32 c32echo.c32 \
47      fd.c32 $(LIB)
48
49 .PRECIOUS: %.o
50 %.o: %.S
51         $(CC) $(SFLAGS) -c -o $@ $<
52
53 .PRECIOUS: %.o
54 %.o: %.c
55         $(CC) $(CFLAGS) -c -o $@ $<
56
57 .PRECIOUS: %.elf
58 %.elf: c32entry.o %.o $(LIB)
59         $(LD) $(LDFLAGS) -Ttext 0x101000 -e _start -o $@ $^
60
61 %.c32: %.elf
62         $(OBJCOPY) -O binary $< $@
63
64 %.com: %.asm
65         $(NASM) -f bin -o $@ -l $*.lst $<
66
67 $(LIB): $(LIBOBJS)
68         rm -f $@
69         $(AR) cq $@ $^
70         $(RANLIB) $@
71
72 syslogo.lss:    syslogo.png $(PPMTOLSS16)
73         pngtopnm syslogo.png | \
74                 $(PPMTOLSS16) \#000000=0 \#d0d0d0=7 \#f6f6f6=15 \
75                 > syslogo.lss
76
77 tidy:
78         rm -f *.o *.a *.lst *.elf
79
80 # Don't specify *.com since mdiskchk.com can't be built using Linux tools
81 clean: tidy
82         rm -f *.lss *.o *.c32 comecho.com
83
84 spotless: clean