Debian Codegraph @

libraries/src/libssh2/Makefile.libgcrypt

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.8
13 endif
14
15 # Edit the path below to point to the base of your Libgcrypt package.
16 ifndef LIBGCRYPT_PATH
17 LIBGCRYPT_PATH = ../../libgcrypt-1.7.8
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_LIBGCRYPT
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 LIBGCRYPT_INCLUDE
134 ifeq "$(wildcard $(LIBGCRYPT_PATH)/include)" "$(LIBGCRYPT_PATH)/include"
135 LIBGCRYPT_INCLUDE = $(LIBGCRYPT_PATH)/include
136 endif
137 endif
138 ifneq "$(wildcard $(LIBGCRYPT_INCLUDE)/gcrypt.h)" "$(LIBGCRYPT_INCLUDE)/gcrypt.h"
139 $(error Invalid LIBGCRYPT_PATH: $(LIBGCRYPT_PATH))
140 endif
141 ifneq "$(wildcard $(LIBGCRYPT_INCLUDE)/gpg-error.h)" "$(LIBGCRYPT_INCLUDE)/gpg-error.h"
142 $(error Invalid LIBGCRYPT_PATH: $(LIBGCRYPT_PATH))
143 endif
144 INCLUDES += -I"$(LIBGCRYPT_INCLUDE)"
145 ifndef LIBGCRYPT_LIBPATH
146 LIBGCRYPT_LIBS_STAT = gcrypt gpg-error
147 ifeq "$(wildcard $(LIBGCRYPT_PATH)/lib)" "$(LIBGCRYPT_PATH)/lib"
148 LIBGCRYPT_LIBPATH = $(LIBGCRYPT_PATH)/lib
149 LIBGCRYPT_LIBS_DYN = gcrypt.dll gpg-error.dll
150 endif
151 endif
152 ifdef LINK_LIBGCRYPT_STATIC
153 LDLIBS += $(patsubst %,$(LIBGCRYPT_LIBPATH)/lib%.$(LIBEXT), $(LIBGCRYPT_LIBS_STAT))
154 else
155 LDLIBS += $(patsubst %,$(LIBGCRYPT_LIBPATH)/lib%.$(LIBEXT), $(LIBGCRYPT_LIBS_DYN))
156 endif
157
158 ifdef WITH_ZLIB
159 CFLAGS += -DLIBSSH2_HAVE_ZLIB
160 INCLUDES += -I$(ZLIB_PATH)
161 ifdef LINK_ZLIB_STATIC
162 LDLIBS += $(ZLIB_PATH)/libz.$(LIBEXT)
163 else
164 LDLIBS += $(ZLIB_PATH)/libz.dll.$(LIBEXT)
165 endif
166 endif
167
168 CFLAGS += $(INCLUDES)
169
170 vpath %.c $(PROOT)/src
171
172 # include Makefile.inc to get CSOURCES define
173 include $(PROOT)/Makefile.libgcrypt.inc
174 include $(PROOT)/Makefile.inc
175
176 OBJECTS := $(patsubst %.c,%.o,$(CSOURCES))
177 OBJS := $(addprefix $(OBJDIR)/,$(OBJECTS))
178 OBJL = $(OBJS) $(OBJDIR)/$(TARGET).res
179
180
181 all: lib dll
182
183 dll: prebuild $(TARGET).dll
184
185 lib: prebuild $(TARGET).$(LIBEXT)
186
187 prebuild: $(OBJDIR) #$(OBJDIR)/version.inc
188 # libssh2_config.h
189
190 test: all
191 $(MAKE) -C test -f GNUmakefile
192
193 $(OBJDIR)/%.o: %.c
194 # @echo Compiling $<
195 $(CC) $(CFLAGS) -c $< -o $@
196
197 $(OBJDIR)/version.inc: $(PROOT)/get_ver.awk $(PROOT)/include/libssh2.h $(OBJDIR)
198 @echo Creating $@
199 @$(AWK) -f $^ > $@
200
201 dist: all $(DISTDIR) $(DISTDIR)/readme.txt
202 @$(call MKDIR, $(DISTDIR)/bin)
203 @$(call COPY, $(PROOT)/AUTHORS, $(DISTDIR))
204 @$(call COPY, $(PROOT)/COPYING, $(DISTDIR))
205 @$(call COPY, $(PROOT)/INSTALL, $(DISTDIR))
206 @$(call COPY, $(PROOT)/README, $(DISTDIR))
207 @$(call COPY, $(PROOT)/RELEASE-NOTES, $(DISTDIR))
208 @$(call COPY, $(TARGET).dll, $(DISTDIR)/bin)
209 @echo Creating $(DISTARC)
210 @$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
211
212 dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt
213 @$(call MKDIR, $(DEVLDIR)/bin)
214 @$(call MKDIR, $(DEVLDIR)/include)
215 @$(call MKDIR, $(DEVLDIR)/win32)
216 @$(call COPY, $(PROOT)/AUTHORS, $(DEVLDIR))
217 @$(call COPY, $(PROOT)/COPYING, $(DEVLDIR))
218 @$(call COPY, $(PROOT)/INSTALL, $(DEVLDIR))
219 @$(call COPY, $(PROOT)/README, $(DEVLDIR))
220 @$(call COPY, $(PROOT)/RELEASE-NOTES, $(DEVLDIR))
221 @$(call COPY, $(TARGET).dll, $(DEVLDIR)/bin)
222 @$(call COPY, $(PROOT)/include/*.h, $(DEVLDIR)/include)
223 @$(call COPY, libssh2_config.h, $(DEVLDIR)/include)
224 @$(call COPY, *.$(LIBEXT), $(DEVLDIR)/win32)
225 @echo Creating $(DEVLARC)
226 @$(ZIP) $(DEVLARC) $(DEVLDIR)/* < $(DEVLDIR)/readme.txt
227
228 distclean vclean: clean
229 $(call RMDIR, $(DISTDIR))
230 $(call DEL, $(DISTARC))
231
232 devclean: clean
233 $(call RMDIR, $(DEVLDIR))
234 $(call DEL, $(DEVLARC))
235
236 objclean: all
237 $(call RMDIR, $(OBJDIR))
238
239 testclean: clean
240 $(MAKE) -C test -f GNUmakefile clean
241
242 clean:
243 # $(call DEL, libssh2_config.h)
244 $(call DEL, $(TARGET).dll $(TARGET).def $(TARGET).$(LIBEXT) $(TARGET)dll.$(LIBEXT))
245 $(call RMDIR, $(OBJDIR))
246
247 $(OBJDIR):
248 @$(call MKDIR, $@)
249
250 $(DISTDIR):
251 @$(call MKDIR, $@)
252
253 $(DEVLDIR):
254 @$(call MKDIR, $@)
255
256 $(TARGET).$(LIBEXT): $(OBJS)
257 @echo Creating $@
258 @$(call DEL, $@)
259 @$(AR) $(ARFLAGS) $@ $^
260 ifdef RANLIB
261 @$(RANLIB) $@
262 endif
263
264 $(TARGET).dll $(TARGET)dll.a: $(OBJL)
265 @echo Linking $@
266 @$(call DEL, $@)
267 @$(LD) $(LDFLAGS) $^ -o $@ $(LIBPATH) $(LDLIBS)
268
269
270 $(OBJDIR)/%.res: %.rc
271 @echo Creating $@
272 @$(RC) $(RCFLAGS) -i $< -o $@
273
274
275 $(DISTDIR)/readme.txt: GNUmakefile
276 @echo Creating $@
277 @echo $(DL)This is a binary 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 $(DEVLDIR)/readme.txt: GNUmakefile
284 @echo Creating $@
285 @echo $(DL)This is a development distribution for Win32 platform.$(DL) > $@
286 @echo $(DL)libssh version $(LIBSSH2_VERSION_STR)$(DL) >> $@
287 @echo $(DL)Please download the complete libssh package for$(DL) >> $@
288 @echo $(DL)any further documentation:$(DL) >> $@
289 @echo $(DL)$(WWWURL)$(DL) >> $@
290
291 help: $(OBJDIR)/version.inc
292 @echo $(DL)===========================================================$(DL)
293 @echo $(DL)Libgcrypt path = $(LIBGCRYPT_PATH)$(DL)
294 @echo $(DL)Zlib path = $(ZLIB_PATH)$(DL)
295 @echo $(DL)===========================================================$(DL)
296 @echo $(DL)libssh $(LIBSSH2_VERSION_STR) - available targets are:$(DL)
297 @echo $(DL)$(MAKE) all$(DL)
298 @echo $(DL)$(MAKE) dll$(DL)
299 @echo $(DL)$(MAKE) lib$(DL)
300 @echo $(DL)$(MAKE) clean$(DL)
301 @echo $(DL)$(MAKE) dev$(DL)
302 @echo $(DL)$(MAKE) devclean$(DL)
303 @echo $(DL)$(MAKE) dist$(DL)
304 @echo $(DL)$(MAKE) distclean$(DL)
305 @echo $(DL)$(MAKE) objclean$(DL)
306 @echo $(DL)$(MAKE) test$(DL)
307 @echo $(DL)===========================================================$(DL)