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