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