Debian Codegraph @

libraries/src/libssh2/Makefile.mbedTLS

raw
1 #########################################################################
2 #
3 ## Makefile for building libssh2 (Win32 version - gnu make)
4 ## Use: make -f GNUmakefile [help|all|clean|dev|devclean|dist|distclean|dll|objclean]
5 ##
6 ## Hacked by: Guenter Knauf, Alexander Koblov
7 #
8 #########################################################################
9
10 # Edit the path below to point to the base of your Zlib sources.
11 ifndef ZLIB_PATH
12 ZLIB_PATH = ../../zlib-1.2.11
13 endif
14
15 # Edit the path below to point to the base of your Libgcrypt package.
16 ifndef MBEDTLS_PATH
17 MBEDTLS_PATH = ../../mbedtls-2.16.1
18 endif
19
20 # Edit the path below to point to your Distribution folder.
21 ifndef DISTDIR
22 DISTDIR = libssh2-$(LIBSSH2_VERSION_STR)-bin-$(ARCH)
23 endif
24 DISTARC = $(DISTDIR).zip
25
26 # Edit the path below to point to your Development folder.
27 ifndef DEVLDIR
28 DEVLDIR = libssh2-$(LIBSSH2_VERSION_STR)-dev-$(ARCH)
29 endif
30 DEVLARC = $(DEVLDIR).zip
31
32 # Project root
33 PROOT = ..
34
35 # Edit the vars below to change target settings.
36 TARGET = libssh2
37 WWWURL = https://www.libssh2.org/
38 DESCR = libssh2 $(LIBSSH2_VERSION_STR)
39 #STACK = 64000
40
41 # must be equal to DEBUG or NDEBUG
42 ifndef DB
43 DB = NDEBUG
44 # DB = DEBUG
45 endif
46 # Optimization: -O<n> or debugging: -g
47 ifeq ($(DB),NDEBUG)
48 OPT = -O2
49 OBJDIR = release
50 else
51 OPT = -g
52 OPT += -DLIBSSH2DEBUG
53 OBJDIR = debug
54 endif
55
56 # Here you can find a native Win32 binary of the original awk:
57 # http://www.gknw.net/development/prgtools/awk-20100523.zip
58 AWK = awk
59 ZIP = zip -qzr9
60
61 # Platform-dependent helper tool macros
62 ifeq ($(findstring /sh,$(SHELL)),/sh)
63 DEL = rm -f $1
64 RMDIR = rm -fr $1
65 MKDIR = mkdir -p $1
66 COPY = -cp -afv $1 $2
67 #COPYR = -cp -afr $1/* $2
68 COPYR = -rsync -aC $1/* $2
69 TOUCH = touch $1
70 CAT = cat
71 ECHONL = echo ""
72 DL = '
73 else
74 ifeq "$(OS)" "Windows_NT"
75 DEL = -del 2>NUL /q /f $(subst /,\,$1)
76 RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
77 else
78 DEL = -del 2>NUL $(subst /,\,$1)
79 RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
80 endif
81 MKDIR = -md 2>NUL $(subst /,\,$1)
82 COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
83 COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
84 TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
85 CAT = type
86 ECHONL = $(ComSpec) /c echo.
87 endif
88
89 # The following line defines your compiler.
90 CC = $(CROSSPREFIX)gcc
91
92 # Set environment var ARCH to your architecture to override autodetection.
93 ifndef ARCH
94 ifeq ($(findstring gcc,$(CC)),gcc)
95 ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
96 ARCH = w64
97 else
98 ARCH = w32
99 endif
100 else
101 ARCH = w32
102 endif
103 endif
104
105 # Include the version info retrieved from libssh2.h
106 #-include $(OBJDIR)/version.inc
107
108 # Global compiler flags
109 CFLAGS = $(OPT) -D$(DB) -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
110 LD = $(CROSSPREFIX)gcc
111 RC = $(CROSSPREFIX)windres
112 LDFLAGS += -s -shared -Wl,--output-def,$(TARGET).def,--out-implib,$(TARGET)dll.a -static-libgcc
113 AR = $(CROSSPREFIX)ar
114 ARFLAGS = -cq
115 LIBEXT = a
116 RANLIB = $(CROSSPREFIX)ranlib
117 LDLIBS += -lws2_32
118 RCFLAGS = -I. -I $(PROOT)/include -O coff
119 CFLAGS += -fno-strict-aliasing -DLIBSSH2_MBEDTLS
120 CFLAGS += -Wall # -pedantic
121 ifeq ($(ARCH),w64)
122 CFLAGS += -m64 -D_AMD64_
123 LDFLAGS += -m64
124 RCFLAGS += -F pe-x86-64
125 else
126 CFLAGS += -m32
127 LDFLAGS += -m32
128 RCFLAGS += -F pe-i386
129 endif
130
131 INCLUDES = -I$(PROOT)/win32 -I$(PROOT)/include
132
133 ifndef MBEDTLS_INCLUDE
134 ifeq "$(wildcard $(MBEDTLS_PATH)/include)" "$(MBEDTLS_PATH)/include"
135 MBEDTLS_INCLUDE = $(MBEDTLS_PATH)/include
136 endif
137 endif
138 ifneq "$(wildcard $(MBEDTLS_INCLUDE)/mbedtls/platform.h)" "$(MBEDTLS_INCLUDE)/mbedtls/platform.h"
139 $(error Invalid MBEDTLS_PATH: $(MBEDTLS_PATH))
140 endif
141 INCLUDES += -I"$(MBEDTLS_INCLUDE)"
142 ifndef LIBGCRYPT_LIBPATH
143 ifeq "$(wildcard $(MBEDTLS_PATH)/library)" "$(MBEDTLS_PATH)/library"
144 LIBGCRYPT_LIBPATH = $(MBEDTLS_PATH)/library
145 endif
146 endif
147 LIBGCRYPT_LIBS_STAT = mbedtls mbedcrypto
148 LDLIBS += $(patsubst %,$(LIBGCRYPT_LIBPATH)/lib%.$(LIBEXT), $(LIBGCRYPT_LIBS_STAT))
149
150 ifdef WITH_ZLIB
151 CFLAGS += -DLIBSSH2_HAVE_ZLIB
152 INCLUDES += -I$(ZLIB_PATH)
153 ifdef LINK_ZLIB_STATIC
154 LDLIBS += $(ZLIB_PATH)/libz.$(LIBEXT)
155 else
156 LDLIBS += $(ZLIB_PATH)/libz.dll.$(LIBEXT)
157 endif
158 endif
159
160 CFLAGS += $(INCLUDES)
161
162 vpath %.c $(PROOT)/src
163
164 # include Makefile.inc to get CSOURCES define
165 include $(PROOT)/Makefile.mbedTLS.inc
166 include $(PROOT)/Makefile.inc
167
168 OBJECTS := $(patsubst %.c,%.o,$(CSOURCES))
169 OBJS := $(addprefix $(OBJDIR)/,$(OBJECTS))
170 OBJL = $(OBJS) $(OBJDIR)/$(TARGET).res
171
172
173 all: lib dll
174
175 dll: prebuild $(TARGET).dll
176
177 lib: prebuild $(TARGET).$(LIBEXT)
178
179 prebuild: $(OBJDIR) #$(OBJDIR)/version.inc
180 # libssh2_config.h
181
182 test: all
183 $(MAKE) -C test -f GNUmakefile
184
185 $(OBJDIR)/%.o: %.c
186 # @echo Compiling $<
187 $(CC) $(CFLAGS) -c $< -o $@
188
189 $(OBJDIR)/version.inc: $(PROOT)/get_ver.awk $(PROOT)/include/libssh2.h $(OBJDIR)
190 @echo Creating $@
191 @$(AWK) -f $^ > $@
192
193 dist: all $(DISTDIR) $(DISTDIR)/readme.txt
194 @$(call MKDIR, $(DISTDIR)/bin)
195 @$(call COPY, $(PROOT)/AUTHORS, $(DISTDIR))
196 @$(call COPY, $(PROOT)/COPYING, $(DISTDIR))
197 @$(call COPY, $(PROOT)/INSTALL, $(DISTDIR))
198 @$(call COPY, $(PROOT)/README, $(DISTDIR))
199 @$(call COPY, $(PROOT)/RELEASE-NOTES, $(DISTDIR))
200 @$(call COPY, $(TARGET).dll, $(DISTDIR)/bin)
201 @echo Creating $(DISTARC)
202 @$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
203
204 dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt
205 @$(call MKDIR, $(DEVLDIR)/bin)
206 @$(call MKDIR, $(DEVLDIR)/include)
207 @$(call MKDIR, $(DEVLDIR)/win32)
208 @$(call COPY, $(PROOT)/AUTHORS, $(DEVLDIR))
209 @$(call COPY, $(PROOT)/COPYING, $(DEVLDIR))
210 @$(call COPY, $(PROOT)/INSTALL, $(DEVLDIR))
211 @$(call COPY, $(PROOT)/README, $(DEVLDIR))
212 @$(call COPY, $(PROOT)/RELEASE-NOTES, $(DEVLDIR))
213 @$(call COPY, $(TARGET).dll, $(DEVLDIR)/bin)
214 @$(call COPY, $(PROOT)/include/*.h, $(DEVLDIR)/include)
215 @$(call COPY, libssh2_config.h, $(DEVLDIR)/include)
216 @$(call COPY, *.$(LIBEXT), $(DEVLDIR)/win32)
217 @echo Creating $(DEVLARC)
218 @$(ZIP) $(DEVLARC) $(DEVLDIR)/* < $(DEVLDIR)/readme.txt
219
220 distclean vclean: clean
221 $(call RMDIR, $(DISTDIR))
222 $(call DEL, $(DISTARC))
223
224 devclean: clean
225 $(call RMDIR, $(DEVLDIR))
226 $(call DEL, $(DEVLARC))
227
228 objclean: all
229 $(call RMDIR, $(OBJDIR))
230
231 testclean: clean
232 $(MAKE) -C test -f GNUmakefile clean
233
234 clean:
235 # $(call DEL, libssh2_config.h)
236 $(call DEL, $(TARGET).dll $(TARGET).def $(TARGET).$(LIBEXT) $(TARGET)dll.$(LIBEXT))
237 $(call RMDIR, $(OBJDIR))
238
239 $(OBJDIR):
240 @$(call MKDIR, $@)
241
242 $(DISTDIR):
243 @$(call MKDIR, $@)
244
245 $(DEVLDIR):
246 @$(call MKDIR, $@)
247
248 $(TARGET).$(LIBEXT): $(OBJS)
249 @echo Creating $@
250 @$(call DEL, $@)
251 @$(AR) $(ARFLAGS) $@ $^
252 ifdef RANLIB
253 @$(RANLIB) $@
254 endif
255
256 $(TARGET).dll $(TARGET)dll.a: $(OBJL)
257 @echo Linking $@
258 @$(call DEL, $@)
259 @$(LD) $(LDFLAGS) $^ -o $@ $(LIBPATH) $(LDLIBS)
260
261
262 $(OBJDIR)/%.res: %.rc
263 @echo Creating $@
264 @$(RC) $(RCFLAGS) -i $< -o $@
265
266
267 $(DISTDIR)/readme.txt: GNUmakefile
268 @echo Creating $@
269 @echo $(DL)This is a binary distribution for Win32 platform.$(DL) > $@
270 @echo $(DL)libssh version $(LIBSSH2_VERSION_STR)$(DL) >> $@
271 @echo $(DL)Please download the complete libssh package for$(DL) >> $@
272 @echo $(DL)any further documentation:$(DL) >> $@
273 @echo $(DL)$(WWWURL)$(DL) >> $@
274
275 $(DEVLDIR)/readme.txt: GNUmakefile
276 @echo Creating $@
277 @echo $(DL)This is a development distribution for Win32 platform.$(DL) > $@
278 @echo $(DL)libssh version $(LIBSSH2_VERSION_STR)$(DL) >> $@
279 @echo $(DL)Please download the complete libssh package for$(DL) >> $@
280 @echo $(DL)any further documentation:$(DL) >> $@
281 @echo $(DL)$(WWWURL)$(DL) >> $@
282
283 help: $(OBJDIR)/version.inc
284 @echo $(DL)===========================================================$(DL)
285 @echo $(DL)mbedTLS path = $(MBEDTLS_PATH)$(DL)
286 @echo $(DL)Zlib path = $(ZLIB_PATH)$(DL)
287 @echo $(DL)===========================================================$(DL)
288 @echo $(DL)libssh $(LIBSSH2_VERSION_STR) - available targets are:$(DL)
289 @echo $(DL)$(MAKE) all$(DL)
290 @echo $(DL)$(MAKE) dll$(DL)
291 @echo $(DL)$(MAKE) lib$(DL)
292 @echo $(DL)$(MAKE) clean$(DL)
293 @echo $(DL)$(MAKE) dev$(DL)
294 @echo $(DL)$(MAKE) devclean$(DL)
295 @echo $(DL)$(MAKE) dist$(DL)
296 @echo $(DL)$(MAKE) distclean$(DL)
297 @echo $(DL)$(MAKE) objclean$(DL)
298 @echo $(DL)$(MAKE) test$(DL)
299 @echo $(DL)===========================================================$(DL)