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