Merge branch 'scsi2sd-util'
[SCSI2SD-V6.git] / software / scsi2sd-util / Makefile
1 VPATH=cybootloaderutils ../SCSI2SD/src
2
3 CPPFLAGS = -I cybootloaderutils -I hidapi/hidapi -I ../include -Ilibzipper-1.0.4 -I$(BUILD)/zlib
4 CFLAGS += -Wall -Wno-pointer-sign -O2 -g
5 CXXFLAGS += -Wall -O2 -g -std=c++0x
6 LDFLAGS += -L$(BUILD)/libzipper/.libs -lzipper -L$(BUILD)/zlib -lz
7
8 LIBZIPPER_CONFIG = --disable-shared LDFLAGS="-L../zlib" CPPFLAGS="-I../zlib"
9
10 # wxWidgets 3.0.2 uses broken Webkit headers under OSX Yosemeti
11 WX_CONFIG=--disable-webkit --disable-webviewwebkit  \
12         --enable-monolithic --enable-stl --disable-shared
13
14 TARGET ?= $(shell uname -s)
15 ifeq ($(TARGET),Win32)
16         VPATH += hidapi/windows
17         LDFLAGS += -static -mconsole -mwindows -lsetupapi
18         BUILD = build/windows/32bit
19         CC=i686-w64-mingw32-gcc
20         CXX=i686-w64-mingw32-g++
21         LIBZIPPER_CONFIG+=--host=i686-w64-mingw32
22         EXE=.exe
23         WX_CONFIG+=--host=i686-w64-mingw32
24 endif
25 ifeq ($(TARGET),Win64)
26         VPATH += hidapi/windows
27         LDFLAGS += -static -mconsole -mwindows -lsetupapi
28         BUILD = build/windows/64bit
29         CC=x86_64-w64-mingw32-gcc
30         CXX=x86_64-w64-mingw32-g++
31         LIBZIPPER_CONFIG+=--host=x86_64-w64-mingw32
32         EXE=.exe
33         WX_CONFIG+=--host=x86_64-w64-mingw32
34 endif
35 ifeq ($(TARGET),Linux)
36         VPATH += hidapi/linux
37         LDFLAGS += -ludev
38         BUILD = build/linux
39 endif
40 ifeq ($(TARGET),Darwin)
41         # Should match OSX
42         VPATH += hidapi-mac
43         LDFLAGS += -framework IOKit -framework CoreFoundation
44         CC=clang -mmacosx-version-min=10.7
45         CXX=clang++ -stdlib=libc++ -mmacosx-version-min=10.7
46         WX_CONFIG += --with-macosx-version-min=10.7
47         BUILD=build/mac
48 endif
49
50 export CC CXX
51
52 all:  $(BUILD)/scsi2sd-util$(EXE)
53
54 CYAPI = \
55         $(BUILD)/cybtldr_api2.o \
56         $(BUILD)/cybtldr_api.o \
57         $(BUILD)/cybtldr_command.o \
58         $(BUILD)/cybtldr_parse.o \
59
60
61 HIDAPI = \
62         $(BUILD)/hid.o \
63
64
65 OBJ = \
66         $(CYAPI) $(HIDAPI) \
67         $(BUILD)/scsi2sd-util.o \
68         $(BUILD)/ConfigUtil.o \
69         $(BUILD)/Firmware.o \
70         $(BUILD)/TargetPanel.o \
71         $(BUILD)/SCSI2SD_Bootloader.o \
72         $(BUILD)/SCSI2SD_HID.o \
73         $(BUILD)/hidpacket.o \
74
75
76 $(OBJ): $(BUILD)/zlib/buildstamp
77 $(BUILD)/zlib/buildstamp:
78         mkdir -p $(dir $@)
79         ( \
80                 cd $(dir $@) && \
81                 cp -a $(CURDIR)/zlib-1.2.8/* . && \
82                 ./configure --static && \
83                 $(MAKE) \
84         ) && \
85         touch $@
86
87 $(OBJ): $(BUILD)/wx.buildstamp
88 $(BUILD)/wx.buildstamp: $(BUILD)/zlib/buildstamp
89         mkdir -p $(dir $@)
90         ( \
91                 cd $(BUILD) && \
92                 $(CURDIR)/wxWidgets/configure $(WX_CONFIG) CPPFLAGS=-I../zlib LDFLAGS=-I../zlib && \
93                 $(MAKE) \
94         ) && \
95         touch $@
96
97 $(OBJ): $(BUILD)/libzipper/buildstamp
98 $(BUILD)/libzipper/buildstamp: $(BUILD)/zlib/buildstamp
99         mkdir -p $(dir $@)
100         ( \
101                 cd $(dir $@) && \
102                 $(CURDIR)/libzipper-1.0.4/configure ${LIBZIPPER_CONFIG} --disable-shared --enable-static && \
103                 $(MAKE) libzipper.la \
104         ) && \
105         touch $@
106
107 $(BUILD)/%.o: %.c
108         mkdir -p $(dir $@)
109         $(CC) $(CPPFLAGS) $(CFLAGS) $< -c -o $@
110
111 $(BUILD)/%.o: %.cc
112         mkdir -p $(dir $@)
113         $(CXX) $(CPPFLAGS) $(CXXFLAGS) `$(BUILD)/wx-config --cxxflags` $< -c -o $@
114
115 $(BUILD)/scsi2sd-util$(EXE): $(OBJ)
116         mkdir -p $(dir $@)
117         $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) `$(BUILD)/wx-config --libs` -o $@
118
119 clean:
120         rm $(BUILD)/scsi2sd-util$(EXE) $(OBJ) $(BUILD)/libzipper/buildstamp
121