FLAGS  += -m32
CFLAGS	+= -fno-builtin -fno-strict-aliasing
ifeq ($(findstring gcc,$(CC)),gcc)
CFLAGS	+= -fpcc-struct-return
endif
CFLAGS	+= -Wall # -pedantic
ifeq ($(LIBARCH),LIBC)
ifeq ($(POSIXFL),1)
	PRELUDE = $(NDK_LIBC)/imports/posixpre.gcc.o
else
	PRELUDE = $(NDK_LIBC)/imports/libcpre.gcc.o
endif
else
	PRELUDE = $(NDK_CLIB)/imports/clibpre.gcc.o
	# to avoid the __init_* / __deinit_* woes don't use prelude from NDK
	# http://www.gknw.net/development/mk_nlm/gcc_pre.zip
	# PRELUDE = $(NDK_ROOT)/pre/prelude.o
	CFLAGS += -include $(NDKBASE)/nlmconv/genlm.h
endif
endif

NDK_ROOT = $(NDKBASE)/ndk
ifndef NDK_CLIB
NDK_CLIB = $(NDK_ROOT)/nwsdk
endif
ifndef NDK_LIBC
NDK_LIBC = $(NDK_ROOT)/libc
endif
ifndef NDK_LDAP
NDK_LDAP = $(NDK_ROOT)/cldapsdk/netware
endif
CURL_INC = ../include
CURL_LIB = ../lib

INCLUDES = -I$(CURL_INC) -I$(CURL_LIB)

ifeq ($(findstring -static,$(CFG)),-static)
LINK_STATIC = 1
endif
ifeq ($(findstring -ares,$(CFG)),-ares)
WITH_ARES = 1
endif
ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
WITH_RTMP = 1
WITH_SSL = 1
WITH_ZLIB = 1
endif
ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
WITH_SSH2 = 1
WITH_SSL = 1
WITH_ZLIB = 1
endif
ifeq ($(findstring -axtls,$(CFG)),-axtls)
WITH_AXTLS = 1
WITH_SSL =
else
ifeq ($(findstring -ssl,$(CFG)),-ssl)
WITH_SSL = 1
ifeq ($(findstring -srp,$(CFG)),-srp)
ifeq "$(wildcard $(OPENSSL_PATH)/outinc_nw_$(LIBARCH_L)/openssl/srp.h)" "$(OPENSSL_PATH)/outinc_nw_$(LIBARCH_L)/openssl/srp.h"
WITH_SRP = 1
endif
endif
endif
endif
ifeq ($(findstring -zlib,$(CFG)),-zlib)
WITH_ZLIB = 1
endif
ifeq ($(findstring -idn,$(CFG)),-idn)
WITH_IDN = 1
endif
ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
WITH_NGHTTP2 = 1
endif
ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
ENABLE_IPV6 = 1
endif

ifdef WITH_ARES
	INCLUDES += -I$(LIBCARES_PATH)
	LDLIBS += $(LIBCARES_PATH)/libcares.$(LIBEXT)
endif
ifdef WITH_SSH2
	INCLUDES += -I$(LIBSSH2_PATH)/include
ifdef LINK_STATIC
	LDLIBS += $(LIBSSH2_PATH)/nw/libssh2.$(LIBEXT)
else
	MODULES += libssh2.nlm
	IMPORTS += @$(LIBSSH2_PATH)/nw/libssh2.imp
endif
endif
ifdef WITH_RTMP
	INC