scsi2sd-util crash on exit fix (again)
[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 # liblzma not available on OSX 10.7
12 WX_CONFIG=--disable-webkit --disable-webviewwebkit  \
13         --without-libtiff --without-libjbig --without-liblzma --without-opengl \
14         --enable-monolithic --enable-stl --disable-shared
15
16 TARGET ?= $(shell uname -s)
17 ifeq ($(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++
23         LIBZIPPER_CONFIG+=--host=i686-w64-mingw32
24         EXE=.exe
25         WX_CONFIG+=--host=i686-w64-mingw32
26 endif
27 ifeq ($(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++
33         LIBZIPPER_CONFIG+=--host=x86_64-w64-mingw32
34         EXE=.exe
35         WX_CONFIG+=--host=x86_64-w64-mingw32
36 endif
37 ifeq ($(TARGET),Linux)
38         VPATH += hidapi/linux
39         LDFLAGS += -ludev -lexpat
40         BUILD = build/linux
41 endif
42 ifeq ($(TARGET),Darwin)
43         # Should match OSX
44         VPATH += hidapi-mac
45         LDFLAGS += -framework IOKit -framework CoreFoundation -lexpat
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
49         BUILD=build/mac
50 endif
51
52 export CC CXX
53
54 all:  $(BUILD)/scsi2sd-util$(EXE) $(BUILD)/scsi2sd-monitor$(EXE)
55
56 CYAPI = \
57         $(BUILD)/cybtldr_api2.o \
58         $(BUILD)/cybtldr_api.o \
59         $(BUILD)/cybtldr_command.o \
60         $(BUILD)/cybtldr_parse.o \
61
62
63 HIDAPI = \
64         $(BUILD)/hid.o \
65
66
67 OBJ = \
68         $(CYAPI) $(HIDAPI) \
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
76 EXEOBJ = \
77         $(BUILD)/scsi2sd-util.o \
78         $(BUILD)/scsi2sd-monitor.o \
79
80
81
82 $(OBJ): $(BUILD)/zlib/buildstamp
83 $(EXEOBJ): $(BUILD)/zlib/buildstamp
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
94 $(OBJ): $(BUILD)/wx.buildstamp
95 $(EXEOBJ): $(BUILD)/wx.buildstamp
96 $(BUILD)/wx.buildstamp: $(BUILD)/zlib/buildstamp
97         mkdir -p $(dir $@)
98         ( \
99                 cd $(BUILD) && \
100                 $(CURDIR)/wxWidgets/configure $(WX_CONFIG) CPPFLAGS=-I../zlib LDFLAGS=-I../zlib && \
101                 $(MAKE) \
102         ) && \
103         touch $@
104
105 $(OBJ): $(BUILD)/libzipper/buildstamp
106 $(EXEOBJ): $(BUILD)/libzipper/buildstamp
107 $(BUILD)/libzipper/buildstamp: $(BUILD)/zlib/buildstamp
108         mkdir -p $(dir $@)
109         ( \
110                 cd $(dir $@) && \
111                 $(CURDIR)/libzipper-1.0.4/configure ${LIBZIPPER_CONFIG} --disable-shared --enable-static && \
112                 $(MAKE) libzipper.la \
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
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
129         mkdir -p $(dir $@)
130         $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) `$(BUILD)/wx-config --libs` -o $@
131
132 clean:
133         rm $(BUILD)/scsi2sd-util$(EXE) $(OBJ) $(BUILD)/libzipper/buildstamp
134