6868b2b8467d3424e3236741470f72ed1e248556
[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         CFLAGS += -mmacosx-version-min=10.7
34         CXXFLAGS += -stdlib=libc++ -mmacosx-version-min=10.7
35         CC=clang
36         CXX=clang++
37         BUILD=build/mac
38 endif
39
40 all:  $(BUILD)/bootloaderhost$(EXE)
41
42 CYAPI = \
43         $(BUILD)/cybtldr_api2.o \
44         $(BUILD)/cybtldr_api.o \
45         $(BUILD)/cybtldr_command.o \
46         $(BUILD)/cybtldr_parse.o \
47
48
49 HIDAPI = \
50         $(BUILD)/hid.o \
51
52
53 OBJ = \
54         $(CYAPI) $(HIDAPI) \
55         $(BUILD)/main.o \
56         $(BUILD)/Firmware.o \
57         $(BUILD)/SCSI2SD_Bootloader.o \
58         $(BUILD)/SCSI2SD_HID.o \
59
60 $(BUILD)/%.o: %.c
61         mkdir -p $(dir $@)
62         $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c -o $@
63
64 $(BUILD)/%.o: %.cc
65         mkdir -p $(dir $@)
66         $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -c -o $@
67
68 $(BUILD)/bootloaderhost$(EXE): $(OBJ)
69         mkdir -p $(dir $@)
70         $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
71
72 clean:
73         rm $(BUILD)/bootloaderhost$(EXE) $(OBJ)
74