Commit 0552b1c5 authored by Howard Chu's avatar Howard Chu
Browse files

NT updates from jon@symas.com.

parent ff701c28
......@@ -7,44 +7,47 @@
## Makefile Template for Shared Libraries
##
NT_LTFLAGS = --only-$(LINKAGE)
LTFLAGS = $(@PLAT@_LTFLAGS)
NT_DYN_LT_NO_UNDEF = -no-undefined
LT_NO_UNDEF = $(@PLAT@_@LIB_LINKAGE@_LT_NO_UNDEF)
COMPILE = $(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) $(CFLAGS) $(EXTRA_DEFS) -c
LTLIBLINK = $(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -rpath $(libdir) \
$(CFLAGS) $(LDFLAGS) $(LTVERSION) $(LT_NO_UNDEF)
MKDEPFLAG = -l
.SUFFIXES: .c .o .lo
.c.lo:
$(COMPILE) $<
# DYN_EXT (@DYN_EXT@) describes the extension assoicated with a
# dynamic library, e.g. so, dll
DYN_EXT=@DYN_EXT@
$(LIBRARY): version.lo
$(LTLIBLINK) -o $@ $(OBJS) version.lo $(EXTRA_LIBS)
$(RM) ../$@
d=`$(PWD)`; d=`$(BASENAME) $$d`; cd ..; $(LN_S) $$d/$@ $@; \
t=`$(BASENAME) $@ .la`.a; $(RM) $$t; $(LN_S) $$d/.libs/$$t $$t
if test "$(LINK_BINS_DYNAMIC)" = "yes"; then \
d=`$(PWD)`; d=`$(BASENAME) $$d`; b=`$(BASENAME) $@ .la`; \
cd .libs; t=`echo $$b*.$(DYN_EXT)`; (cd ../.. ; $(RM) $$t; \
$(LN_S) $$d/.libs/$$t $$t); \
if test "$(DYN_EXT)" != dll; then \
t=`echo $$b.$(DYN_EXT).?`; cd ../.. ; \
$(RM) $$t; \
$(LN_S) $$d/.libs/$$t $$t; \
fi \
fi
$(LTCOMPILE_LIB) $<
#
# symlinks for libraries: UNIX and Windows (a.k.a. NT) need to be handled
# differently. In UNIX, the static and shared libraries, as well as shared
# library symlinks, can all be symlinked in the 'libraries' directory. In
# Windows, only the static library (.a file) or the shared library (.dll)
# file should be present. The current mingw linker (i.e. ld) WILL look
# for a .dll file at link time and internally generate an import library
# for it. However, ld will not do this if a static library is present.
# That doesn't seem very correct, but that's the behavior, like it or not.
#
# Note that there doesn't seem to be a true need for the .la file at
# this level, so it is left out.
#
# The set of symlinks are determined by examining the library's .la file.
#
$(LIBRARY): version.lo
$(LTLINK_LIB) -o $@ $(OBJS) version.lo $(LINK_LIBS)
@d=`$(PWD)`; b=`$(BASENAME) $$d`; \
echo cd ..; \
cd ..; \
arlib=`grep '^old_library=' $$b/$@`; \
arlib=`expr "$$arlib" : "[^']*'\(.*\)'"`; \
libs=$$arlib; \
if test "$(BUILD_LIBS_DYNAMIC)" = "shared"; then \
shlibs=`grep '^library_names' $$b/$@`; \
shlibs=`expr "$$shlibs" : "[^']*'\(.*\)'"`; \
libs="$$libs $$shlibs"; \
fi; \
for i in $$libs; do \
echo $(RM) $$i; \
$(RM) $$i; \
echo $(LN_S) $$b/.libs/$$i $$i; \
$(LN_S) $$b/.libs/$$i $$i; \
done
Makefile: $(top_srcdir)/build/lib-shared.mk
......@@ -21,11 +21,17 @@ lint: lint-local FORCE
lint5: lint5-local FORCE
$(5LINT) $(DEFS) $(DEFINES) $(SRCS)
#
# In the mingw/cygwin environment, the so and dll files must be
# deleted separately, instead of using the {.so*,*.dll} construct
# that was previously used. It just didn't work.
#
clean-common: FORCE
$(RM) $(LIBRARY) ../$(LIBRARY) $(XLIBRARY) \
$(PROGRAMS) $(XPROGRAMS) $(XSRCS) $(XXSRCS) \
*.o *.lo a.out *.exe core version.c .libs/* \
../`$(BASENAME) $(LIBRARY) .la`{.a,.so*,*.dll}
../`$(BASENAME) $(LIBRARY) .la`.so* \
../`$(BASENAME) $(LIBRARY) .la`*.dll
depend-common: FORCE
$(MKDEP) $(DEFS) $(DEFINES) $(SRCS) $(XXSRCS)
......@@ -34,3 +40,4 @@ lint-local: FORCE
lint5-local: FORCE
Makefile: $(top_srcdir)/build/lib.mk
......@@ -10,18 +10,12 @@
LIBRARY = $(LIBBASE).la
LIBSTAT = lib$(LIBBASE).a
LTFLAGS = --only-$(LINKAGE)
COMPILE = $(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) $(CFLAGS) $(MODDEFS) -c
LTLIBLINK = $(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -rpath $(moduledir) \
$(CFLAGS) $(LDFLAGS) $(LTVERSION) $(LT_NO_UNDEF)
MKDEPFLAG = -l
.SUFFIXES: .c .o .lo
.c.lo:
$(COMPILE) $<
$(LTCOMPILE_MOD) $<
all-no lint-no 5lint-no depend-no install-no: FORCE
@echo "run configure with $(BUILD_OPT) to make $(LIBBASE)"
......@@ -32,9 +26,8 @@ version.c: $(OBJS)
$(RM) $@
$(MKVERSION) $(LIBBASE) > $@
$(LIBRARY): $(MODDEPS) version.lo
$(LTLIBLINK) -module -o $@ $(OBJS) version.lo \
$(MODLIBS)
$(LIBRARY): version.lo
$(LTLINK_MOD) -module -o $@ $(OBJS) version.lo $(LINK_LIBS)
$(LIBSTAT): version.lo
$(AR) ruv $@ `echo $(OBJS) | sed 's/\.lo/.o/g'` version.o
......
......@@ -774,6 +774,7 @@ AC_DEFUN([OL_NT_THREADS], [
if test $ac_cv_func__beginthread = yes ; then
AC_DEFINE(HAVE_NT_THREADS,1,[if you have NT Threads])
ol_cv_nt_threads=yes
fi
])
dnl ====================================================================
......
......@@ -37,9 +37,12 @@ sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@$(ldap_subdir)
schemadir = $(sysconfdir)/schema
PLAT = @PLAT@
EXEEXT = @EXEEXT@
OBJEXT = @OBJEXT@
BUILD_LIBS_DYNAMIC = @BUILD_LIBS_DYNAMIC@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
......@@ -58,11 +61,47 @@ MKVERSION = $(top_srcdir)/build/mkversion -v "$(VERSION)"
LIBTOOL = @LIBTOOL@
LIBVERSION = @OPENLDAP_LIBVERSION@
LTVERSION = -version-info $(LIBVERSION)
#We don't use our own shared libraries (yet)
#LTLINK = $(LIBTOOL) --mode=link $(CC) -rpath $(libdir) \
# $(CFLAGS) $(LDFLAGS)
LTLINK = $(LIBTOOL) --mode=link $(CC) \
$(CFLAGS) $(LDFLAGS)
# libtool --only flag for libraries: platform specific
NT_LTONLY_LIB = --only-$(BUILD_LIBS_DYNAMIC)
LTONLY_LIB = $(@PLAT@_LTONLY_LIB)
# libtool --only flag for modules: depends on linkage of module
# The BUILD_MOD_DYNAMIC macro is defined in each backend Makefile.in file
LTONLY_MOD = --only-$(BUILD_MOD_DYNAMIC)
# platform-specific libtool flags
NT_LTFLAGS_LIB = -no-undefined -avoid-version -rpath $(libdir)
NT_LTFLAGS_MOD = -no-undefined -avoid-version -rpath $(moduledir)
UNIX_LTFLAGS_LIB = $(LTVERSION) -rpath $(libdir)
UNIX_LTFLAGS_MOD = $(LTVERSION) -rpath $(moduledir)
# libtool flags
LTFLAGS = $(@PLAT@_LTFLAGS)
LTFLAGS_LIB = $(@PLAT@_LTFLAGS_LIB)
LTFLAGS_MOD = $(@PLAT@_LTFLAGS_MOD)
# LIB_DEFS defined in liblber and libldap Makefile.in files.
# MOD_DEFS defined in backend Makefile.in files.
# platform-specific LINK_LIBS defined in various Makefile.in files.
# LINK_LIBS referenced in library and module link commands.
LINK_LIBS = $(@PLAT@_LINK_LIBS)
LTLINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LTFLAGS)
LTCOMPILE_LIB = $(LIBTOOL) $(LTONLY_LIB) --mode=compile \
$(CC) $(CFLAGS) $(CPPFLAGS) $(LIB_DEFS) -c
LTLINK_LIB = $(LIBTOOL) $(LTONLY_LIB) --mode=link \
$(CC) $(CFLAGS) $(LDFLAGS) $(LTFLAGS_LIB)
LTCOMPILE_MOD = $(LIBTOOL) $(LTONLY_MOD) --mode=compile \
$(CC) $(CFLAGS) $(CPPFLAGS) $(MOD_DEFS) -c
LTLINK_MOD = $(LIBTOOL) $(LTONLY_MOD) --mode=link \
$(CC) $(CFLAGS) $(LDFLAGS) $(LTFLAGS_MOD)
LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
# Misc UNIX commands used in build environment
......@@ -140,7 +179,6 @@ MODULES_LDFLAGS = @SLAPD_MODULES_LDFLAGS@
MODULES_LIBS = @MODULES_LIBS@
TERMCAP_LIBS = @TERMCAP_LIBS@
SLAPD_PERL_LDFLAGS = @SLAPD_PERL_LDFLAGS@
LINK_BINS_DYNAMIC = @LINK_BINS_DYNAMIC@
SLAPD_SQL_LDFLAGS = @SLAPD_SQL_LDFLAGS@
SLAPD_SQL_INCLUDES = @SLAPD_SQL_INCLUDES@
......@@ -152,7 +190,8 @@ SLURPD_LIBS = @SLURPD_LIBS@
# Our Defaults
CC = $(AC_CC)
DEFS = $(LDAP_INCPATH) $(XINCPATH) $(XDEFS) $(AC_DEFS) $(DEFINES)
CFLAGS = $(AC_CFLAGS) $(DEFS)
CFLAGS = $(AC_CFLAGS)
CPPFLAGS = $(DEFS)
LDFLAGS = $(LDAP_LIBPATH) $(AC_LDFLAGS) $(XLDFLAGS)
LIBS = $(XLIBS) $(XXLIBS) $(AC_LIBS) $(XXXLIBS)
......
......@@ -4,4 +4,6 @@
##
## Clients Makefile.in for OpenLDAP
SUBDIRS= tools ud
SUBDIRS = tools ud
CLEANDIRS = finger mail500 maildap
......@@ -8,9 +8,6 @@ OBJS = ldapsearch.o ldapmodify.o ldapdelete.o ldapmodrdn.o ldappasswd.o
LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries
NT_DYN_DEFS = -DLBER_DECL=dllimport -DLDAP_DECL=dllimport
CPPFLAGS = $(@PLAT@_@LIB_LINKAGE@_DEFS)
XLIBS = -llutil -lldif -lldap -llber
XXLIBS = $(SECURITY_LIBS) $(LDIF_LIBS) $(LUTIL_LIBS)
......
......@@ -6,16 +6,15 @@ XSRCS= version.c
OBJS= main.o find.o mod.o print.o auth.o util.o help.o \
group.o globals.o edit.o
HDRS= ud.h
PROGRAMS= ud
UNIX_PRGS = ud
PROGRAMS = $(@PLAT@_PRGS)
LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries
NT_DYN_DEFS = -DLBER_DECL=dllimport -DLDAP_DECL=dllimport
CPPFLAGS = $(@PLAT@_@LIB_LINKAGE@_DEFS)
XLIBS = -llutil -lldif -lldap -llber
XXLIBS = $(TERMCAP_LIBS) $(SECURITY_LIBS) $(LUTIL_LIBS)
XXLIBS = $(TERMCAP_LIBS) $(SECURITY_LIBS) $(LDIF_LIBS) $(LUTIL_LIBS)
ud : version.o
$(LTLINK) -o $@ version.o $(OBJS) $(LIBS)
......
......@@ -788,6 +788,7 @@ AC_CHECK_HEADERS( \
termios.h \
unistd.h \
winsock.h \
winsock2.h \
)
......@@ -799,24 +800,43 @@ AC_CHECK_FUNC(dlopen, :, [AC_CHECK_LIB(dl, dlopen)])
dnl HP-UX requires -lV3
AC_CHECK_LIB(V3, sigset)
dnl Gotta check for winsock manually
if test $ac_cv_header_winsock_h = yes; then
AC_CACHE_CHECK([for winsock], [ol_cv_winsock],
AC_TRY_LINK([#include <winsock.h>],[
socket(0,0,0);
select(0,NULL,NULL,NULL,NULL);
closesocket(0);
gethostname(NULL,0);
],[ol_cv_winsock=yes],[ol_cv_winsock=no]))
if test $ol_cv_winsock = yes ; then
AC_DEFINE(HAVE_WINSOCK,1,[define if you have winsock])
dnl The following is INTENTIONALLY scripted out because shell does not
dnl support variable names with the '@' character, which is what
dnl autoconf would try to generate if one merely used AC_SEARCH_LIBS
AC_MSG_CHECKING(for winsock)
save_LIBS="$LIBS"
for curlib in ws2_32 wsock32; do
LIBS="$LIBS -l$curlib"
AC_TRY_LINK([
char socket@12();
char select@20();
char closesocket@4();
char gethostname@8();
],
[
socket@12();
select@20();
closesocket@4();
gethostname@8();
],
have_winsock=yes, have_winsock=no)
if test $have_winsock = yes; then
AC_DEFINE(HAVE_WINSOCK, 1, [define if you have winsock])
ac_cv_func_socket=yes
ac_cv_func_select=yes
ac_cv_func_closesocket=yes
ac_cv_func_gethostname=yes
if test $curlib = ws2_32; then
have_winsock=winsock2
AC_DEFINE(HAVE_WINSOCK2, 1,
[define if you have winsock2])
fi
break
fi
fi
LIBS="$save_LIBS"
done
AC_MSG_RESULT($have_winsock)
dnl Find socket()
dnl Likely combinations:
......@@ -852,7 +872,8 @@ AC_CHECK_HEADERS( regex.h )
if test "$ac_cv_header_regex_h" != yes ; then
AC_MSG_ERROR([POSIX regex.h required.])
fi
AC_CHECK_FUNC(regfree, :, AC_MSG_ERROR([POSIX regex required.]))
AC_SEARCH_LIBS(regfree, [regex gnuregex],
:, AC_MSG_ERROR([POSIX regex required.]))
OL_POSIX_REGEX
if test "$ol_cv_c_posix_regex" = no ; then
......@@ -1898,9 +1919,10 @@ fi
dnl ----------------------------------------------------------------
if test $ol_enable_dynamic = yes -a $enable_shared = yes ; then
LINK_BINS_DYNAMIC="yes"
BUILD_LIBS_DYNAMIC=shared
AC_DEFINE(LDAP_LIBS_DYNAMIC, 1, [define if LDAP libs are dynamic])
else
LINK_BINS_DYNAMIC="no"
BUILD_LIBS_DYNAMIC=static
fi
dnl ----------------------------------------------------------------
......@@ -2074,7 +2096,7 @@ fi
dnl ----------------------------------------------------------------
dnl Check for entropy sources
if test $cross_compiling != yes ; then
if test $cross_compiling != yes -a $ac_cv_mingw32 != yes ; then
dev=no
if test -r /dev/urandom ; then
dev="/dev/urandom";
......@@ -2559,28 +2581,22 @@ fi
dnl ----------------------------------------------------------------
if test "$LINK_BINS_DYNAMIC" = yes; then
LIB_LINKAGE=DYN
LT_LIB_LINKAGE=shared
else
LIB_LINKAGE=STAT
LT_LIB_LINKAGE=static
fi
dnl
dnl For Windows build, we don't want to include -dlopen flags.
dnl They hurt more than they help.
dnl
if test "$ac_cv_mingw32" = yes ; then
PLAT=NT
DYN_EXT=dll
SLAPD_MODULES_LDFLAGS=
SLAPD_MODULES_LIST=
else
PLAT=UNIX
DYN_EXT=so
fi
AC_SUBST(LIBSRCS)
AC_SUBST(PLAT)
AC_SUBST(LIB_LINKAGE)
AC_SUBST(LT_LIB_LINKAGE)
AC_SUBST(DYN_EXT)
AC_SUBST(BUILD_LIBS_DYNAMIC)
AC_SUBST(BUILD_SLAPD)
AC_SUBST(BUILD_BDB)
......@@ -2618,7 +2634,6 @@ AC_SUBST(LTHREAD_LIBS)
AC_SUBST(LUTIL_LIBS)
AC_SUBST(WRAP_LIBS)
AC_SUBST(MOD_TCL_LIB)
AC_SUBST(LINK_BINS_DYNAMIC)
AC_SUBST(SLAPD_MODULES_CPPFLAGS)
AC_SUBST(SLAPD_MODULES_LDFLAGS)
......
......@@ -31,16 +31,46 @@ ldap_config.h: $(LDAP_CONFIG) Makefile
@$(RM) $@
@echo "Making $@"
@echo "/* Generated from $(LDAP_CONFIG) on `date` */" > $@; \
if test $(PLAT) = NT; then \
sysconfdir=`cygpath -w $(sysconfdir) | \
$(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
datadir=`cygpath -w $(datadir) | \
$(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
bindir=`cygpath -w $(bindir) | \
$(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
sbindir=`cygpath -w $(sbindir) | \
$(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
libexecdir=`cygpath -w $(libexecdir) | \
$(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
localstatedir=`cygpath -w $(localstatedir) | \
$(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
editor=`cygpath -w $(EDITOR) | \
$(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
finger=`cygpath -w $(FINGER) | \
$(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
sendmail=`cygpath -w $(SENDMAIL) | \
$(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
else \
sysconfdir=$(sysconfdir); \
datadir=$(datadir); \
bindir=$(bindir); \
sbindir=$(sbindir); \
libexecdir=$(libexecdir); \
localstatedir=$(localstatedir); \
editor=$(EDITOR); \
finger=$(FINGER); \
sendmail=$(SENDMAIL); \
fi; \
$(SED) \
-e 's;%SYSCONFDIR%;$(sysconfdir);' \
-e 's;%DATADIR%;$(datadir);' \
-e 's;%BINDIR%;$(bindir);' \
-e 's;%SBINDIR%;$(sbindir);' \
-e 's;%LIBEXECDIR%;$(libexecdir);' \
-e 's;%RUNDIR%;$(localstatedir);' \
-e 's;%EDITOR%;$(EDITOR);' \
-e 's;%FINGER%;$(FINGER);' \
-e 's;%SENDMAIL%;$(SENDMAIL);' \
-e "s;%SYSCONFDIR%;$$sysconfdir;" \
-e "s;%DATADIR%;$$datadir;" \
-e "s;%BINDIR%;$$bindir;" \
-e "s;%SBINDIR%;$$sbindir;" \
-e "s;%LIBEXECDIR%;$$libexecdir;" \
-e "s;%RUNDIR%;$$localstatedir;" \
-e "s;%EDITOR%;$$editor;" \
-e "s;%FINGER%;$$finger;" \
-e "s;%SENDMAIL%;$$sendmail;" \
$(LDAP_CONFIG) >> $@; \
$(CHMOD) 444 $@
......@@ -49,3 +79,4 @@ install-common: all-common install-local
clean-common: clean-local
veryclean-common: veryclean-local
depend-common: depend-local
......@@ -51,8 +51,9 @@ LDAP_F(char *) ldap_pvt_strtok LDAP_P(( char *str,
/* strdup() is missing, declare our own version */
# undef strdup
# define strdup(s) ber_strdup(s)
#else
#elif !defined(_WIN32)
/* some systems fail to declare strdup */
/* Windows does not require this declaration */
LDAP_LIBC_F(char *) (strdup)();
#endif
......
......@@ -498,12 +498,12 @@ ber_sockbuf_ctrl LDAP_P((
int opt,
void *arg ));
LBER_F( Sockbuf_IO ) ber_sockbuf_io_tcp;
LBER_F( Sockbuf_IO ) ber_sockbuf_io_readahead;
LBER_F( Sockbuf_IO ) ber_sockbuf_io_fd;
LBER_F( Sockbuf_IO ) ber_sockbuf_io_debug;
LBER_V( Sockbuf_IO ) ber_sockbuf_io_tcp;
LBER_V( Sockbuf_IO ) ber_sockbuf_io_readahead;
LBER_V( Sockbuf_IO ) ber_sockbuf_io_fd;
LBER_V( Sockbuf_IO ) ber_sockbuf_io_debug;
#ifdef LDAP_CONNECTIONLESS
LBER_F( Sockbuf_IO ) ber_sockbuf_io_udp;
LBER_V( Sockbuf_IO ) ber_sockbuf_io_udp;
#endif
/*
......
......@@ -31,7 +31,7 @@ typedef struct sockbuf_buf {
/*
* bprint.c
*/
LBER_F( BER_LOG_PRINT_FN ) ber_pvt_log_print;
LBER_V( BER_LOG_PRINT_FN ) ber_pvt_log_print;
LBER_F( int )
ber_pvt_log_printf LDAP_P((
......
......@@ -55,93 +55,182 @@
# define LDAP_GCCATTR(attrs)
#endif
/* Support for NT dynamic libraries. */
/*
* Support for Windows DLLs.
*
* When external source code includes header files for dynamic libraries,
* the external source code is "importing" DLL symbols into its resulting
* object code. On Windows, symbols imported from DLLs must be explicitly
* indicated in header files with the __declspec(dllimport) directive.
* This is not totally necessary for functions because the compiler
* (gcc or MSVC) will generate stubs when this directive is absent.
* However, this is required for imported variables.
*
* The LDAP libraries, i.e. liblber and libldap, can be built as
* static or shared, based on configuration. Just about all other source
* code in OpenLDAP use these libraries. If the LDAP libraries
* are configured as shared, 'configure' defines the LDAP_LIBS_DYNAMIC
* macro. When other source files include LDAP library headers, the
* LDAP library symbols will automatically be marked as imported. When
* the actual LDAP libraries are being built, the symbols will not
* be marked as imported because the LBER_LIBRARY or LDAP_LIBRARY macros
* will be respectively defined.
*
* Any project outside of OpenLDAP with source code wanting to use
* LDAP dynamic libraries should explicitly define LDAP_LIBS_DYNAMIC.
* This will ensure that external source code appropriately marks symbols
* that will be imported.
*
* The slapd executable, itself, can be used as a dynamic library.
* For example, if a backend module is compiled as shared, it will
* import symbols from slapd. When this happens, the slapd symbols
* must be marked as imported in header files that the backend module
* includes. Remember that slapd links with various static libraries.
* If the LDAP libraries were configured as static, their object
* code is also part of the monolithic slapd executable. Thus, when
* a backend module imports symbols from slapd, it imports symbols from
* all of the static libraries in slapd as well. Thus, the SLAP_IMPORT
* macro, when defined, will appropriately mark symbols as imported.
* This macro should be used by shared backend modules as well as any
* other external source code that imports symbols from the slapd
* executable as if it were a DLL.
*
* Note that we don't actually have to worry about using the
* __declspec(dllexport) directive anywhere. This is because both
* MSVC and Mingw provide alternate (more effective) methods for exporting
* symbols out of binaries, i.e. the use of a DEF file.
*
* NOTE ABOUT BACKENDS: Backends can be configured as static or dynamic.
* When a backend is configured as dynamic, slapd will load the backend
* explicitly and populate function pointer structures by calling
* the backend's well-known initialization function. Because of this
* procedure, slapd never implicitly imports symbols from dynamic backends.
* This makes it unnecessary to tag various backend functions with the
* __declspec(dllimport) directive. This is because neither slapd nor
* any other external binary should ever be implicitly loading a backend
* dynamic module.
*
* Backends are supposed to be self-contained. However, it appears that
* back-meta DOES implicitly import symbols from back-ldap. This means
* that the __declspec(dllimport) directive should be marked on back-ldap
* functions (in its header files) if and only if we're compiling for
* windows AND back-ldap has been configured as dynamic AND back-meta
* is the client of back-ldap. When client is slapd, there is no effect
* since slapd does not implicitly import symbols.
*
* TODO(?): Currently, back-meta nor back-ldap is supported for Mingw32.
* Thus, there's no need to worry about this right now. This is something that
* may or may not have to be addressed in the future.
*/
/* LBER library */
#if defined(LBER_DECL) && defined(_WIN32)
# define LBER_F(type) extern __declspec(LBER_DECL) type
# define LBER_V(type) extern __declspec(LBER_DECL) type
#if defined(_WIN32) && \
((defined(LDAP_LIBS_DYNAMIC) && !defined(LBER_LIBRARY)) || \
(!defined(LDAP_LIBS_DYNAMIC) && defined(SLAPD_IMPORT)))
# define LBER_F(type) extern __declspec(dllimport) type
# define LBER_V(type) extern __declspec(dllimport) type
#else
# define LBER_F(type) extern type
# define LBER_V(type) extern type
#endif
/* LDAP library */
#if defined(LDAP_DECL) && defined(_WIN32)
# define LDAP_F(type) extern __declspec(LDAP_DECL) type
# define LDAP_V(type) extern __declspec(LDAP_DECL) type
#if defined(_WIN32) && \
((defined(LDAP_LIBS_DYNAMIC) && !defined(LDAP_LIBRARY)) || \
(!defined(LDAP_LIBS_DYNAMIC) && defined(SLAPD_IMPORT)))
# define LDAP_F(type) extern __declspec(dllimport) type
# define LDAP_V(type) extern __declspec(dllimport) type
#else
# define LDAP_F(type) extern type
# define LDAP_V(type) extern type
#endif
/*
* C library. Mingw32 links with the C run-time library by default,
* so the explicit definition of CSTATIC will keep dllimport from
* being defined.
*/
#if (defined(__MINGW32__) && !defined(CSTATIC) || \
defined(_WIN32) && defined(_DLL))
# define LDAP_LIBC_F(type) extern __declspec(dllimport) type
# define LDAP_LIBC_V(type) extern __declspec(dllimport) type
#else
# define LDAP_LIBC_F(type) extern type
# define LDAP_LIBC_V(type) extern type
#endif
/* AVL library */
#if defined(LDAP_AVL_DECL) && defined(_WIN32)
# define LDAP_AVL_F(type) extern __declspec(LDAP_AVL_DECL) type
# define LDAP_AVL_V(type) extern __declspec(LDAP_AVL_DECL) type
#if defined(_WIN32) && defined(SLAPD_IMPORT)
# define LDAP_AVL_F(type) extern __declspec(dllimport) type
# define LDAP_AVL_V(type) extern __declspec(dllimport) type
#else
# define LDAP_AVL_F(type) extern type
# define LDAP_AVL_V(type) extern type