Added metalink support to NetWare builds.
[platform/upstream/curl.git] / src / Makefile.netware
1 #################################################################
2 #
3 ## Makefile for building curl.nlm (NetWare version - gnu make)
4 ## Use: make -f Makefile.netware
5 ##
6 ## Comments to: Guenter Knauf http://www.gknw.net/phpbb
7 #
8 #################################################################
9
10 # Edit the path below to point to the base of your Novell NDK.
11 ifndef NDKBASE
12 NDKBASE = c:/novell
13 endif
14
15 # Edit the path below to point to the base of your Zlib sources.
16 ifndef ZLIB_PATH
17 ZLIB_PATH = ../../zlib-1.2.7
18 endif
19
20 # Edit the path below to point to the base of your OpenSSL package.
21 ifndef OPENSSL_PATH
22 OPENSSL_PATH = ../../openssl-0.9.8x
23 endif
24
25 # Edit the path below to point to the base of your LibSSH2 package.
26 ifndef LIBSSH2_PATH
27 LIBSSH2_PATH = ../../libssh2-1.4.2
28 endif
29
30 # Edit the path below to point to the base of your axTLS package.
31 ifndef AXTLS_PATH
32 AXTLS_PATH = ../../axTLS-1.2.7
33 endif
34
35 # Edit the path below to point to the base of your libidn package.
36 ifndef LIBIDN_PATH
37 LIBIDN_PATH = ../../libidn-1.18
38 endif
39
40 # Edit the path below to point to the base of your librtmp package.
41 ifndef LIBRTMP_PATH
42 LIBRTMP_PATH = ../../librtmp-2.3
43 endif
44
45 # Edit the path below to point to the base of your fbopenssl package.
46 ifndef FBOPENSSL_PATH
47 FBOPENSSL_PATH = ../../fbopenssl-0.4
48 endif
49
50 # Edit the path below to point to the base of your libmetalink package.
51 ifndef LIBMETALINK_PATH
52 LIBMETALINK_PATH = ../../libmetalink-0.0.3
53 endif
54
55 # Edit the path below to point to the base of your c-ares package.
56 ifndef LIBCARES_PATH
57 LIBCARES_PATH = ../ares
58 endif
59
60 ifndef INSTDIR
61 INSTDIR = ..$(DS)curl-$(LIBCURL_VERSION_STR)-bin-nw
62 endif
63
64 # Edit the vars below to change NLM target settings.
65 TARGET  = curl
66 VERSION = $(LIBCURL_VERSION)
67 COPYR   = Copyright (C) $(LIBCURL_COPYRIGHT_STR)
68 DESCR   = cURL $(LIBCURL_VERSION_STR) ($(LIBARCH)) - http://curl.haxx.se
69 MTSAFE  = YES
70 STACK   = 64000
71 SCREEN  = $(TARGET) commandline utility
72 # Comment the line below if you dont want to load protected automatically.
73 # LDRING = 3
74
75 # Uncomment the next line to enable linking with POSIX semantics.
76 # POSIXFL = 1
77
78 # Edit the var below to point to your lib architecture.
79 ifndef LIBARCH
80 LIBARCH = LIBC
81 endif
82
83 # must be equal to NDEBUG or DEBUG, CURLDEBUG
84 ifndef DB
85 DB      = NDEBUG
86 endif
87 # Optimization: -O<n> or debugging: -g
88 ifeq ($(DB),NDEBUG)
89         OPT     = -O2
90         OBJDIR  = release
91 else
92         OPT     = -g
93         OBJDIR  = debug
94 endif
95
96 # The following lines defines your compiler.
97 ifdef CWFolder
98         METROWERKS = $(CWFolder)
99 endif
100 ifdef METROWERKS
101         # MWCW_PATH = $(subst \,/,$(METROWERKS))/Novell Support
102         MWCW_PATH = $(subst \,/,$(METROWERKS))/Novell Support/Metrowerks Support
103         CC = mwccnlm
104 else
105         CC = gcc
106 endif
107 PERL    = perl
108 # Here you can find a native Win32 binary of the original awk:
109 # http://www.gknw.net/development/prgtools/awk-20100523.zip
110 AWK     = awk
111 CP      = cp -afv
112 MKDIR   = mkdir
113 # RM    = rm -f
114 # If you want to mark the target as MTSAFE you will need a tool for
115 # generating the xdc data for the linker; here's a minimal tool:
116 # http://www.gknw.net/development/prgtools/mkxdc.zip
117 MPKXDC  = mkxdc
118
119 # LIBARCH_U = $(shell $(AWK) 'BEGIN {print toupper(ARGV[1])}' $(LIBARCH))
120 LIBARCH_L = $(shell $(AWK) 'BEGIN {print tolower(ARGV[1])}' $(LIBARCH))
121
122 # Include the version info retrieved from curlver.h
123 -include $(OBJDIR)/version.inc
124
125 # Global flags for all compilers
126 CFLAGS  += $(OPT) -D$(DB) -DNETWARE -DHAVE_CONFIG_H -nostdinc
127
128 ifeq ($(CC),mwccnlm)
129 LD      = mwldnlm
130 LDFLAGS = -nostdlib $(OBJS) $(PRELUDE) $(LDLIBS) -o $@ -commandfile
131 LIBEXT  = lib
132 CFLAGS  += -gccinc -inline off -opt nointrinsics -proc 586
133 CFLAGS  += -relax_pointers
134 #CFLAGS += -w on
135 ifeq ($(LIBARCH),LIBC)
136 ifeq ($(POSIXFL),1)
137         PRELUDE = $(NDK_LIBC)/imports/posixpre.o
138 else
139         PRELUDE = $(NDK_LIBC)/imports/libcpre.o
140 endif
141         CFLAGS += -align 4
142 else
143         # PRELUDE = $(NDK_CLIB)/imports/clibpre.o
144         # to avoid the __init_* / __deinit_* whoes dont use prelude from NDK
145         PRELUDE = "$(MWCW_PATH)/libraries/runtime/prelude.obj"
146         # CFLAGS += -include "$(MWCW_PATH)/headers/nlm_clib_prefix.h"
147         CFLAGS += -align 1
148 endif
149 else
150 LD      = nlmconv
151 LDFLAGS = -T
152 LIBEXT  = a
153 CFLAGS  += -m32
154 CFLAGS  += -fno-builtin -fno-strict-aliasing
155 ifeq ($(findstring gcc,$(CC)),gcc)
156 CFLAGS  += -fpcc-struct-return
157 endif
158 CFLAGS  += -Wall # -pedantic
159 ifeq ($(LIBARCH),LIBC)
160 ifeq ($(POSIXFL),1)
161         PRELUDE = $(NDK_LIBC)/imports/posixpre.gcc.o
162 else
163         PRELUDE = $(NDK_LIBC)/imports/libcpre.gcc.o
164 endif
165 else
166         # PRELUDE = $(NDK_CLIB)/imports/clibpre.gcc.o
167         # to avoid the __init_* / __deinit_* whoes dont use prelude from NDK
168         # http://www.gknw.net/development/mk_nlm/gcc_pre.zip
169         PRELUDE = $(NDK_ROOT)/pre/prelude.o
170         CFLAGS += -include $(NDKBASE)/nlmconv/genlm.h
171 endif
172 endif
173
174 NDK_ROOT = $(NDKBASE)/ndk
175 ifndef NDK_CLIB
176 NDK_CLIB = $(NDK_ROOT)/nwsdk
177 endif
178 ifndef NDK_LIBC
179 NDK_LIBC = $(NDK_ROOT)/libc
180 endif
181 ifndef NDK_LDAP
182 NDK_LDAP = $(NDK_ROOT)/cldapsdk/netware
183 endif
184 CURL_INC = ../include
185 CURL_LIB = ../lib
186
187 INCLUDES = -I$(CURL_INC) -I$(CURL_LIB)
188
189 ifeq ($(findstring -static,$(CFG)),-static)
190 LINK_STATIC = 1
191 endif
192 ifeq ($(findstring -ares,$(CFG)),-ares)
193 WITH_ARES = 1
194 endif
195 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
196 WITH_RTMP = 1
197 WITH_SSL = 1
198 WITH_ZLIB = 1
199 endif
200 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
201 WITH_SSH2 = 1
202 WITH_SSL = 1
203 WITH_ZLIB = 1
204 endif
205 ifeq ($(findstring -axtls,$(CFG)),-axtls)
206 WITH_AXTLS = 1
207 WITH_SSL =
208 else
209 ifeq ($(findstring -ssl,$(CFG)),-ssl)
210 WITH_SSL = 1
211 endif
212 endif
213 ifeq ($(findstring -zlib,$(CFG)),-zlib)
214 WITH_ZLIB = 1
215 endif
216 ifeq ($(findstring -idn,$(CFG)),-idn)
217 WITH_IDN = 1
218 endif
219 ifeq ($(findstring -spnego,$(CFG)),-spnego)
220 WITH_SPNEGO = 1
221 endif
222 ifeq ($(findstring -metalink,$(CFG)),-metalink)
223 WITH_METALINK = 1
224 endif
225 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
226 ENABLE_IPV6 = 1
227 endif
228
229 ifdef LINK_STATIC
230         LDLIBS  = $(CURL_LIB)/libcurl.$(LIBEXT)
231 ifdef WITH_ARES
232         LDLIBS += $(LIBCARES_PATH)/libcares.$(LIBEXT)
233 endif
234 else
235         MODULES = libcurl.nlm
236         IMPORTS = @$(CURL_LIB)/libcurl.imp
237 endif
238 ifdef WITH_SSH2
239         # INCLUDES += -I$(LIBSSH2_PATH)/include
240 ifdef LINK_STATIC
241         LDLIBS += $(LIBSSH2_PATH)/nw/libssh2.$(LIBEXT)
242 else
243         MODULES += libssh2.nlm
244         IMPORTS += @$(LIBSSH2_PATH)/nw/libssh2.imp
245 endif
246 endif
247 ifdef WITH_RTMP
248         # INCLUDES += -I$(LIBRTMP_PATH)
249 ifdef LINK_STATIC
250         LDLIBS += $(LIBRTMP_PATH)/librtmp/librtmp.$(LIBEXT)
251 endif
252 endif
253 ifdef WITH_SSL
254         # INCLUDES += -I$(OPENSSL_PATH)/outinc_nw_$(LIBARCH_L)
255         LDLIBS += $(OPENSSL_PATH)/out_nw_$(LIBARCH_L)/ssl.$(LIBEXT)
256         LDLIBS += $(OPENSSL_PATH)/out_nw_$(LIBARCH_L)/crypto.$(LIBEXT)
257         IMPORTS += GetProcessSwitchCount RunningProcess
258 ifdef WITH_SPNEGO
259         # INCLUDES += -I$(FBOPENSSL_PATH)/include
260         LDLIBS += $(FBOPENSSL_PATH)/nw/fbopenssl.$(LIBEXT)
261 endif
262 else
263 ifdef WITH_AXTLS
264         # INCLUDES += -I$(AXTLS_PATH)/inc
265 ifdef LINK_STATIC
266         LDLIBS += $(AXTLS_PATH)/lib/libaxtls.$(LIBEXT)
267 else
268         MODULES += libaxtls.nlm
269         IMPORTS += $(AXTLS_PATH)/lib/libaxtls.imp
270 endif
271 endif
272 endif
273 ifdef WITH_ZLIB
274         INCLUDES += -I$(ZLIB_PATH)
275 ifdef LINK_STATIC
276         LDLIBS += $(ZLIB_PATH)/nw/$(LIBARCH)/libz.$(LIBEXT)
277 else
278         MODULES += libz.nlm
279         IMPORTS += @$(ZLIB_PATH)/nw/$(LIBARCH)/libz.imp
280 endif
281 endif
282 ifdef WITH_IDN
283         # INCLUDES += -I$(LIBIDN_PATH)/include
284         LDLIBS += $(LIBIDN_PATH)/lib/libidn.$(LIBEXT)
285 endif
286 ifdef WITH_METALINK
287         CFLAGS += -DUSE_METALINK
288         INCLUDES += -I$(METALINK_PATH)/include
289         LDLIBS += $(METALINK_PATH)/lib/libmetalink.$(LIBEXT)
290 endif
291
292 ifeq ($(LIBARCH),LIBC)
293         INCLUDES += -I$(NDK_LIBC)/include
294         # INCLUDES += -I$(NDK_LIBC)/include/nks
295         # INCLUDES += -I$(NDK_LIBC)/include/winsock
296         CFLAGS += -D_POSIX_SOURCE
297 else
298         INCLUDES += -I$(NDK_CLIB)/include/nlm
299         # INCLUDES += -I$(NDK_CLIB)/include
300 endif
301 ifndef DISABLE_LDAP
302         # INCLUDES += -I$(NDK_LDAP)/$(LIBARCH_L)/inc
303 endif
304 CFLAGS  += $(INCLUDES)
305
306 ifeq ($(MTSAFE),YES)
307         XDCOPT = -n
308 endif
309 ifeq ($(MTSAFE),NO)
310         XDCOPT = -u
311 endif
312 ifdef XDCOPT
313         XDCDATA = $(OBJDIR)/$(TARGET).xdc
314 endif
315
316 ifeq ($(findstring /sh,$(SHELL)),/sh)
317 DL      = '
318 DS      = /
319 PCT     = %
320 #-include $(NDKBASE)/nlmconv/ncpfs.inc
321 else
322 DS      = \\
323 PCT     = %%
324 endif
325
326 # Makefile.inc provides the CSOURCES and HHEADERS defines
327 include Makefile.inc
328
329 OBJX    := $(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(strip $(CURLX_ONES))))
330 OBJS    := $(patsubst %.c,$(OBJDIR)/%.o,$(strip $(CURL_CFILES)))
331 ifndef LINK_STATIC
332 OBJS    += $(OBJX)
333 endif
334
335 vpath %.c $(CURL_LIB)
336
337 all: prebuild $(TARGET).nlm
338
339 prebuild: $(OBJDIR) $(OBJDIR)/version.inc
340
341 $(OBJDIR)/%.o: %.c
342 #       @echo Compiling $<
343         $(CC) $(CFLAGS) -c $< -o $@
344
345 $(OBJDIR)/version.inc: $(CURL_INC)/curl/curlver.h $(OBJDIR)
346         @echo Creating $@
347         @$(AWK) -f ../packages/NetWare/get_ver.awk $< > $@
348
349 install: $(INSTDIR) all
350         @-$(CP) ../docs/$(TARGET).pdf $(INSTDIR)
351         @-$(CP) ../docs/$(TARGET).html $(INSTDIR)
352         @$(CP) $(TARGET).nlm $(INSTDIR)
353
354 clean:
355 ifeq "$(wildcard hugehelp.c.cvs)" "hugehelp.c.cvs"
356         -$(RM) hugehelp.c
357 endif
358         -$(RM) -r $(OBJDIR)
359
360 distclean vclean: clean
361         -$(RM) $(TARGET).nlm
362
363 $(OBJDIR) $(INSTDIR):
364         @$(MKDIR) $@
365
366 $(TARGET).nlm: $(OBJS) $(OBJDIR)/$(TARGET).def $(XDCDATA)
367         @echo Linking $@
368         @-$(RM) $@
369         @$(LD) $(LDFLAGS) $(OBJDIR)/$(TARGET).def
370
371 $(OBJDIR)/%.xdc: Makefile.netware
372         @echo Creating $@
373         @$(MPKXDC) $(XDCOPT) $@
374
375 $(OBJDIR)/%.def: Makefile.netware
376         @echo $(DL)# DEF file for linking with $(LD)$(DL) > $@
377         @echo $(DL)# Do not edit this file - it is created by make!$(DL) >> $@
378         @echo $(DL)# All your changes will be lost!!$(DL) >> $@
379         @echo $(DL)#$(DL) >> $@
380         @echo $(DL)copyright "$(COPYR)"$(DL) >> $@
381         @echo $(DL)description "$(DESCR)"$(DL) >> $@
382         @echo $(DL)version $(VERSION)$(DL) >> $@
383 ifdef NLMTYPE
384         @echo $(DL)type $(NLMTYPE)$(DL) >> $@
385 endif
386 ifdef STACK
387         @echo $(DL)stack $(STACK)$(DL) >> $@
388 endif
389 ifdef SCREEN
390         @echo $(DL)screenname "$(SCREEN)"$(DL) >> $@
391 else
392         @echo $(DL)screenname "DEFAULT"$(DL) >> $@
393 endif
394 ifneq ($(DB),NDEBUG)
395         @echo $(DL)debug$(DL) >> $@
396 endif
397         @echo $(DL)threadname "$(TARGET)"$(DL) >> $@
398 ifdef XDCDATA
399         @echo $(DL)xdcdata $(XDCDATA)$(DL) >> $@
400 endif
401 ifeq ($(LDRING),0)
402         @echo $(DL)flag_on 16$(DL) >> $@
403 endif
404 ifeq ($(LDRING),3)
405         @echo $(DL)flag_on 512$(DL) >> $@
406 endif
407 ifeq ($(LIBARCH),CLIB)
408         @echo $(DL)start _Prelude$(DL) >> $@
409         @echo $(DL)exit _Stop$(DL) >> $@
410         @echo $(DL)import @$(NDK_CLIB)/imports/clib.imp$(DL) >> $@
411         @echo $(DL)import @$(NDK_CLIB)/imports/threads.imp$(DL) >> $@
412         @echo $(DL)import @$(NDK_CLIB)/imports/nlmlib.imp$(DL) >> $@
413         @echo $(DL)import @$(NDK_CLIB)/imports/socklib.imp$(DL) >> $@
414         @echo $(DL)module clib$(DL) >> $@
415 ifndef DISABLE_LDAP
416         @echo $(DL)import @$(NDK_LDAP)/clib/imports/ldapsdk.imp$(DL) >> $@
417         @echo $(DL)import @$(NDK_LDAP)/clib/imports/ldapssl.imp$(DL) >> $@
418 #       @echo $(DL)import @$(NDK_LDAP)/clib/imports/ldapx.imp$(DL) >> $@
419         @echo $(DL)module ldapsdk ldapssl$(DL) >> $@
420 endif
421 else
422 ifeq ($(POSIXFL),1)
423         @echo $(DL)flag_on 4194304$(DL) >> $@
424 endif
425         @echo $(DL)flag_on 64$(DL) >> $@
426         @echo $(DL)pseudopreemption$(DL) >> $@
427 ifeq ($(findstring posixpre,$(PRELUDE)),posixpre)
428         @echo $(DL)start POSIX_Start$(DL) >> $@
429         @echo $(DL)exit POSIX_Stop$(DL) >> $@
430         @echo $(DL)check POSIX_CheckUnload$(DL) >> $@
431 else
432         @echo $(DL)start _LibCPrelude$(DL) >> $@
433         @echo $(DL)exit _LibCPostlude$(DL) >> $@
434         @echo $(DL)check _LibCCheckUnload$(DL) >> $@
435 endif
436         @echo $(DL)import @$(NDK_LIBC)/imports/libc.imp$(DL) >> $@
437         @echo $(DL)import @$(NDK_LIBC)/imports/netware.imp$(DL) >> $@
438         @echo $(DL)module libc$(DL) >> $@
439 ifndef DISABLE_LDAP
440         @echo $(DL)import @$(NDK_LDAP)/libc/imports/lldapsdk.imp$(DL) >> $@
441         @echo $(DL)import @$(NDK_LDAP)/libc/imports/lldapssl.imp$(DL) >> $@
442 #       @echo $(DL)import @$(NDK_LDAP)/libc/imports/lldapx.imp$(DL) >> $@
443         @echo $(DL)module lldapsdk lldapssl$(DL) >> $@
444 endif
445 endif
446 ifdef MODULES
447         @echo $(DL)module $(MODULES)$(DL) >> $@
448 endif
449 ifdef EXPORTS
450         @echo $(DL)export $(EXPORTS)$(DL) >> $@
451 endif
452 ifdef IMPORTS
453         @echo $(DL)import $(IMPORTS)$(DL) >> $@
454 endif
455 ifeq ($(findstring nlmconv,$(LD)),nlmconv)
456         @echo $(DL)input $(PRELUDE)$(DL) >> $@
457         @echo $(DL)input $(OBJS)$(DL) >> $@
458 ifdef LDLIBS
459         @echo $(DL)input $(LDLIBS)$(DL) >> $@
460 endif
461         @echo $(DL)output $(TARGET).nlm$(DL) >> $@
462 endif
463
464 hugehelp.c:
465         @echo Creating $@
466         @$(CP) hugehelp.c.cvs $@
467
468 $(LIBCARES_PATH)/libcares.$(LIBEXT):
469         $(MAKE) -C $(LIBCARES_PATH) -f Makefile.netware lib
470
471