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