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