d1ae7453cc9f8f2b7125ddae2ada16e7826476ab
[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
40 BUILD = build/linux
41 endif
42 ifeq ($(TARGET),Darwin)
43 # Should match OSX
44 VPATH += hidapi-mac
45 LDFLAGS += -framework IOKit -framework CoreFoundation
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)
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)/scsi2sd-util.o \
70 $(BUILD)/ConfigUtil.o \
71 $(BUILD)/Firmware.o \
72 $(BUILD)/TargetPanel.o \
73 $(BUILD)/SCSI2SD_Bootloader.o \
74 $(BUILD)/SCSI2SD_HID.o \
75 $(BUILD)/hidpacket.o \
76
77
78 $(OBJ): $(BUILD)/zlib/buildstamp
79 $(BUILD)/zlib/buildstamp:
80 mkdir -p $(dir $@)
81 ( \
82 cd $(dir $@) && \
83 cp -a $(CURDIR)/zlib-1.2.8/* . && \
84 ./configure --static && \
85 $(MAKE) \
86 ) && \
87 touch $@
88
89 $(OBJ): $(BUILD)/wx.buildstamp
90 $(BUILD)/wx.buildstamp: $(BUILD)/zlib/buildstamp
91 mkdir -p $(dir $@)
92 ( \
93 cd $(BUILD) && \
94 $(CURDIR)/wxWidgets/configure $(WX_CONFIG) CPPFLAGS=-I../zlib LDFLAGS=-I../zlib && \
95 $(MAKE) \
96 ) && \
97 touch $@
98
99 $(OBJ): $(BUILD)/libzipper/buildstamp
100 $(BUILD)/libzipper/buildstamp: $(BUILD)/zlib/buildstamp
101 mkdir -p $(dir $@)
102 ( \
103 cd $(dir $@) && \
104 $(CURDIR)/libzipper-1.0.4/configure ${LIBZIPPER_CONFIG} --disable-shared --enable-static && \
105 $(MAKE) libzipper.la \
106 ) && \
107 touch $@
108
109 $(BUILD)/%.o: %.c
110 mkdir -p $(dir $@)
111 $(CC) $(CPPFLAGS) $(CFLAGS) $< -c -o $@
112
113 $(BUILD)/%.o: %.cc
114 mkdir -p $(dir $@)
115 $(CXX) $(CPPFLAGS) $(CXXFLAGS) `$(BUILD)/wx-config --cxxflags` $< -c -o $@
116
117 $(BUILD)/scsi2sd-util$(EXE): $(OBJ)
118 mkdir -p $(dir $@)
119 $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) `$(BUILD)/wx-config --libs` -o $@
120
121 clean:
122 rm $(BUILD)/scsi2sd-util$(EXE) $(OBJ) $(BUILD)/libzipper/buildstamp
123