summaryrefslogtreecommitdiff
path: root/win32/Makefile
blob: ef5edac11aadd7607de062a044c2d009cbaff468 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
## -----------------------------------------------------------------------
##
##   Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
##   Copyright 2010 Intel Corporation; author: H. Peter Anvin
##
##   This program is free software; you can redistribute it and/or modify
##   it under the terms of the GNU General Public License as published by
##   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
##   Boston MA 02111-1307, USA; either version 2 of the License, or
##   (at your option) any later version; incorporated herein by reference.
##
## -----------------------------------------------------------------------

#
# Makefile for SYSLINUX Win32
#
# This is separated out mostly so we can have a different set of Makefile
# variables.
#

OSTYPE   = $(shell uname -msr)
ifeq ($(findstring CYGWIN,$(OSTYPE)),CYGWIN)
## Compiling on Cygwin
WINPREFIX  :=
WINCFLAGS  := -mno-cygwin -mno-ms-bitfields $(GCCWARN) -Os \
	      -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
WINLDFLAGS := -mno-cygwin -Os -s
else
## Compiling on some variant of MinGW
ifeq ($(findstring MINGW32,$(OSTYPE)),MINGW32)
WINPREFIX  :=
else
WINPREFIX  := $(shell ./find-mingw32.sh gcc)
endif
WINCFLAGS  := -mno-ms-bitfields $(GCCWARN) -Wno-sign-compare -Os \
	      -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
WINLDFLAGS := -Os -s
endif
WINCFLAGS += -I. -I../win -I.. -I../libfat -I../libinstaller \
	     -I../libinstaller/getopt

WINCC      := $(WINPREFIX)gcc
WINAR	   := $(WINPREFIX)ar
WINRANLIB  := $(WINPREFIX)ranlib

WINCC_IS_GOOD := $(shell $(WINCC) $(WINCFLAGS) $(WINLDFLAGS) \
	-o hello.exe ../win/hello.c >/dev/null 2>&1 ; echo $$?)

.SUFFIXES: .c .obj .lib .exe .i .s .S

SRCS     = ../win/syslinux.c ../win/ntfssect.c
OBJS     = $(patsubst %.c,%.obj,$(notdir $(SRCS)))
LIBSRC   = ../libinstaller/fs.c \
	   ../libinstaller/syslxmod.c \
	   ../libinstaller/syslxopt.c \
	   ../libinstaller/setadv.c \
	   ../libinstaller/getopt/getopt_long.c \
	   ../libinstaller/bootsect_bin.c \
	   ../libinstaller/ldlinux_bin.c \
	   ../libinstaller/mbr_bin.c \
	   $(wildcard ../libfat/*.c)
LIBOBJS  = $(patsubst %.c,%.obj,$(notdir $(LIBSRC)))

LIB	 = syslinux.lib

VPATH = .:../win:../libfat:../libinstaller:../libinstaller/getopt

TARGETS = syslinux.exe

ifeq ($(WINCC_IS_GOOD),0)
all: $(TARGETS)
else
all:
	rm -f $(TARGETS)
endif

tidy dist:
	-rm -f *.o *.obj *.lib *.i *.s *.a .*.d *.tmp *_bin.c hello.exe

clean: tidy

spotless: clean
	-rm -f *~ $(TARGETS)

installer:

$(LIB): $(LIBOBJS)
	rm -f $@
	$(WINAR) cq $@ $^
	$(WINRANLIB) $@

syslinux.exe: $(OBJS) $(LIB)
	$(WINCC) $(WINLDFLAGS) -o $@ $^


%.obj: %.c
	$(WINCC) $(UMAKEDEPS) $(WINCFLAGS) -c -o $@ $<
%.i: %.c
	$(WINCC) $(UMAKEDEPS) $(WINCFLAGS) -E -o $@ $<
%.s: %.c
	$(WINCC) $(UMAKEDEPS) $(WINCFLAGS) -S -o $@ $<

-include .*.d *.tmp