# compiler flags

SOPE_ROOT=../..

ADDITIONAL_INCLUDE_DIRS += \
	-I..				\
	-I../../sope-core/NGExtensions	\
	-I../../sope-core		\
	-I/usr/local/include

ADDITIONAL_CPPFLAGS += -Wall -Wno-protocol


# dependencies

libNGLdap_LIBRARIES_DEPEND_UPON += \
	-lNGExtensions -lEOControl	\
	-lDOM -lSaxObjC
NGLdap_LIBRARIES_DEPEND_UPON += \
	-framework NGExtensions -framework EOControl	\
	-framework DOM -framework SaxObjC


# OpenLDAP library dependencies

ifeq ($(reentrant),yes)
ADDITIONAL_CPPFLAGS += -D_REENTRANT=1
libNGLdap_LIBRARIES_DEPEND_UPON += -lldap_r -llber -lpthread
NGLdap_LIBRARIES_DEPEND_UPON    += -lldap_r -llber -lpthread
else
libNGLdap_LIBRARIES_DEPEND_UPON += -lldap -llber
NGLdap_LIBRARIES_DEPEND_UPON    += -lldap -llber
endif


# SASL/SSL dependencies

ifneq ($(FOUNDATION_LIB),nx)

ifeq ($(sasl),yes)
libNGLdap_LIBRARIES_DEPEND_UPON += -lsasl
endif
ifneq ($(nossl),yes)
libNGLdap_LIBRARIES_DEPEND_UPON += -lssl
endif

else # is NeXT/Apple Foundation

# TODO: document whether Foundation includes required dependencies
ADDITIONAL_LDFLAGS += -framework Foundation

endif


# library/framework search pathes

DEP_DIRS = \
	$(SOPE_ROOT)/sope-core/NGStreams	\
	$(SOPE_ROOT)/sope-core/NGExtensions	\
	$(SOPE_ROOT)/sope-core/EOControl	\
	$(SOPE_ROOT)/sope-xml/DOM		\
	$(SOPE_ROOT)/sope-xml/SaxObjC

ifneq ($(frameworks),yes)
ADDITIONAL_LIB_DIRS += \
	$(foreach dir,$(DEP_DIRS),\
	  -L$(GNUSTEP_BUILD_DIR)/$(dir)/$(GNUSTEP_OBJ_DIR_NAME))
else
ADDITIONAL_LIB_DIRS += \
	$(foreach dir,$(DEP_DIRS),-F$(GNUSTEP_BUILD_DIR)/$(dir))
endif

SYSTEM_LIB_DIR += -L/usr/local/lib


# Apple

ifeq ($(FOUNDATION_LIB),apple)
libNGLdap_PREBIND_ADDR="0xC1C00000"
libNGLdap_LDFLAGS += -seg1addr $(libNGLdap_PREBIND_ADDR)
NGLdap_LDFLAGS += -seg1addr $(libNGLdap_PREBIND_ADDR)
endif

# only required on 10.2 and before?
#ifneq ($(FOUNDATION_LIB),apple)
#ADDITIONAL_INCLUDE_DIRS += -I/usr/local/openldap/include
#SYSTEM_LIB_DIR += -L/usr/local/openldap/lib
#endif


# Windows

ifeq ($(GNUSTEP_TARGET_OS),mingw32)
libNGLdap_LIBRARIES_DEPEND_UPON += -lFoundation -lobjc
endif
ifeq ($(GNUSTEP_TARGET_OS),cygwin32)
libNGLdap_LIBRARIES_DEPEND_UPON += -lFoundation -lobjc
endif