1######################################################################### 2# 3## Makefile for building libssh2 (NetWare version - gnu make) 4## 5## Hacked by: Guenter Knauf 6# 7######################################################################### 8 9# Edit the path below to point to the base of your Novell NDK. 10ifndef NDKBASE 11NDKBASE = c:/novell 12endif 13 14# Edit the path below to point to the base of your Zlib sources. 15ifndef ZLIB_PATH 16ZLIB_PATH = ../../../zlib-1.2.8 17endif 18 19# Edit the path below to point to the base of your OpenSSL package. 20ifndef OPENSSL_PATH 21OPENSSL_PATH = ../../../openssl-0.9.8zc 22endif 23 24# Edit the var below to enable static linking of libssh2 and libz 25LINK_STATIC = 1 26 27# Edit the vars below to change NLM target settings. 28SAMPLES = ../../example 29TARGETS := $(filter-out x11.nlm,$(patsubst $(SAMPLES)/%.c,%.nlm,$(strip $(wildcard $(SAMPLES)/*.c)))) 30VERSION = $(LIBSSH2_VERSION) 31COPYR = Copyright (c) $(LIBSSH2_COPYRIGHT_STR) 32WWWURL = http://www.libssh2.org/ 33DESCR = libssh2 $(notdir $(@:.def=)) $(LIBSSH2_VERSION_STR) ($(LIBARCH)) - $(WWWURL) 34MTSAFE = YES 35STACK = 64000 36SCREEN = NONE 37#SCREEN = libssh2 $(notdir $(@:.def=)) 38# Comment the line below if you dont want to load protected automatically. 39#LDRING = 3 40 41# Edit the var below to point to your lib architecture. 42ifndef LIBARCH 43LIBARCH = LIBC 44endif 45 46# must be equal to DEBUG or NDEBUG 47ifndef DB 48 DB = NDEBUG 49 # DB = DEBUG 50endif 51# Optimization: -O<n> or debugging: -g 52ifeq ($(DB),NDEBUG) 53 OPT = -O2 54 OBJDIR = release 55else 56 OPT = -g 57 OPT += -DLIBSSH2DEBUG 58 OBJDIR = debug 59endif 60 61# The following lines defines your compiler. 62ifdef CWFolder 63 METROWERKS = $(CWFolder) 64endif 65ifdef METROWERKS 66 # MWCW_PATH = $(subst \,/,$(METROWERKS))/Novell Support 67 MWCW_PATH = $(subst \,/,$(METROWERKS))/Novell Support/Metrowerks Support 68 CC = mwccnlm 69else 70 CC = $(CROSSPREFIX)gcc 71endif 72 73# Here you can find a native Win32 binary of the original awk: 74# http://www.gknw.net/development/prgtools/awk-20100523.zip 75AWK = awk 76# If you want to mark the target as MTSAFE you will need a tool for 77# generating the xdc data for the linker; here's a minimal tool: 78# http://www.gknw.net/development/prgtools/mkxdc.zip 79MPKXDC = mkxdc 80 81# Platform-dependent helper tool macros 82ifeq ($(findstring /sh,$(SHELL)),/sh) 83DEL = rm -f $1 84RMDIR = rm -fr $1 85MKDIR = mkdir -p $1 86COPY = -cp -afv $1 $2 87#COPYR = -cp -afr $1/* $2 88COPYR = -rsync -aC $1/* $2 89TOUCH = touch $1 90CAT = cat 91ECHONL = echo "" 92DL = ' 93else 94ifeq "$(OS)" "Windows_NT" 95DEL = -del 2>NUL /q /f $(subst /,\,$1) 96RMDIR = -rd 2>NUL /q /s $(subst /,\,$1) 97else 98DEL = -del 2>NUL $(subst /,\,$1) 99RMDIR = -deltree 2>NUL /y $(subst /,\,$1) 100endif 101MKDIR = -md 2>NUL $(subst /,\,$1) 102COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2) 103COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2) 104TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,, 105CAT = type 106ECHONL = $(ComSpec) /c echo. 107endif 108 109# LIBARCH_U = $(shell $(AWK) 'BEGIN {print toupper(ARGV[1])}' $(LIBARCH)) 110LIBARCH_L = $(shell $(AWK) 'BEGIN {print tolower(ARGV[1])}' $(LIBARCH)) 111 112# Include the version info retrieved from libssh2.h 113-include $(OBJDIR)/version.inc 114 115# Global flags for all compilers 116CFLAGS += $(OPT) -D$(DB) -DNETWARE -nostdinc 117 118ifeq ($(CC),mwccnlm) 119LD = mwldnlm 120LDFLAGS = -nostdlib $(<:.def=.o) $(PRELUDE) $(LDLIBS) -o $@ -commandfile 121AR = mwldnlm 122ARFLAGS = -type library -w nocmdline $(OBJS) -o 123LIBEXT = lib 124CFLAGS += -msgstyle gcc -gccinc -inline off -opt nointrinsics -proc 586 125CFLAGS += -relax_pointers 126#CFLAGS += -w on 127ifeq ($(LIBARCH),LIBC) 128 PRELUDE = $(SDK_LIBC)/imports/libcpre.o 129 CFLAGS += -align 4 130else 131 # PRELUDE = $(SDK_CLIB)/imports/clibpre.o 132 # to avoid the __init_* / __deinit_* whoes dont use prelude from NDK 133 PRELUDE = "$(MWCW_PATH)/libraries/runtime/prelude.obj" 134 # CFLAGS += -include "$(MWCW_PATH)/headers/nlm_clib_prefix.h" 135 CFLAGS += -align 1 136endif 137else 138LD = nlmconv 139LDFLAGS = -UT 140AR = ar 141ARFLAGS = -cq 142LIBEXT = a 143CFLAGS += -m32 144CFLAGS += -fno-builtin -fpcc-struct-return 145CFLAGS += -fno-strict-aliasing 146CFLAGS += -Wall # -pedantic 147ifeq ($(LIBARCH),LIBC) 148 PRELUDE = $(SDK_LIBC)/imports/libcpre.gcc.o 149else 150 # PRELUDE = $(SDK_CLIB)/imports/clibpre.gcc.o 151 # to avoid the __init_* / __deinit_* whoes dont use prelude from NDK 152 # http://www.gknw.net/development/mk_nlm/gcc_pre.zip 153 PRELUDE = $(NDK_ROOT)/pre/prelude.o 154 CFLAGS += -include $(NDKBASE)/nlmconv/genlm.h 155endif 156endif 157 158NDK_ROOT = $(NDKBASE)/ndk 159SDK_CLIB = $(NDK_ROOT)/nwsdk 160SDK_LIBC = $(NDK_ROOT)/libc 161SNPRINTF = $(NDKBASE)/snprintf 162 163INCLUDES = -I.. -I../../include 164 165LDLIBS = 166 167ifdef LINK_STATIC 168 LDLIBS += ../libssh2.$(LIBEXT) 169else 170 IMPORTS += @../libssh2.imp 171 MODULES += libssh2.nlm 172endif 173 174INCLUDES += -I$(OPENSSL_PATH)/outinc_nw_$(LIBARCH_L) 175LDLIBS += $(OPENSSL_PATH)/out_nw_$(LIBARCH_L)/ssl.$(LIBEXT) 176LDLIBS += $(OPENSSL_PATH)/out_nw_$(LIBARCH_L)/crypto.$(LIBEXT) 177IMPORTS += GetProcessSwitchCount RunningProcess 178 179ifdef WITH_ZLIB 180 INCLUDES += -I$(ZLIB_PATH) 181ifdef LINK_STATIC 182 LDLIBS += $(ZLIB_PATH)/nw/$(LIBARCH)/libz.$(LIBEXT) 183else 184 MODULES += libz.nlm 185 IMPORTS += @$(ZLIB_PATH)/nw/$(LIBARCH)/libz.imp 186endif 187endif 188 189ifeq ($(LIBARCH),LIBC) 190 INCLUDES += -I$(SDK_LIBC)/include 191 # INCLUDES += -I$(SDK_LIBC)/include/nks 192 # INCLUDES += -I$(SDK_LIBC)/include/winsock 193 CFLAGS += -D_POSIX_SOURCE 194else 195 INCLUDES += -I$(SDK_CLIB)/include/nlm 196 # INCLUDES += -I$(SDK_CLIB)/include/nlm/obsolete 197 # INCLUDES += -I$(SDK_CLIB)/include 198 # CFLAGS += -DNETDB_USE_INTERNET 199endif 200CFLAGS += $(INCLUDES) 201 202ifeq ($(MTSAFE),YES) 203 XDCOPT = -n 204endif 205ifeq ($(MTSAFE),NO) 206 XDCOPT = -u 207endif 208 209vpath %.c $(SAMPLES) 210 211.PRECIOUS: $(OBJDIR)/%.o $(OBJDIR)/%.def $(OBJDIR)/%.xdc 212 213 214all: prebuild $(TARGETS) 215 216prebuild: $(OBJDIR) $(OBJDIR)/version.inc 217 218$(OBJDIR)/%.o: %.c 219# @echo Compiling $< 220 $(CC) $(CFLAGS) -c $< -o $@ 221 222$(OBJDIR)/version.inc: ../../get_ver.awk ../../include/libssh2.h $(OBJDIR) 223 @echo Creating $@ 224 @$(AWK) -f $^ > $@ 225 226objclean: 227 $(call RMDIR, $(OBJDIR)) 228 229clean: objclean 230 $(foreach f, $(TARGETS), $(call DEL, $(f))) 231 232$(OBJDIR): 233 @$(call MKDIR, $@) 234 235%.nlm: $(OBJDIR)/%.def $(OBJDIR)/%.o $(OBJDIR)/%.xdc 236 @echo Linking $@ 237 @$(call DEL, $@) 238 @$(LD) $(LDFLAGS) $< 239 240$(OBJDIR)/%.xdc: GNUmakefile 241 @echo Creating $@ 242 @$(MPKXDC) $(XDCOPT) $@ 243 244$(OBJDIR)/%.def: GNUmakefile 245 @echo $(DL)# DEF file for linking with $(LD)$(DL) > $@ 246 @echo $(DL)# Do not edit this file - it is created by make!$(DL) >> $@ 247 @echo $(DL)# All your changes will be lost!!$(DL) >> $@ 248 @echo $(DL)#$(DL) >> $@ 249 @echo $(DL)copyright "$(COPYR)"$(DL) >> $@ 250 @echo $(DL)description "$(DESCR)"$(DL) >> $@ 251 @echo $(DL)version $(VERSION)$(DL) >> $@ 252ifdef NLMTYPE 253 @echo $(DL)type $(NLMTYPE)$(DL) >> $@ 254endif 255ifdef STACK 256 @echo $(DL)stack $(STACK)$(DL) >> $@ 257endif 258ifdef SCREEN 259 @echo $(DL)screenname "$(SCREEN)"$(DL) >> $@ 260else 261 @echo $(DL)screenname "DEFAULT"$(DL) >> $@ 262endif 263ifeq ($(DB),DEBUG) 264 @echo $(DL)debug$(DL) >> $@ 265endif 266 @echo $(DL)threadname "$(notdir $(@:.def=))"$(DL) >> $@ 267ifdef XDCOPT 268 @echo $(DL)xdcdata $(@:.def=.xdc)$(DL) >> $@ 269endif 270ifeq ($(LDRING),0) 271 @echo $(DL)flag_on 16$(DL) >> $@ 272endif 273ifeq ($(LDRING),3) 274 @echo $(DL)flag_on 512$(DL) >> $@ 275endif 276ifeq ($(LIBARCH),CLIB) 277 @echo $(DL)start _Prelude$(DL) >> $@ 278 @echo $(DL)exit _Stop$(DL) >> $@ 279 @echo $(DL)import @$(SDK_CLIB)/imports/clib.imp$(DL) >> $@ 280 @echo $(DL)import @$(SDK_CLIB)/imports/threads.imp$(DL) >> $@ 281 @echo $(DL)import @$(SDK_CLIB)/imports/nlmlib.imp$(DL) >> $@ 282 @echo $(DL)import @$(SDK_CLIB)/imports/socklib.imp$(DL) >> $@ 283 @echo $(DL)module clib$(DL) >> $@ 284else 285 @echo $(DL)flag_on 64$(DL) >> $@ 286 @echo $(DL)pseudopreemption$(DL) >> $@ 287 @echo $(DL)start _LibCPrelude$(DL) >> $@ 288 @echo $(DL)exit _LibCPostlude$(DL) >> $@ 289 @echo $(DL)check _LibCCheckUnload$(DL) >> $@ 290 @echo $(DL)import @$(SDK_LIBC)/imports/libc.imp$(DL) >> $@ 291 @echo $(DL)import @$(SDK_LIBC)/imports/netware.imp$(DL) >> $@ 292 @echo $(DL)module libc$(DL) >> $@ 293endif 294ifdef MODULES 295 @echo $(DL)module $(MODULES)$(DL) >> $@ 296endif 297ifdef EXPORTS 298 @echo $(DL)export $(EXPORTS)$(DL) >> $@ 299endif 300ifdef IMPORTS 301 @echo $(DL)import $(IMPORTS)$(DL) >> $@ 302endif 303ifeq ($(LD),nlmconv) 304 @echo $(DL)input $(@:.def=.o)$(DL) >> $@ 305 @echo $(DL)input $(PRELUDE)$(DL) >> $@ 306ifdef LDLIBS 307 @echo $(DL)input $(LDLIBS)$(DL) >> $@ 308endif 309 @echo $(DL)output $(notdir $(@:.def=.nlm))$(DL) >> $@ 310endif 311 312