Centralize configurables; better "make install" etc
[profile/ivi/syslinux.git] / com32 / samples / Makefile
1 ## -----------------------------------------------------------------------
2 ##
3 ##   Copyright 2001-2008 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.
10 ##
11 ## -----------------------------------------------------------------------
12
13 ##
14 ## samples for syslinux users
15 ##
16
17 TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
18 CC      = gcc
19
20 gcc_ok   = $(shell tmpf=$(TMPFILE); if $(CC) $(1) -c -x c /dev/null -o $$tmpf 2>/dev/null; \
21                    then echo $(1); else echo $(2); fi; rm -f $$tmpf)
22
23 M32     := $(call gcc_ok,-m32,) $(call gcc_ok,-fno-stack-protector,)
24
25 LD         = ld -m elf_i386
26 AR         = ar
27 NASM       = nasm
28 NASMOPT    = -O9999
29 RANLIB     = ranlib
30 CFLAGS     = $(M32) -mregparm=3 -DREGPARM=3 -W -Wall -march=i386 -Os \
31              -fomit-frame-pointer -D__COM32__ \
32              -nostdinc -iwithprefix include \
33              -I../libutil/include -I../include \
34              -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d
35 LNXCFLAGS  = -W -Wall -O -g -I../libutil/include
36 LNXSFLAGS  = -g
37 LNXLDFLAGS = -g
38 SFLAGS     = -D__COM32__ -march=i386
39 LDFLAGS    = -T ../lib/com32.ld
40 OBJCOPY    = objcopy
41 LIBGCC    := $(shell $(CC) --print-libgcc)
42 LIBS       = ../libutil/libutil_com.a ../lib/libcom32.a $(LIBGCC)
43 LNXLIBS    = ../libutil/libutil_lnx.a
44
45 .SUFFIXES: .lss .c .o .elf .c32 .lnx
46
47 all:    hello.c32 cat.c32 resolv.c32 vesainfo.c32 serialinfo.c32 \
48         localboot.c32 \
49         fancyhello.c32 fancyhello.lnx \
50         keytest.c32 keytest.lnx \
51         advdump.c32
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 tidy dist:
81         rm -f *.o *.lo *.a *.lst *.elf .*.d
82
83 clean: tidy
84         rm -f *.lss *.c32 *.lnx *.com
85
86 spotless: clean
87         rm -f *~ \#*
88
89 install:        # Don't install samples
90
91 -include .*.d