win: Add -mno-ms-bitfields
[profile/ivi/syslinux.git] / win32 / Makefile
1 ## -----------------------------------------------------------------------
2 ##
3 ##   Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
4 ##   Copyright 2010 Intel Corporation; author: H. Peter Anvin
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 # Makefile for SYSLINUX Win32
16 #
17 # This is separated out mostly so we can have a different set of Makefile
18 # variables.
19 #
20
21 OSTYPE   = $(shell uname -msr)
22 ifeq ($(findstring CYGWIN,$(OSTYPE)),CYGWIN)
23 ## Compiling on Cygwin
24 WINPREFIX  :=
25 WINCFLAGS  := -mno-cygwin -mno-ms-bitfields $(GCCWARN) -Os \
26               -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
27 WINLDFLAGS := -mno-cygwin -Os -s
28 else
29 ## Compiling on some variant of MinGW
30 ifeq ($(findstring MINGW32,$(OSTYPE)),MINGW32)
31 WINPREFIX  :=
32 else
33 WINPREFIX  := $(shell ./find-mingw32.sh gcc)
34 endif
35 WINCFLAGS  := -mno-ms-bitfields $(GCCWARN) -Wno-sign-compare -Os \
36               -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
37 WINLDFLAGS := -Os -s
38 endif
39 WINCFLAGS += -I. -I../win -I.. -I../libfat -I../libinstaller \
40              -I../libinstaller/getopt
41
42 WINCC      := $(WINPREFIX)gcc
43 WINAR      := $(WINPREFIX)ar
44 WINRANLIB  := $(WINPREFIX)ranlib
45
46 WINCC_IS_GOOD := $(shell $(WINCC) $(WINCFLAGS) $(WINLDFLAGS) \
47         -o hello.exe ../win/hello.c >/dev/null 2>&1 ; echo $$?)
48
49 .SUFFIXES: .c .obj .lib .exe .i .s .S
50
51 SRCS     = ../win/syslinux.c ../win/ntfssect.c
52 OBJS     = $(patsubst %.c,%.obj,$(notdir $(SRCS)))
53 LIBSRC   = ../libinstaller/fs.c \
54            ../libinstaller/syslxmod.c \
55            ../libinstaller/syslxopt.c \
56            ../libinstaller/setadv.c \
57            ../libinstaller/getopt/getopt_long.c \
58            ../libinstaller/bootsect_bin.c \
59            ../libinstaller/ldlinux_bin.c \
60            ../libinstaller/mbr_bin.c \
61            $(wildcard ../libfat/*.c)
62 LIBOBJS  = $(patsubst %.c,%.obj,$(notdir $(LIBSRC)))
63
64 LIB      = syslinux.lib
65
66 VPATH = .:../win:../libfat:../libinstaller:../libinstaller/getopt
67
68 TARGETS = syslinux.exe
69
70 ifeq ($(WINCC_IS_GOOD),0)
71 all: $(TARGETS)
72 else
73 all:
74         rm -f $(TARGETS)
75 endif
76
77 tidy dist:
78         -rm -f *.o *.obj *.lib *.i *.s *.a .*.d *.tmp *_bin.c hello.exe
79
80 clean: tidy
81
82 spotless: clean
83         -rm -f *~ $(TARGETS)
84
85 installer:
86
87 $(LIB): $(LIBOBJS)
88         rm -f $@
89         $(WINAR) cq $@ $^
90         $(WINRANLIB) $@
91
92 syslinux.exe: $(OBJS) $(LIB)
93         $(WINCC) $(WINLDFLAGS) -o $@ $^
94
95
96 %.obj: %.c
97         $(WINCC) $(UMAKEDEPS) $(WINCFLAGS) -c -o $@ $<
98 %.i: %.c
99         $(WINCC) $(UMAKEDEPS) $(WINCFLAGS) -E -o $@ $<
100 %.s: %.c
101         $(WINCC) $(UMAKEDEPS) $(WINCFLAGS) -S -o $@ $<
102
103 -include .*.d *.tmp