Removed C++11 dependencies, and compile Windows binaries staically with mingw.
[SCSI2SD.git] / software / scsi2sd-debug / Makefile
index d286620..c68e105 100644 (file)
@@ -1,24 +1,63 @@
-all: build/scsi2sd-debug
 
-CFLAGS += -Wall
+CPPFLAGS = -I ../bootloaderhost/hidapi/hidapi -I ../bootloaderhost
+CFLAGS += -Wall -Wno-pointer-sign -O2
+CXXFLAGS += -Wall -O2
+VPATH += ../bootloaderhost
 
-UNAME_S := $(shell uname -s)
-ifeq ($(UNAME_S),Linux)
-       HID_C = ../bootloaderhost/hidapi/linux/hid.c
+TARGET ?= $(shell uname -s)
+ifeq ($(TARGET),Win32)
+       VPATH += hidapi/windows
+       LDFLAGS += -static -mconsole -mwindows -lsetupapi -lws2_32
+       BUILD = build/windows/32bit
+       CC=i686-w64-mingw32-gcc
+       CXX=i686-w64-mingw32-g++
+       EXE=.exe
+endif
+ifeq ($(TARGET),Win64)
+       VPATH += hidapi/windows
+       LDFLAGS += -static -mconsole -mwindows -lsetupapi -lws2_32
+       BUILD = build/windows/64bit
+       CC=x86_64-w64-mingw32-gcc
+       CXX=x86_64-w64-mingw32-g++
+       EXE=.exe
+endif
+ifeq ($(TARGET),Linux)
+       VPATH += hidapi/linux
        LDFLAGS += -ludev
+       BUILD = build/linux
 endif
-ifeq ($(UNAME_S),Darwin)
+ifeq ($(TARGET),Darwin)
        # Should match OSX
-       HID_C = ../bootloaderhost/hidapi/mac/hid.c
+       VPATH += ../bootloaderhost/hidapi/mac
        LDFLAGS += -framework IOKit -framework CoreFoundation
-       CFLAGS += -mmacosx-version-min=10.5 -arch x86_64 -arch i386 -arch ppc -isysroot /Xcode3.1.4/SDKs/MacOSX10.5.sdk
-       CC=/Xcode3.1.4/usr/bin/gcc
+       CFLAGS += -mmacosx-version-min=10.7
+       CXXFLAGS += -stdlib=libc++ -mmacosx-version-min=10.7
+       CC=clang
+       CXX=clang++
+       BUILD=build/mac
 endif
 
+all:  $(BUILD)/scsi2sd-debug$(EXE)
+
+HIDAPI = \
+       $(BUILD)/hid.o \
+
+OBJ = \
+       $(HIDAPI) \
+       $(BUILD)/scsi2sd-debug.o \
+       $(BUILD)/SCSI2SD_HID.o \
+
+$(BUILD)/%.o: %.c
+       mkdir -p $(dir $@)
+       $(CC) $(CPPFLAGS) $(CFLAGS) $^ -c -o $@
+
+$(BUILD)/%.o: %.cc
+       mkdir -p $(dir $@)
+       $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -c -o $@
 
-build/scsi2sd-debug: main.c $(HID_C) $(CYAPI)
+$(BUILD)/scsi2sd-debug$(EXE): $(OBJ)
        mkdir -p $(dir $@)
-       $(CC) $(CFLAGS) -I ../bootloaderhost/hidapi/hidapi $^ $(LDFLAGS) -o $@
+       $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
 
 clean:
-       rm build/scsi2sd-debug
+       rm $(BUILD)/scsi2sd-debug$(EXE) $(OBJ)