Merge branch 'master' into core32
[profile/ivi/syslinux.git] / win32 / Makefile
1 ## -----------------------------------------------------------------------
2 ##
3 ##   Copyright 1998-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 # Makefile for SYSLINUX Win32
15 #
16 # This is separated out mostly so we can have a different set of Makefile
17 # variables.
18 #
19
20 OSTYPE   = $(shell uname -msr)
21 ifeq ($(findstring CYGWIN,$(OSTYPE)),CYGWIN)
22 ## Compiling on Cygwin
23 WINPREFIX  :=
24 WINCFLAGS  := -mno-cygwin -W -Wall -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
25 WINLDFLAGS := -mno-cygwin -Os -s
26 else
27 ## Compiling on some variant of MinGW
28 ifeq ($(findstring MINGW32,$(OSTYPE)),MINGW32)
29 WINPREFIX  :=
30 else
31 WINPREFIX  := $(shell ./find-mingw.sh gcc)
32 endif
33 WINCFLAGS  := -W -Wall -Wno-sign-compare -Os -fomit-frame-pointer \
34               -D_FILE_OFFSET_BITS=64
35 WINLDFLAGS := -Os -s
36 endif
37 WINCFLAGS += -I. -I.. -I../libfat -I../libinstaller
38
39 WINCC      := $(WINPREFIX)gcc
40 WINAR      := $(WINPREFIX)ar
41 WINRANLIB  := $(WINPREFIX)ranlib
42
43 WINCC_IS_GOOD := $(shell $(WINCC) $(WINCFLAGS) $(WINLDFLAGS) -o hello.exe hello.c >/dev/null 2>&1 ; echo $$?)
44
45 .SUFFIXES: .c .o .i .s .S
46
47 SRCS     = syslinux.c \
48            ../libinstaller/syslxmod.c \
49            ../libinstaller/bootsect_bin.c \
50            ../libinstaller/ldlinux_bin.c \
51            ../libinstaller/mbr_bin.c \
52            $(wildcard ../libfat/*.c)
53 OBJS     = $(patsubst %.c,%.o,$(notdir $(SRCS)))
54
55 VPATH = .:../libfat:../libinstaller
56
57 TARGETS = syslinux.exe
58
59 ifeq ($(WINCC_IS_GOOD),0)
60 all: $(TARGETS)
61 else
62 all:
63         rm -f $(TARGETS)
64 endif
65
66 tidy dist:
67         -rm -f *.o *.i *.s *.a .*.d *.tmp *_bin.c hello.exe
68
69 clean: tidy
70
71 spotless: clean
72         -rm -f *~ $(TARGETS)
73
74 installer:
75
76 syslinux.exe: $(OBJS)
77         $(WINCC) $(WINLDFLAGS) -o $@ $^
78
79
80 %.o: %.c
81         $(WINCC) $(UMAKEDEPS) $(WINCFLAGS) -c -o $@ $<
82 %.i: %.c
83         $(WINCC) $(UMAKEDEPS) $(WINCFLAGS) -E -o $@ $<
84 %.s: %.c
85         $(WINCC) $(UMAKEDEPS) $(WINCFLAGS) -S -o $@ $<
86
87 -include .*.d *.tmp