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