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