Lots of bug fixing, and 4.7 merges
[SCSI2SD-V6.git] / src / scsi2sd-util6 / Makefile
index 3cd88aa..42e1d9b 100755 (executable)
@@ -1,4 +1,4 @@
-VPATH=../firmware
+VPATH=../firmware TerminalWx/src TerminalWx/src/taTelnet TerminalWx/src/GTerm
 
 VERSION=6.0
 NAME=scsi2sd-util6
@@ -7,6 +7,15 @@ ifeq ($(USE_SYSTEM), Yes)
 USE_SYSTEM_HIDAPI = Yes
 USE_SYSTEM_ZLIB = Yes
 USE_SYSTEM_WX = Yes
+USE_SYSTEM_LIBUSB = Yes
+endif
+
+ifeq ($(USE_SYSTEM_LIBUSB), Yes)
+CPPFLAGS_LIBUSB=$(shell pkg-config libusb-1.0 --cflags)
+LDFLAGS_LIBUSB=$(shell pkg-config libusb-1.0 --libs)
+else
+CPPFLAGS_LIBUSB=-I $(PWD)/libusb-1.0.20/libusb
+LDFLAGS_LIBUSB=-L $(BUILD)/libusb/libusb/.libs -lusb-1.0
 endif
 
 ifeq ($(USE_SYSTEM_HIDAPI), Yes)
@@ -33,16 +42,26 @@ else
 LDFLAGS_WX=$(shell $(BUILD)/wx/wx-config --libs)
 endif
 
-CPPFLAGS = $(CPPFLAGS_HIDAPI) -I. -I ../../include -Ilibzipper-1.0.4 $(CPPFLAGS_ZLIB)
-CFLAGS += -Wall -Wno-pointer-sign -O2 -g
-CXXFLAGS += -Wall -O2 -g -std=c++0x
+CPPFLAGS = $(CPPFLAGS_HIDAPI) -I. -I ../../include -ITerminalWx/src \
+       -Ilibzipper-1.0.4 \
+       $(CPPFLAGS_ZLIB) \
+       $(CPPFLAGS_LIBUSB) \
+       -DHAVE_LIBUSB_1_0 \
+
 
-LDFLAGS += -L$(BUILD)/libzipper/.libs -lzipper $(LDFLAGS_ZLIB) $(LDFLAGS_HIDAPI)
+CFLAGS += -Wall -Wno-pointer-sign -O2 -g -fPIC
+CXXFLAGS += -Wall -O2 -g -std=c++0x -fPIC
+
+LDFLAGS += -L$(BUILD)/libzipper/.libs -lzipper \
+       $(LDFLAGS_ZLIB) \
+       $(LDFLAGS_HIDAPI) \
+       $(LDFLAGS_LIBUSB)
 
 
 # wxWidgets 3.0.2 uses broken Webkit headers under OSX Yosemeti
 # liblzma not available on OSX 10.7
-WX_CONFIG=--disable-webkit --disable-webviewwebkit  \
+# --disable-mediactrl for missing Quicktime.h on Mac OSX Sierra
+WX_CONFIG=--disable-webkit --disable-webviewwebkit  --disable-mediactrl \
        --without-libtiff --without-libjbig --without-liblzma --without-opengl \
        --enable-monolithic --enable-stl --disable-shared
 
@@ -56,6 +75,8 @@ ifeq ($(TARGET),Win32)
        LIBZIPPER_CONFIG+=--host=i686-w64-mingw32
        EXE=.exe
        WX_CONFIG+=--host=i686-w64-mingw32
+       LIBUSB_CONFIG+=--host=i686-w64-mingw32 --disable-shared
+       DFU-UTIL_CONFIG+=--host=i686-w64-mingw32
 endif
 ifeq ($(TARGET),Win64)
        VPATH += hidapi/windows
@@ -66,12 +87,15 @@ ifeq ($(TARGET),Win64)
        LIBZIPPER_CONFIG+=--host=x86_64-w64-mingw32
        EXE=.exe
        WX_CONFIG+=--host=x86_64-w64-mingw32
+       LIBUSB_CONFIG+=--host=x86_64-w64-mingw32 --disable-shared
+       DFU-UTIL_CONFIG+=--host=x86_64-w64-mingw32
 endif
 ifeq ($(TARGET),Linux)
        VPATH += hidapi/linux
-       CPPFLAGS += -DHAS_LIBUSB
        LDFLAGS += -ludev -lexpat -lusb-1.0
        BUILD := $(PWD)/build/linux
+       LIBUSB_CONFIG+=--disable-shared
+       LDFLAGS_LIBUSB+= -ludev -lpthread
 endif
 ifeq ($(TARGET),Darwin)
        # Should match OSX
@@ -80,14 +104,18 @@ ifeq ($(TARGET),Darwin)
        CC=clang -mmacosx-version-min=10.7
        CXX=clang++ -stdlib=libc++ -mmacosx-version-min=10.7
        WX_CONFIG += --with-macosx-version-min=10.7
+       LIBUSB_CONFIG += --with-macosx-version-min=10.7 --disable-shared
+       LDFLAGS_LIBUSB += -lobjc
+       DFU-UTIL_CONFIG += --with-macosx-version-min=10.7 --disable-shared
        BUILD := $(PWD)/build/mac
 all: $(BUILD)/scsi2sd-util6.dmg
 
-$(BUILD)/scsi2sd-util6.dmg: $(BUILD)/scsi2sd-util6
+$(BUILD)/scsi2sd-util6.dmg: $(BUILD)/scsi2sd-util6 $(BUILD)/dfu-util/buildstamp
+       rm -rf $(dir $@)/dmg $@
        mkdir -p $(dir $@)/dmg
-       cp $(BUILD)/scsi2sd-util6 $(dir $@)/dmg
+       cp $(BUILD)/scsi2sd-util6 $(BUILD)/dfu-util/src/dfu-util $(dir $@)/dmg
        chmod a+rx $(dir $@)/dmg/*
-       hdiutil create -srcfolder $(dir $@)/dmg $@
+       hdiutil create -volname scsi2sd-util6 -srcfolder $(dir $@)/dmg $@
 endif
 
 export CC CXX
@@ -108,12 +136,22 @@ OBJ = \
        $(BUILD)/TargetPanel.o \
        $(BUILD)/SCSI2SD_HID.o \
        $(BUILD)/hidpacket.o \
+       $(BUILD)/Dfu.o \
+       $(BUILD)/terminalwx.o \
+       $(BUILD)/terminalinputevent.o \
+       $(BUILD)/wxterm.o \
+       $(BUILD)/gterm.o \
+       $(BUILD)/actions.o \
+       $(BUILD)/keytrans.o \
+       $(BUILD)/states.o \
+       $(BUILD)/utils.o \
+       $(BUILD)/vt52_states.o \
+
 
 EXEOBJ = \
        $(BUILD)/scsi2sd-util6.o \
 
 
-
 ifneq ($(USE_SYSTEM_ZLIB),Yes)
 $(OBJ): $(BUILD)/zlib/buildstamp
 $(EXEOBJ): $(BUILD)/zlib/buildstamp
@@ -128,6 +166,23 @@ $(BUILD)/zlib/buildstamp:
        touch $@
 endif
 
+ifneq ($(USE_SYSTEM_LIBUSB),Yes)
+$(OBJ): $(BUILD)/libusb/buildstamp
+$(EXEOBJ): $(BUILD)/libusb/buildstamp
+$(BUILD)/libusb/buildstamp:
+       mkdir -p $(dir $@)
+       ( \
+               cd $(dir $@) && \
+               $(CURDIR)/libusb-1.0.20/configure $(LIBUSB_CONFIG) && \
+               $(MAKE) \
+       ) && \
+       touch $@
+else
+$(BUILD)/libusb/buildstamp:
+       mkdir -p $(dir $@)
+       touch $@
+endif
+
 ifneq ($(USE_SYSTEM_WX),Yes)
 $(OBJ): $(BUILD)/wx/buildstamp
 $(EXEOBJ): $(BUILD)/wx/buildstamp
@@ -176,10 +231,28 @@ else
        $(CXX) $(CPPFLAGS) $(CXXFLAGS) `wx-config-3.0 --cxxflags` $< -c -o $@
 endif
 
+$(BUILD)/%.o: %.cpp
+       mkdir -p $(dir $@)
+ifneq ($(USE_SYSTEM_WX),Yes)
+       $(CXX) $(CPPFLAGS) $(CXXFLAGS) `$(BUILD)/wx/wx-config --cxxflags` $< -c -o $@
+else
+       $(CXX) $(CPPFLAGS) $(CXXFLAGS) `wx-config-3.0 --cxxflags` $< -c -o $@
+endif
+
 $(BUILD)/scsi2sd-util6$(EXE): $(OBJ) $(BUILD)/scsi2sd-util.o
        mkdir -p $(dir $@)
        $(CXX) $(CXXFLAGS) $^ $(LDFLAGS_WX) $(LDFLAGS) -o $@
 
+all: $(BUILD)/dfu-util/buildstamp
+$(BUILD)/dfu-util/buildstamp: $(BUILD)/libusb/buildstamp
+       mkdir -p $(dir $@)
+       ( \
+               cd $(dir $@) && \
+               $(CURDIR)/dfu-util/configure ${DFU-UTIL_CONFIG} CPPFLAGS="${CPPFLAGS_LIBUSB}" LDFLAGS="${LDFLAGS_LIBUSB} ${LDFLAGS}" && \
+               $(MAKE) \
+       ) && \
+       touch $@
+
 clean:
        rm $(BUILD)/scsi2sd-util6$(EXE) $(OBJ) $(BUILD)/libzipper/buildstamp