Adding upstream version 3.51.
[syslinux-debian/hramrach.git] / menu / Makefile
blob702f4563e705fe88c03be69b986d370a83d5fd06
1 ## -----------------------------------------------------------------------
2 ##
3 ## Copyright 2001-2005 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,-fno-stack-protector,)
24 CC = gcc
25 LD = ld -m elf_i386
26 AR = ar
27 NASM = nasm
28 RANLIB = ranlib
29 COM32DIR = ../com32
30 LUDIR = $(COM32DIR)/libutil
31 LDIR = $(COM32DIR)/lib
32 CFLAGS = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os -fomit-frame-pointer -I$(LUDIR)/include -I$(COM32DIR)/include -Ilibmenu -D__COM32__
33 SFLAGS = -D__COM32__ -march=i386
34 LDFLAGS = -T $(LDIR)/com32.ld
35 OBJCOPY = objcopy
36 LIBGCC := $(shell $(CC) --print-libgcc)
38 LIBS = libmenu/libmenu.a $(LUDIR)/libutil_com.a $(LDIR)/libcom32.a $(LIBGCC)
40 LIBMENU = libmenu/syslnx.o libmenu/com32io.o libmenu/tui.o \
41 libmenu/menu.o libmenu/passwords.o libmenu/des.o libmenu/help.o
43 CMENUS = $(patsubst %.c,%.c32,$(wildcard *.c))
44 IMENUS = $(patsubst %.menu,%.c32,$(wildcard *.menu))
46 MENUS = $(CMENUS) $(IMENUS)
48 .SUFFIXES: .S .c .o .elf .c32 .menu
50 .PRECIOUS: %.c
51 %.c: %.menu adv_menu.tpl
52 python menugen.py --input=$< --output=$@ --template=adv_menu.tpl
54 .PRECIOUS: %.o
55 %.o: %.S
56 $(CC) $(SFLAGS) -c -o $@ $<
58 .PRECIOUS: %.o
59 %.o: %.c %.h
60 $(CC) $(CFLAGS) -c -o $@ $<
62 .PRECIOUS: %.elf
63 %.elf: %.o $(LIBS)
64 $(LD) $(LDFLAGS) -o $@ $^
66 %.c32: %.elf
67 $(OBJCOPY) -O binary $< $@
69 all: menus
71 libmenu/libmenu.a: $(LIBMENU)
72 -rm -f $@
73 $(AR) cq $@ $^
74 $(RANLIB) $@
76 tidy:
77 rm -f *.o *.lo *.a *.lst *.elf
79 libclean:
80 rm -f libmenu/*.o libmenu/*.a
82 clean: tidy menuclean
83 rm -f *.lss *.c32 *.com
85 menuclean:
86 rm -f $(patsubst %.menu,%.c,$(wildcard *.menu))
88 spotless: clean libclean menuclean
89 rm -f *~ \#*
91 menus: $(MENUS)
93 install: # Don't install samples