syslinux-3.08-2 sources from FC4
[bootcd.git] / syslinux / menu / Makefile
1 #ident "$Id: Makefile,v 1.9 2005/04/28 23:12:09 hpa Exp $"
2 ## -----------------------------------------------------------------------
3 ##   
4 ##   Copyright 2001-2005 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 COM32DIR   = ../com32
29 LUDIR      = $(COM32DIR)/libutil
30 LDIR       = $(COM32DIR)/lib
31 CFLAGS     = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os -fomit-frame-pointer -I$(LUDIR)/include -I$(COM32DIR)/include  -Ilibmenu -D__COM32__
32 SFLAGS     = -D__COM32__ -march=i386
33 LDFLAGS    = -T $(LDIR)/com32.ld 
34 OBJCOPY    = objcopy
35 LIBGCC    := $(shell $(CC) --print-libgcc)
36
37 LIBS       = libmenu/libmenu.a $(LUDIR)/libutil_com.a $(LDIR)/libcom32.a $(LIBGCC)
38
39 LIBMENU = libmenu/syslnx.o libmenu/com32io.o libmenu/tui.o \
40         libmenu/menu.o libmenu/passwords.o libmenu/des.o libmenu/help.o 
41
42 MENUS = $(patsubst %.c,%.c32,$(wildcard *.c))
43
44 .SUFFIXES: .S .c .o .elf .c32 
45
46 .PRECIOUS: %.o
47 %.o: %.S
48         $(CC) $(SFLAGS) -c -o $@ $<
49
50 .PRECIOUS: %.o
51 %.o: %.c %.h
52         $(CC) $(CFLAGS) -c -o $@ $<
53
54 .PRECIOUS: %.elf 
55 %.elf: %.o $(LIBS)
56         $(LD) $(LDFLAGS) -o $@ $^ 
57
58 %.c32: %.elf
59         $(OBJCOPY) -O binary $< $@
60
61 all: menus
62
63 libmenu/libmenu.a: $(LIBMENU)
64         -rm -f $@
65         $(AR) cq $@ $^
66         $(RANLIB) $@
67
68 tidy:
69         rm -f *.o *.lo *.a *.lst *.elf libmenu/*.o libmenu/*.a
70
71 clean: tidy
72         rm -f *.lss *.c32 *.com
73
74 spotless: clean
75         rm -f *~ \#*
76
77 menus: $(MENUS)
78
79 install:        # Don't install samples