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