geom_gate userland utility improvements
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

284 lines
7.7 KiB

  1. #########################################################################
  2. #
  3. ## Makefile for building libssh2 samples (Win32 version - gnu make)
  4. ## Use: make -f GNUmakefile [help]
  5. ##
  6. ## Hacked by: Guenter Knauf
  7. #
  8. #########################################################################
  9. # Edit the path below to point to the base of your Zlib sources.
  10. ifndef ZLIB_PATH
  11. ZLIB_PATH = ../../../zlib-1.2.8
  12. endif
  13. # Edit the path below to point to the base of your OpenSSL package.
  14. ifndef OPENSSL_PATH
  15. OPENSSL_PATH = ../../../openssl-0.9.8zc
  16. endif
  17. # Project root
  18. PROOT = ../..
  19. # Edit the var below to enable static linking of libssh2 and libz
  20. LINK_STATIC = 1
  21. # Edit the vars below to change target settings.
  22. SAMPLES = $(PROOT)/example
  23. TARGETS := $(filter-out x11.exe,$(patsubst $(SAMPLES)/%.c,%.exe,$(strip $(wildcard $(SAMPLES)/*.c))))
  24. WWWURL = https://www.libssh2.org/
  25. DESCR = libssh2 $(subst .rc,,$(notdir $@)) $(LIBSSH2_VERSION_STR)
  26. #STACK = 64000
  27. # must be equal to DEBUG or NDEBUG
  28. ifndef DB
  29. DB = NDEBUG
  30. # DB = DEBUG
  31. endif
  32. # Optimization: -O<n> or debugging: -g
  33. ifeq ($(DB),NDEBUG)
  34. OPT = -O2
  35. OBJDIR = release
  36. else
  37. OPT = -g
  38. OBJDIR = debug
  39. endif
  40. # Here you can find a native Win32 binary of the original awk:
  41. # http://www.gknw.net/development/prgtools/awk-20100523.zip
  42. AWK = awk
  43. ZIP = zip -qzr9
  44. # Platform-dependent helper tool macros
  45. ifeq ($(findstring /sh,$(SHELL)),/sh)
  46. DEL = rm -f $1
  47. RMDIR = rm -fr $1
  48. MKDIR = mkdir -p $1
  49. COPY = -cp -afv $1 $2
  50. #COPYR = -cp -afr $1/* $2
  51. COPYR = -rsync -aC $1/* $2
  52. TOUCH = touch $1
  53. CAT = cat
  54. ECHONL = echo ""
  55. DL = '
  56. else
  57. ifeq "$(OS)" "Windows_NT"
  58. DEL = -del 2>NUL /q /f $(subst /,\,$1)
  59. RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
  60. else
  61. DEL = -del 2>NUL $(subst /,\,$1)
  62. RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
  63. endif
  64. MKDIR = -md 2>NUL $(subst /,\,$1)
  65. COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
  66. COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
  67. TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
  68. CAT = type
  69. ECHONL = $(ComSpec) /c echo.
  70. endif
  71. # The following line defines your compiler.
  72. ifdef METROWERKS
  73. CC = mwcc
  74. else
  75. CC = $(CROSSPREFIX)gcc
  76. endif
  77. # Set environment var ARCH to your architecture to override autodetection.
  78. ifndef ARCH
  79. ifeq ($(findstring gcc,$(CC)),gcc)
  80. ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
  81. ARCH = w64
  82. else
  83. ARCH = w32
  84. endif
  85. else
  86. ARCH = w32
  87. endif
  88. endif
  89. # Include the version info retrieved from libssh2.h
  90. -include $(OBJDIR)/version.inc
  91. # Global flags for all compilers
  92. CFLAGS = $(OPT) -D$(DB) -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
  93. ifeq ($(CC),mwcc)
  94. LD = mwld
  95. RC = mwwinrc
  96. LDFLAGS = -nostdlib
  97. AR = $(LD)
  98. ARFLAGS = -nostdlib -library -o
  99. LIBEXT = lib
  100. LIBPATH += -lr "$(METROWERKS)/MSL" -lr "$(METROWERKS)/Win32-x86 Support"
  101. LDLIBS += -lMSL_Runtime_x86.lib -lMSL_C_x86.lib -lMSL_Extras_x86.lib
  102. LDLIBS += -lkernel32.lib -luser32.lib -lwsock32.lib
  103. RCFLAGS =
  104. CFLAGS += -nostdinc -gccinc -msgstyle gcc -inline off -opt nointrinsics -proc 586
  105. CFLAGS += -ir "$(METROWERKS)/MSL" -ir "$(METROWERKS)/Win32-x86 Support"
  106. CFLAGS += -w on,nounused,nounusedexpr # -ansi strict
  107. else
  108. LD = $(CROSSPREFIX)gcc
  109. RC = $(CROSSPREFIX)windres
  110. LDFLAGS = -s
  111. AR = $(CROSSPREFIX)ar
  112. ARFLAGS = -cq
  113. LIBEXT = a
  114. #LDLIBS += -lwsock32
  115. LDLIBS += -lws2_32
  116. RCFLAGS = -I $(PROOT)/include -O coff
  117. CFLAGS += -fno-builtin
  118. CFLAGS += -fno-strict-aliasing
  119. CFLAGS += -Wall #-Wno-unused #-pedantic
  120. ifeq ($(ARCH),w64)
  121. CFLAGS += -D_AMD64_
  122. RCFLAGS += -F pe-x86-64
  123. else
  124. CFLAGS += -m32
  125. RCFLAGS += -F pe-i386
  126. endif
  127. endif
  128. INCLUDES = -I$(PROOT)/win32 -I$(PROOT)/include
  129. LIBPATH += -L$(PROOT)/win32
  130. ifdef LINK_STATIC
  131. LDLIBS += -llibssh2
  132. else
  133. LDLIBS += -llibssh2dll
  134. endif
  135. ifdef WITH_WINCNG
  136. # CFLAGS += -DLIBSSH2_WINCNG
  137. LDLIBS += -lbcrypt -lcrypt32
  138. else
  139. # CFLAGS += -DLIBSSH2_OPENSSL
  140. ifndef OPENSSL_INCLUDE
  141. ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
  142. OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
  143. endif
  144. ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
  145. OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
  146. endif
  147. endif
  148. ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
  149. $(error Invalid OPENSSL_PATH: $(OPENSSL_PATH))
  150. endif
  151. INCLUDES += -I"$(OPENSSL_INCLUDE)"
  152. ifndef OPENSSL_LIBPATH
  153. OPENSSL_LIBS_STAT = crypto ssl
  154. ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
  155. OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
  156. OPENSSL_LIBS_DYN = eay32 ssl32
  157. endif
  158. ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
  159. OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
  160. OPENSSL_LIBS_DYN = crypto.dll ssl.dll
  161. endif
  162. endif
  163. ifdef LINK_STATIC
  164. ifdef LINK_OPENSSL_STATIC
  165. LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_STAT)) -lgdi32
  166. else
  167. LDLIBS += $(patsubst %,$(OPENSSL_LIBPATH)/lib%.$(LIBEXT), $(OPENSSL_LIBS_DYN))
  168. endif
  169. endif
  170. endif
  171. ifdef WITH_ZLIB
  172. CFLAGS += -DLIBSSH2_HAVE_ZLIB
  173. INCLUDES += -I$(ZLIB_PATH)
  174. ifdef LINK_ZLIB_STATIC
  175. LDLIBS += $(ZLIB_PATH)/libz.$(LIBEXT)
  176. else
  177. LDLIBS += $(ZLIB_PATH)/libzdll.$(LIBEXT)
  178. endif
  179. endif
  180. CFLAGS += $(INCLUDES)
  181. vpath %.c $(PROOT)/example
  182. .PRECIOUS: $(OBJDIR)/%.o $(OBJDIR)/%.rc $(OBJDIR)/%.res
  183. all: prebuild $(TARGETS)
  184. prebuild: $(OBJDIR) $(OBJDIR)/version.inc
  185. $(OBJDIR)/%.o: %.c
  186. # @echo Compiling $<
  187. $(CC) $(CFLAGS) -c $< -o $@
  188. $(OBJDIR)/version.inc: $(PROOT)/include/libssh2.h $(OBJDIR)
  189. @echo Creating $@
  190. @$(AWK) -f $(PROOT)/get_ver.awk $< > $@
  191. objclean:
  192. $(call RMDIR, $(OBJDIR))
  193. clean: objclean
  194. $(call DEL, $(TARGETS))
  195. $(OBJDIR):
  196. $(call MKDIR, $@)
  197. %.exe: $(OBJDIR)/%.o $(OBJDIR)/%.res
  198. @echo Linking $@
  199. @$(call DEL, $@)
  200. $(LD) $(LDFLAGS) $^ -o $@ $(LIBPATH) $(LDLIBS)
  201. $(OBJDIR)/%.res: $(OBJDIR)/%.rc
  202. @echo Creating $@
  203. @$(RC) $(RCFLAGS) -i $< -o $@
  204. $(OBJDIR)/%.rc: GNUmakefile $(OBJDIR)/version.inc
  205. @echo $(DL)1 VERSIONINFO$(DL) > $@
  206. @echo $(DL) FILEVERSION $(LIBSSH2_VERSION),0$(DL) >> $@
  207. @echo $(DL) PRODUCTVERSION $(LIBSSH2_VERSION),0$(DL) >> $@
  208. @echo $(DL) FILEFLAGSMASK 0x3fL$(DL) >> $@
  209. @echo $(DL) FILEOS 0x40004L$(DL) >> $@
  210. @echo $(DL) FILEFLAGS 0x0L$(DL) >> $@
  211. @echo $(DL) FILETYPE 0x1L$(DL) >> $@
  212. @echo $(DL) FILESUBTYPE 0x0L$(DL) >> $@
  213. @echo $(DL)BEGIN$(DL) >> $@
  214. @echo $(DL) BLOCK "StringFileInfo"$(DL) >> $@
  215. @echo $(DL) BEGIN$(DL) >> $@
  216. @echo $(DL) BLOCK "040904E4"$(DL) >> $@
  217. @echo $(DL) BEGIN$(DL) >> $@
  218. @echo $(DL) VALUE "LegalCopyright","\xA9 $(LIBSSH2_COPYRIGHT_STR)\0"$(DL) >> $@
  219. ifdef COMPANY
  220. @echo $(DL) VALUE "CompanyName","$(COMPANY)\0"$(DL) >> $@
  221. endif
  222. @echo $(DL) VALUE "ProductName","$(notdir $(@:.rc=.exe))\0"$(DL) >> $@
  223. @echo $(DL) VALUE "ProductVersion","$(LIBSSH2_VERSION_STR)\0"$(DL) >> $@
  224. @echo $(DL) VALUE "License","Released under GPL.\0"$(DL) >> $@
  225. @echo $(DL) VALUE "FileDescription","$(DESCR)\0"$(DL) >> $@
  226. @echo $(DL) VALUE "FileVersion","$(LIBSSH2_VERSION_STR)\0"$(DL) >> $@
  227. @echo $(DL) VALUE "InternalName","$(notdir $(@:.rc=))\0"$(DL) >> $@
  228. @echo $(DL) VALUE "OriginalFilename","$(notdir $(@:.rc=.exe))\0"$(DL) >> $@
  229. @echo $(DL) VALUE "WWW","$(WWWURL)\0"$(DL) >> $@
  230. @echo $(DL) END$(DL) >> $@
  231. @echo $(DL) END$(DL) >> $@
  232. @echo $(DL) BLOCK "VarFileInfo"$(DL) >> $@
  233. @echo $(DL) BEGIN$(DL) >> $@
  234. @echo $(DL) VALUE "Translation", 0x409, 1252$(DL) >> $@
  235. @echo $(DL) END$(DL) >> $@
  236. @echo $(DL)END$(DL) >> $@
  237. ifdef ICON
  238. @echo $(DL)10 ICON DISCARDABLE "$(ICON)"$(DL) >> $@
  239. endif
  240. help: $(OBJDIR)/version.inc
  241. @echo $(DL)===========================================================$(DL)
  242. @echo $(DL)OpenSSL path = $(OPENSSL_PATH)$(DL)
  243. @echo $(DL)Zlib path = $(ZLIB_PATH)$(DL)
  244. @echo $(DL)===========================================================$(DL)
  245. @echo $(DL)libssh $(LIBSSH2_VERSION_STR) - available targets are:$(DL)
  246. @echo $(DL)$(MAKE) all$(DL)
  247. @echo $(DL)$(MAKE) clean$(DL)
  248. @echo $(DL)$(MAKE) objclean$(DL)
  249. @echo $(DL)===========================================================$(DL)