Fix utility Makefiles to output Windows binaries using mingw
[SCSI2SD.git] / software / bootloaderhost / Makefile
1 VPATH=cybootloaderutils
2
3 CPPFLAGS = -I cybootloaderutils -I hidapi/hidapi
4 CFLAGS += -Wall -Wno-pointer-sign -O2
5 CXXFLAGS += -Wall -std=c++11 -O2
6
7 TARGET ?= $(shell uname -s)
8 ifeq ($(TARGET),Win32)
9         VPATH += hidapi/windows
10         LDFLAGS += -mconsole -mwindows -lsetupapi
11         BUILD = build/windows/32bit
12         CC=i686-w64-mingw32-gcc
13         CXX=i686-w64-mingw32-g++
14         EXE=.exe
15 endif
16 ifeq ($(TARGET),Win64)
17         VPATH += hidapi/windows
18         LDFLAGS += -mconsole -mwindows -lsetupapi
19         BUILD = build/windows/64bit
20         CC=x86_64-w64-mingw32-gcc
21         CXX=x86_64-w64-mingw32-g++
22         EXE=.exe
23 endif
24 ifeq ($(TARGET),Linux)
25         VPATH += hidapi/linux
26         LDFLAGS += -ludev
27         BUILD = build/linux
28 endif
29 ifeq ($(TARGET),Darwin)
30         # Should match OSX
31         VPATH += hidapi/mac
32         LDFLAGS += -framework IOKit -framework CoreFoundation
33         CPPFLAGS += -isysroot /Xcode3.1.4/SDKs/MacOSX10.5.sdk
34         CFLAGS += -mmacosx-version-min=10.5 -arch x86_64 -arch i386 -arch ppc
35         CXXFLAGS += -mmacosx-version-min=10.5 -arch x86_64 -arch i386 -arch ppc
36         CC=/Xcode3.1.4/usr/bin/gcc
37         CXX=/Xcode3.1.4/usr/bin/g++
38         BUILD=build/mac
39 endif
40
41 all:  $(BUILD)/bootloaderhost$(EXE)
42
43 CYAPI = \
44         $(BUILD)/cybtldr_api2.o \
45         $(BUILD)/cybtldr_api.o \
46         $(BUILD)/cybtldr_command.o \
47         $(BUILD)/cybtldr_parse.o \
48
49
50 HIDAPI = \
51         $(BUILD)/hid.o \
52
53
54 OBJ = \
55         $(CYAPI) $(HIDAPI) \
56         $(BUILD)/main.o \
57         $(BUILD)/Firmware.o \
58         $(BUILD)/SCSI2SD_Bootloader.o \
59         $(BUILD)/SCSI2SD_HID.o \
60
61 $(BUILD)/%.o: %.c
62         mkdir -p $(dir $@)
63         $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c -o $@
64
65 $(BUILD)/%.o: %.cc
66         mkdir -p $(dir $@)
67         $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -c -o $@
68
69 $(BUILD)/bootloaderhost$(EXE): $(OBJ)
70         mkdir -p $(dir $@)
71         $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
72
73 clean:
74         rm $(BUILD)/bootloaderhost$(EXE) $(OBJ)
75