8d785c643bb8b1a2feb0e22003157c7a67380e23
[SCSI2SD-V6.git] / software / scsi2sd-util / Makefile
1 VPATH=cybootloaderutils ../SCSI2SD/src
2
3 ifeq ($(USE_SYSTEM), Yes)
4 USE_SYSTEM_HIDAPI = Yes
5 USE_SYSTEM_ZLIB = Yes
6 USE_SYSTEM_WX = Yes
7 endif
8
9 CPPFLAGS_HIDAPI=$(shell pkg-config hidapi-hidraw --cflags)
10 CPPFLAGS_ZLIB=$(shell pkg-config zlib --cflags)
11
12 CPPFLAGS = -I cybootloaderutils $(CPPFLAGS_HIDAPI) -I ../include -Ilibzipper-1.0.4 $(CPPFLAGS_ZLIB)
13 CFLAGS += -Wall -Wno-pointer-sign -O2 -g
14 CXXFLAGS += -Wall -O2 -g -std=c++0x
15
16 LDFLAGS_ZLIB=$(shell pkg-config zlib --libs)
17 LDFLAGS_HIDAPI=$(shell pkg-config hidapi-hidraw --libs)
18
19 LDFLAGS += -L$(BUILD)/libzipper/.libs -lzipper $(LDFLAGS_ZLIB) $(LDFLAGS_HIDAPI)
20
21 LIBZIPPER_CONFIG = --disable-shared LDFLAGS="$(LDFLAGS_ZLIB)" CPPFLAGS="$(CPPFLAGS_ZLIB)"
22
23 # wxWidgets 3.0.2 uses broken Webkit headers under OSX Yosemeti
24 # liblzma not available on OSX 10.7
25 WX_CONFIG=--disable-webkit --disable-webviewwebkit  \
26         --without-libtiff --without-libjbig --without-liblzma --without-opengl \
27         --enable-monolithic --enable-stl --disable-shared
28
29 TARGET ?= $(shell uname -s)
30 ifeq ($(TARGET),Win32)
31         VPATH += hidapi/windows
32         LDFLAGS += -static -mconsole -mwindows -lsetupapi
33         BUILD = build/windows/32bit
34         CC=i686-w64-mingw32-gcc
35         CXX=i686-w64-mingw32-g++
36         LIBZIPPER_CONFIG+=--host=i686-w64-mingw32
37         EXE=.exe
38         WX_CONFIG+=--host=i686-w64-mingw32
39 endif
40 ifeq ($(TARGET),Win64)
41         VPATH += hidapi/windows
42         LDFLAGS += -static -mconsole -mwindows -lsetupapi
43         BUILD = build/windows/64bit
44         CC=x86_64-w64-mingw32-gcc
45         CXX=x86_64-w64-mingw32-g++
46         LIBZIPPER_CONFIG+=--host=x86_64-w64-mingw32
47         EXE=.exe
48         WX_CONFIG+=--host=x86_64-w64-mingw32
49 endif
50 ifeq ($(TARGET),Linux)
51         VPATH += hidapi/linux
52         LDFLAGS += -ludev -lexpat
53         BUILD = build/linux
54 endif
55 ifeq ($(TARGET),Darwin)
56         # Should match OSX
57         VPATH += hidapi-mac
58         LDFLAGS += -framework IOKit -framework CoreFoundation -lexpat
59         CC=clang -mmacosx-version-min=10.7
60         CXX=clang++ -stdlib=libc++ -mmacosx-version-min=10.7
61         WX_CONFIG += --with-macosx-version-min=10.7
62         BUILD=build/mac
63 endif
64
65 export CC CXX
66
67 all:  $(BUILD)/scsi2sd-util$(EXE) $(BUILD)/scsi2sd-monitor$(EXE)
68
69 CYAPI = \
70         $(BUILD)/cybtldr_api2.o \
71         $(BUILD)/cybtldr_api.o \
72         $(BUILD)/cybtldr_command.o \
73         $(BUILD)/cybtldr_parse.o \
74
75
76 ifneq ($(USE_SYSTEM_HIDAPI),Yes)
77 HIDAPI = \
78         $(BUILD)/hid.o
79 endif
80
81
82 OBJ = \
83         $(CYAPI) $(HIDAPI) \
84         $(BUILD)/ConfigUtil.o \
85         $(BUILD)/Firmware.o \
86         $(BUILD)/TargetPanel.o \
87         $(BUILD)/SCSI2SD_Bootloader.o \
88         $(BUILD)/SCSI2SD_HID.o \
89         $(BUILD)/hidpacket.o \
90
91 EXEOBJ = \
92         $(BUILD)/scsi2sd-util.o \
93         $(BUILD)/scsi2sd-monitor.o \
94
95
96
97 ifneq ($(USE_SYSTEM_ZLIB),Yes)
98 $(OBJ): $(BUILD)/zlib/buildstamp
99 $(EXEOBJ): $(BUILD)/zlib/buildstamp
100 $(BUILD)/zlib/buildstamp:
101         mkdir -p $(dir $@)
102         ( \
103                 cd $(dir $@) && \
104                 cp -a $(CURDIR)/zlib-1.2.8/* . && \
105                 ./configure --static && \
106                 $(MAKE) \
107         ) && \
108         touch $@
109 endif
110
111 ifneq ($(USE_SYSTEM_WX),Yes)
112 $(OBJ): $(BUILD)/wx.buildstamp
113 $(EXEOBJ): $(BUILD)/wx.buildstamp
114 ifneq ($(USE_SYSTEM_ZLIB),Yes)
115 $(BUILD)/wx.buildstamp: $(BUILD)/zlib/buildstamp
116 else
117 $(BUILD)/wx.buildstamp:
118 endif
119         mkdir -p $(dir $@)
120         ( \
121                 cd $(BUILD) && \
122                 $(CURDIR)/wxWidgets/configure $(WX_CONFIG) CPPFLAGS="$(CPPFLAGS_ZLIB)" LDFLAGS="$(LDFLAGS_ZLIB)" && \
123                 $(MAKE) \
124         ) && \
125         touch $@
126 endif
127
128 ifneq ($(USE_SYSTEM_ZLIB),Yes)
129 LIBZIPPER_STATIC=-enable-static
130 endif
131
132 $(OBJ): $(BUILD)/libzipper/buildstamp
133 $(EXEOBJ): $(BUILD)/libzipper/buildstamp
134 ifneq ($(USE_SYSTEM_ZLIB),Yes)
135 $(BUILD)/libzipper/buildstamp: $(BUILD)/zlib/buildstamp
136 else
137 $(BUILD)/libzipper/buildstamp:
138 endif
139         mkdir -p $(dir $@)
140         ( \
141                 cd $(dir $@) && \
142                 $(CURDIR)/libzipper-1.0.4/configure ${LIBZIPPER_CONFIG} --disable-shared $(LIBZIPPER_STATIC) && \
143                 $(MAKE) libzipper.la \
144         ) && \
145         touch $@
146
147 $(BUILD)/%.o: %.c
148         mkdir -p $(dir $@)
149         $(CC) $(CPPFLAGS) $(CFLAGS) $< -c -o $@
150
151 $(BUILD)/%.o: %.cc
152         mkdir -p $(dir $@)
153 ifneq ($(USE_SYSTEM_WX),Yes)
154         $(CXX) $(CPPFLAGS) $(CXXFLAGS) `$(BUILD)/wx-config --cxxflags` $< -c -o $@
155 else
156         $(CXX) $(CPPFLAGS) $(CXXFLAGS) `wx-config-3.0 --cxxflags` $< -c -o $@
157 endif
158
159 $(BUILD)/scsi2sd-util$(EXE): $(OBJ) $(BUILD)/scsi2sd-util.o
160         mkdir -p $(dir $@)
161 ifneq ($(USE_SYSTEM_WX),Yes)
162         $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) `$(BUILD)/wx-config --libs` -o $@
163 else
164         $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) `wx-config-3.0 --libs` -o $@
165 endif
166
167 $(BUILD)/scsi2sd-monitor$(EXE): $(OBJ) $(BUILD)/scsi2sd-monitor.o
168         mkdir -p $(dir $@)
169 ifneq ($(USE_SYSTEM_WX),Yes)
170         $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) `$(BUILD)/wx-config --libs` -o $@
171 else
172         $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) `wx-config-3.0 --libs` -o $@
173 endif
174
175 clean:
176         rm $(BUILD)/scsi2sd-util$(EXE) $(OBJ) $(BUILD)/libzipper/buildstamp
177