syslinux-3.08-2 sources from FC4
[bootcd.git] / syslinux / com32 / modules / Makefile
1 #ident "$Id: Makefile,v 1.21 2005/05/08 21:47:04 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,)
22
23 CC         = gcc
24 LD         = ld -m elf_i386
25 AR         = ar
26 NASM       = nasm
27 RANLIB     = ranlib
28 CFLAGS     = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os -fomit-frame-pointer -I../libutil/include -I../include  -D__COM32__
29 LNXCFLAGS  = -W -Wall -O -g -I../libutil/include
30 LNXSFLAGS  = -g
31 LNXLDFLAGS = -g
32 SFLAGS     = -D__COM32__ -march=i386
33 LDFLAGS    = -T ../lib/com32.ld
34 OBJCOPY    = objcopy
35 PPMTOLSS16 =    ../ppmtolss16
36 LIBGCC    := $(shell $(CC) --print-libgcc)
37 LIBS       = ../libutil/libutil_com.a ../lib/libcom32.a $(LIBGCC)
38 LNXLIBS    = ../libutil/libutil_lnx.a
39
40 .SUFFIXES: .lss .c .o .elf .c32 .lnx
41
42 BINDIR   = /usr/bin
43 LIBDIR   = /usr/lib
44 AUXDIR   = $(LIBDIR)/syslinux
45 INCDIR   = /usr/include
46 COM32DIR = $(AUXDIR)/com32
47
48 MODULES   = chain.c32 menu.c32 ethersel.c32 mboot.c32
49 TESTFILES = menu.lnx
50
51 all: $(MODULES) $(TESTFILES)
52
53 .PRECIOUS: %.o
54 %.o: %.S
55         $(CC) $(SFLAGS) -c -o $@ $<
56
57 .PRECIOUS: %.o
58 %.o: %.c
59         $(CC) $(CFLAGS) -c -o $@ $<
60
61 .PRECIOUS: %.elf
62 %.elf: %.o $(LIBS)
63         $(LD) $(LDFLAGS) -o $@ $^
64
65 .PRECIOUS: %.lo
66 %.lo: %.S
67         $(CC) $(LNXSFLAGS) -c -o $@ $<
68
69 .PRECIOUS: %.lo
70 %.lo: %.c
71         $(CC) $(LNXCFLAGS) -c -o $@ $<
72
73 .PRECIOUS: %.lnx
74 %.lnx: %.lo $(LNXLIBS)
75         $(CC) $(LNXLDFLAGS) -o $@ $^
76
77 %.c32: %.elf
78         $(OBJCOPY) -O binary $< $@
79
80 menu.elf : menu.o readconfig.o $(LIBS)
81         $(LD) $(LDFLAGS) -o $@ $^
82
83 menu.lnx : menu.lo readconfig.lo $(LNXLIBS)
84         $(CC) $(LNXLDFLAGS) -o $@ $^
85
86 tidy:
87         rm -f *.o *.lo *.a *.lst *.elf
88
89 clean: tidy
90         rm -f *.lss *.c32 *.lnx *.com
91
92 spotless: clean
93         rm -f *~ \#*
94
95 install: all
96         mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
97         install -m 644 $(MODULES) $(INSTALLROOT)$(AUXDIR)
98