LUDES += -I$(LIBRTMP_PATH)
	LDLIBS += $(LIBRTMP_PATH)/librtmp/librtmp.$(LIBEXT)
endif
ifdef WITH_SSL
	INCLUDES += -I$(OPENSSL_PATH)/outinc_nw_$(LIBARCH_L)
	LDLIBS += $(OPENSSL_PATH)/out_nw_$(LIBARCH_L)/ssl.$(LIBEXT)
	LDLIBS += $(OPENSSL_PATH)/out_nw_$(LIBARCH_L)/crypto.$(LIBEXT)
	IMPORTS += GetProcessSwitchCount RunningProcess
	INSTDEP += ca-bundle.crt
else
ifdef WITH_AXTLS
	INCLUDES += -I$(AXTLS_PATH)/inc
ifdef LINK_STATIC
	LDLIBS += $(AXTLS_PATH)/lib/libaxtls.$(LIBEXT)
else
	MODULES += libaxtls.nlm
	IMPORTS += $(AXTLS_PATH)/lib/libaxtls.imp
endif
	INSTDEP += ca-bundle.crt
endif
endif
ifdef WITH_ZLIB
	INCLUDES += -I$(ZLIB_PATH)
ifdef LINK_STATIC
	LDLIBS += $(ZLIB_PATH)/nw/$(LIBARCH)/libz.$(LIBEXT)
else
	MODULES += libz.nlm
	IMPORTS += @$(ZLIB_PATH)/nw/$(LIBARCH)/libz.imp
endif
endif
ifdef WITH_IDN
	INCLUDES += -I$(LIBIDN_PATH)/include
	LDLIBS += $(LIBIDN_PATH)/lib/libidn.$(LIBEXT)
endif
ifdef WITH_NGHTTP2
	INCLUDES += -I$(NGHTTP2_PATH)/include
	LDLIBS += $(NGHTTP2_PATH)/lib/libnghttp2.$(LIBEXT)
endif

ifeq ($(LIBARCH),LIBC)
	INCLUDES += -I$(NDK_LIBC)/include
	# INCLUDES += -I$(NDK_LIBC)/include/nks
	# INCLUDES += -I$(NDK_LIBC)/include/winsock
	CFLAGS += -D_POSIX_SOURCE
else
	INCLUDES += -I$(NDK_CLIB)/include/nlm
	# INCLUDES += -I$(NDK_CLIB)/include/nlm/obsolete
	# INCLUDES += -I$(NDK_CLIB)/include
endif
ifndef DISABLE_LDAP
	INCLUDES += -I$(NDK_LDAP)/$(LIBARCH_L)/inc
endif
CFLAGS	+= $(INCLUDES)

ifeq ($(MTSAFE),YES)
	XDCOPT = -n
endif
ifeq ($(MTSAFE),NO)
	XDCOPT = -u
endif
ifdef XDCOPT
	XDCDATA = $(OBJDIR)/$(TARGET).xdc
endif

ifeq ($(findstring /sh,$(SHELL)),/sh)
DL	= '
DS	= /
PCT	= %
#-include $(NDKBASE)/nlmconv/ncpfs.inc
else
DS	= \\
PCT	= %%
endif

# Makefile.inc provides the CSOURCES and HHEADERS defines
include Makefile.inc

OBJS	:= $(patsubst %.c,$(OBJDIR)/%.o,$(strip $(notdir $(CSOURCES)))) $(OBJDIR)/nwos.o

OBJL	= $(OBJS) $(OBJDIR)/nwlib.o $(LDLIBS)

vpath %.c . vauth vtls

all: lib nlm

nlm: prebuild $(TARGET).nlm

lib: prebuild $(TARGET).$(LIBEXT)

prebuild: $(OBJDIR) $(OBJDIR)/version.inc curl_config.