Makefile 5.1 KB

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