From: Howard Chu Date: Fri, 7 Dec 2001 04:03:25 +0000 (+0000) Subject: NT updates from jon@symas.com. X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~728 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0552b1c53fa44790811f44cac5e14fc52fbd2ace;p=openldap NT updates from jon@symas.com. --- diff --git a/build/lib-shared.mk b/build/lib-shared.mk index 20f4aa4b89..e1a07bf96c 100644 --- a/build/lib-shared.mk +++ b/build/lib-shared.mk @@ -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 diff --git a/build/lib.mk b/build/lib.mk index b647665842..a1cf72b3e7 100644 --- a/build/lib.mk +++ b/build/lib.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 + diff --git a/build/mod.mk b/build/mod.mk index eac8f6ecf0..2e3510d0a5 100644 --- a/build/mod.mk +++ b/build/mod.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 diff --git a/build/openldap.m4 b/build/openldap.m4 index 044fba6d36..dd7f7b7de1 100644 --- a/build/openldap.m4 +++ b/build/openldap.m4 @@ -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 ==================================================================== diff --git a/build/top.mk b/build/top.mk index c57068ea20..fbe6d41324 100644 --- a/build/top.mk +++ b/build/top.mk @@ -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) diff --git a/clients/Makefile.in b/clients/Makefile.in index 5387ff97e6..218050234f 100644 --- a/clients/Makefile.in +++ b/clients/Makefile.in @@ -4,4 +4,6 @@ ## ## Clients Makefile.in for OpenLDAP -SUBDIRS= tools ud +SUBDIRS = tools ud +CLEANDIRS = finger mail500 maildap + diff --git a/clients/tools/Makefile.in b/clients/tools/Makefile.in index d86b751312..944860c993 100644 --- a/clients/tools/Makefile.in +++ b/clients/tools/Makefile.in @@ -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) diff --git a/clients/ud/Makefile.in b/clients/ud/Makefile.in index 8632500903..fcf82469de 100644 --- a/clients/ud/Makefile.in +++ b/clients/ud/Makefile.in @@ -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) diff --git a/configure.in b/configure.in index 151b4f87d3..64b6f291d8 100644 --- a/configure.in +++ b/configure.in @@ -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 ],[ - 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) diff --git a/include/Makefile.in b/include/Makefile.in index 410163ff9c..f93ba38f44 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -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 + diff --git a/include/ac/string.h b/include/ac/string.h index 5d7cf3d7a1..24fd966557 100644 --- a/include/ac/string.h +++ b/include/ac/string.h @@ -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 diff --git a/include/lber.h b/include/lber.h index 129dfc0dd3..17088c8e8d 100644 --- a/include/lber.h +++ b/include/lber.h @@ -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 /* diff --git a/include/lber_pvt.h b/include/lber_pvt.h index 6698475e72..b2f808d4a0 100644 --- a/include/lber_pvt.h +++ b/include/lber_pvt.h @@ -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(( diff --git a/include/ldap_cdefs.h b/include/ldap_cdefs.h index 12e6064922..e6cc1c6757 100644 --- a/include/ldap_cdefs.h +++ b/include/ldap_cdefs.h @@ -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 +# define LDAP_AVL_F(type) extern type +# define LDAP_AVL_V(type) extern type #endif /* LDBM library */ -#if defined(LDAP_LDBM_DECL) && defined(_WIN32) -# define LDAP_LDBM_F(type) extern __declspec(LDAP_LDBM_DECL) type -# define LDAP_LDBM_V(type) extern __declspec(LDAP_LDBM_DECL) type +#if defined(_WIN32) && defined(SLAPD_IMPORT) +# define LDAP_LDBM_F(type) extern __declspec(dllimport) type +# define LDAP_LDBM_V(type) extern __declspec(dllimport) type #else # define LDAP_LDBM_F(type) extern type # define LDAP_LDBM_V(type) extern type #endif /* LDIF library */ -#if defined(LDAP_LDIF_DECL) && defined(_WIN32) -# define LDAP_LDIF_F(type) extern __declspec(LDAP_LDIF_DECL) type -# define LDAP_LDIF_V(type) extern __declspec(LDAP_LDIF_DECL) type +#if defined(_WIN32) && defined(SLAPD_IMPORT) +# define LDAP_LDIF_F(type) extern __declspec(dllimport) type +# define LDAP_LDIF_V(type) extern __declspec(dllimport) type #else # define LDAP_LDIF_F(type) extern type # define LDAP_LDIF_V(type) extern type #endif /* LUNICODE library */ -#if defined(LDAP_LUNICODE_DECL) && defined(_WIN32) -# define LDAP_LUNICODE_F(type) extern __declspec(LDAP_LUNICODE_DECL) type -# define LDAP_LUNICODE_V(type) extern __declspec(LDAP_LUNICODE_DECL) type +#if defined(_WIN32) && defined(SLAPD_IMPORT) +# define LDAP_LUNICODE_F(type) extern __declspec(dllimport) type +# define LDAP_LUNICODE_V(type) extern __declspec(dllimport) type #else # define LDAP_LUNICODE_F(type) extern type # define LDAP_LUNICODE_V(type) extern type #endif /* LUTIL library */ -#if defined(LDAP_LUTIL_DECL) && defined(_WIN32) -# define LDAP_LUTIL_F(type) extern __declspec(LDAP_LUTIL_DECL) type -# define LDAP_LUTIL_V(type) extern __declspec(LDAP_LUTIL_DECL) type +#if defined(_WIN32) && defined(SLAPD_IMPORT) +# define LDAP_LUTIL_F(type) extern __declspec(dllimport) type +# define LDAP_LUTIL_V(type) extern __declspec(dllimport) type #else # define LDAP_LUTIL_F(type) extern type # define LDAP_LUTIL_V(type) extern type #endif -/* SLAPD (as a module exporting symbols) */ -#if defined(LDAP_SLAPD_DECL) && defined(_WIN32) -# define LDAP_SLAPD_F(type) extern __declspec(LDAP_SLAPD_DECL) type -# define LDAP_SLAPD_V(type) extern __declspec(LDAP_SLAPD_DECL) type +/* REWRITE library */ +#if defined(_WIN32) && defined(SLAPD_IMPORT) +# define LDAP_REWRITE_F(type) extern __declspec(dllimport) type +# define LDAP_REWRITE_V(type) extern __declspec(dllimport) type +#else +# define LDAP_REWRITE_F(type) extern type +# define LDAP_REWRITE_V(type) extern type +#endif + +/* SLAPD (as a dynamic library exporting symbols) */ +#if defined(_WIN32) && defined(SLAPD_IMPORT) +# define LDAP_SLAPD_F(type) extern __declspec(dllimport) type +# define LDAP_SLAPD_V(type) extern __declspec(dllimport) type #else # define LDAP_SLAPD_F(type) extern type # define LDAP_SLAPD_V(type) extern type #endif +/* + * C library. Mingw32 links with the dynamic C run-time library by default, + * so the explicit definition of CSTATIC will keep dllimport from + * being defined, if desired. + * + * MSVC defines the _DLL macro when the compiler is invoked with /MD or /MDd, + * which means the resulting object code will be linked with the dynamic + * C run-time library. + * + * Technically, it shouldn't be necessary to redefine any functions that + * the headers for the C library should already contain. Nevertheless, this + * is here as a safe-guard. + * + * TODO: Determine if these macros ever get expanded for Windows. If not, + * the declspec expansion can probably be removed. + */ +#if (defined(__MINGW32__) && !defined(CSTATIC)) || \ + (defined(_MSC_VER) && 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 + #endif /* _LDAP_CDEFS_H */ diff --git a/include/lutil.h b/include/lutil.h index 534cfe660a..5adc4b998e 100644 --- a/include/lutil.h +++ b/include/lutil.h @@ -74,7 +74,7 @@ lutil_authpasswd_hash LDAP_P(( #if defined( SLAPD_SPASSWD ) && defined( HAVE_CYRUS_SASL ) /* cheat to avoid pulling in */ -LDAP_LUTIL_F( struct sasl_conn * ) lutil_passwd_sasl_conn; +LDAP_LUTIL_V( struct sasl_conn * ) lutil_passwd_sasl_conn; #endif LDAP_LUTIL_F( int ) @@ -110,6 +110,27 @@ lutil_progname LDAP_P(( LDAP_LUTIL_F( int ) lutil_pair( ber_socket_t sd[2] ); +/* + * Sometimes not all declarations in a header file are needed. + * An indicator to this is whether or not the symbol's type has + * been defined. Thus, we don't need to include a symbol if + * its type has not been defined through another header file. + */ + +#ifdef HAVE_NT_SERVICE_MANAGER +LDAP_LUTIL_V (int) is_NT_Service; + +#ifdef _LDAP_PVT_THREAD_H +LDAP_LUTIL_V (ldap_pvt_thread_cond_t) started_event; +#endif /* _LDAP_PVT_THREAD_H */ + +#ifdef _WINSVC_H +LDAP_LUTIL_V (SERVICE_STATUS) SLAPDServiceStatus; +LDAP_LUTIL_V (SERVICE_STATUS_HANDLE) hSLAPDServiceStatus; +#endif /* _WINSVC_H */ + +#endif /* HAVE_NT_SERVICE_MANAGER */ + LDAP_END_DECL #endif /* _LUTIL_H */ diff --git a/include/rewrite.h b/include/rewrite.h index 9c61ba942d..1c74f073e4 100644 --- a/include/rewrite.h +++ b/include/rewrite.h @@ -86,7 +86,7 @@ struct berval; /* avoid include */ /* * Inits the info */ -extern struct rewrite_info * +LDAP_REWRITE_F (struct rewrite_info *) rewrite_info_init( int mode ); @@ -94,7 +94,7 @@ rewrite_info_init( /* * Cleans up the info structure */ -extern int +LDAP_REWRITE_F (int) rewrite_info_delete( struct rewrite_info *info ); @@ -111,7 +111,7 @@ rewrite_info_delete( * rewriteMap mapType mapName [mapArgs] * rewriteParam paramName paramValue */ -extern int +LDAP_REWRITE_F (int) rewrite_parse( struct rewrite_info *info, const char *fname, @@ -135,7 +135,7 @@ rewrite_parse( * - ok with copy of string as result, * - use the default rewrite context. */ -extern int +LDAP_REWRITE_F (int) rewrite( struct rewrite_info *info, const char *rewriteContext, @@ -146,7 +146,7 @@ rewrite( /* * Same as above; the cookie relates the rewrite to a session */ -extern int +LDAP_REWRITE_F (int) rewrite_session( struct rewrite_info *info, const char *rewriteContext, @@ -158,7 +158,7 @@ rewrite_session( /* * Inits a session */ -extern struct rewrite_session * +LDAP_REWRITE_F (struct rewrite_session *) rewrite_session_init( struct rewrite_info *info, const void *cookie @@ -167,7 +167,7 @@ rewrite_session_init( /* * Defines and inits a variable with session scope */ -extern int +LDAP_REWRITE_F (int) rewrite_session_var_set( struct rewrite_info *info, const void *cookie, @@ -178,7 +178,7 @@ rewrite_session_var_set( /* * Deletes a session */ -extern int +LDAP_REWRITE_F (int) rewrite_session_delete( struct rewrite_info *info, const void *cookie @@ -192,7 +192,7 @@ rewrite_session_delete( /* * Defines and inits a variable with global scope */ -extern int +LDAP_REWRITE_F (int) rewrite_param_set( struct rewrite_info *info, const char *name, @@ -202,7 +202,7 @@ rewrite_param_set( /* * Gets a var with global scope */ -extern int +LDAP_REWRITE_F (int) rewrite_param_get( struct rewrite_info *info, const char *name, @@ -212,7 +212,7 @@ rewrite_param_get( /* * Destroys the parameter tree */ -extern int +LDAP_REWRITE_F (int) rewrite_param_destroy( struct rewrite_info *info ); diff --git a/libraries/libavl/avl.c b/libraries/libavl/avl.c index 827e7d3404..bd0ede4d66 100644 --- a/libraries/libavl/avl.c +++ b/libraries/libavl/avl.c @@ -24,6 +24,8 @@ #ifdef CSRIMALLOC #define ber_memalloc malloc #define ber_memrealloc realloc +#else +#include "lber.h" #endif #define AVL_INTERNAL diff --git a/libraries/liblber/Makefile.in b/libraries/liblber/Makefile.in index 4180432c88..068a7aa024 100644 --- a/libraries/liblber/Makefile.in +++ b/libraries/liblber/Makefile.in @@ -11,6 +11,8 @@ XLIBRARY = ../liblber.a NT_SRCS = nt_err.c NT_OBJS = nt_err.lo +LIB_DEFS = -DLBER_LIBRARY + SRCS= assert.c decode.c encode.c io.c bprint.c \ memory.c options.c sockbuf.c $(@PLAT@_SRCS) OBJS= assert.lo decode.lo encode.lo io.lo bprint.lo \ @@ -24,17 +26,7 @@ LDAP_LIBDIR= ../../libraries XLIBS = -llber XXLIBS = - -LINKAGE = @LT_LIB_LINKAGE@ - -NT_DYN_TEST_DEFS = -DLBER_DECL=dllimport - -# Extras for building the library -EXTRA_DEFS = $(@PLAT@_@LIB_LINKAGE@_LIB_DEFS) -EXTRA_LIBS = - -# Only the test programs will pick up these defs. -CPPFLAGS = $(@PLAT@_@LIB_LINKAGE@_TEST_DEFS) +NT_LINK_LIBS = $(AC_LIBS) dtest: $(LIBRARY) dtest.o $(LTLINK) -o $@ dtest.o $(LIBS) diff --git a/libraries/liblber/lber-int.h b/libraries/liblber/lber-int.h index b477d26491..73f3238e4f 100644 --- a/libraries/liblber/lber-int.h +++ b/libraries/liblber/lber-int.h @@ -24,7 +24,7 @@ LDAP_BEGIN_DECL -LBER_F (BER_ERRNO_FN) ber_int_errno_fn; +LBER_V (BER_ERRNO_FN) ber_int_errno_fn; struct lber_options { short lbo_valid; @@ -51,7 +51,7 @@ struct lber_options { #define LBER_VALID_BERELEMENT 0x2 #define LBER_VALID_SOCKBUF 0x3 -LBER_F (struct lber_options) ber_int_options; +LBER_V (struct lber_options) ber_int_options; #define ber_int_debug ber_int_options.lbo_debug struct berelement { @@ -105,7 +105,8 @@ struct seqorset { /* * io.c */ -int ber_realloc LDAP_P(( +LBER_F( int ) +ber_realloc LDAP_P(( BerElement *ber, ber_len_t len )); @@ -146,7 +147,7 @@ ber_log_sos_dump LDAP_P(( /* memory.c */ /* simple macros to realloc for now */ -LBER_F (BerMemoryFunctions *) ber_int_memory_fns; +LBER_V (BerMemoryFunctions *) ber_int_memory_fns; LBER_F (char *) ber_strndup( LDAP_CONST char *, ber_len_t ); LBER_F (char *) ber_strndup__( LDAP_CONST char *, size_t ); diff --git a/libraries/libldap/Makefile.in b/libraries/libldap/Makefile.in index 090243a99d..484b8f6591 100644 --- a/libraries/libldap/Makefile.in +++ b/libraries/libldap/Makefile.in @@ -33,26 +33,11 @@ OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \ LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries -XLIBS = -lldap -llber -llutil -XXLIBS = $(SECURITY_LIBS) $(TLS_LIBS) - -LINKAGE = @LT_LIB_LINKAGE@ - -NT_DYN_LIB_LIBS = -llber -llutil $(AC_LIBS) -NT_DYN_LIB_DEFS = -DLBER_DECL=dllimport -NT_DYN_TEST_DEFS = -DLBER_DECL=dllimport -DLDAP_DECL=dllimport - -NT_XXLIBS = $(SECURITY_LIBS) +LIB_DEFS = -DLDAP_LIBRARY -UNIX_DYN_LIB_LIBS = -llber $(AC_LIBS) -UNIX_XXLIBS = $(SECURITY_LIBS) - -# Extras for building the library -EXTRA_DEFS = $(@PLAT@_@LIB_LINKAGE@_LIB_DEFS) -EXTRA_LIBS = $(@PLAT@_@LIB_LINKAGE@_LIB_LIBS) $(@PLAT@_XXLIBS) - -# Only the test programs will pick up these defs. -CPPFLAGS = $(@PLAT@_@LIB_LINKAGE@_TEST_DEFS) +XLIBS = -lldap -llber -llutil +XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS) +NT_LINK_LIBS = -llber $(AC_LIBS) $(SECURITY_LIBS) apitest: $(LIBRARY) apitest.o $(LDAP_LIBLBER_DEPEND) $(LTLINK) -o $@ apitest.o $(LIBS) diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index 33ba74d2cb..693686a280 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -345,7 +345,7 @@ LDAP_F ( void ) ldap_int_initialize_global_options LDAP_P(( /* * in error.c */ -void ldap_int_error_init( void ); +LDAP_F (void) ldap_int_error_init( void ); /* * in unit-int.c @@ -416,7 +416,7 @@ LDAP_F (int) ldap_int_open_connection( LDAP *ld, /* * in os-ip.c */ -LDAP_F (int) ldap_int_tblsize; +LDAP_V (int) ldap_int_tblsize; LDAP_F (int) ldap_int_timeval_dup( struct timeval **dest, const struct timeval *tm ); LDAP_F (int) ldap_connect_to_host( LDAP *ld, Sockbuf *sb, int proto, const char *host, unsigned long address, int port, diff --git a/libraries/libldap/url.c b/libraries/libldap/url.c index 851f2494c5..8db923b2a5 100644 --- a/libraries/libldap/url.c +++ b/libraries/libldap/url.c @@ -69,7 +69,8 @@ int ldap_pvt_url_scheme2proto( const char *scheme ) return -1; } -LDAP_F(int) ldap_pvt_url_scheme2tls( const char *scheme ) +int +ldap_pvt_url_scheme2tls( const char *scheme ) { assert( scheme ); diff --git a/libraries/libldap_r/Makefile.in b/libraries/libldap_r/Makefile.in index 42b58fd432..92f2303ec6 100644 --- a/libraries/libldap_r/Makefile.in +++ b/libraries/libldap_r/Makefile.in @@ -40,28 +40,13 @@ OBJS = threads.lo rdwr.lo tpool.lo \ LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries +LIB_DEFS = -DLDAP_LIBRARY + XDEFS = -DLDAP_R_COMPILE -I$(XXDIR) XLIBS = -lldap_r -llber -llutil XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS) XXXLIBS = $(LTHREAD_LIBS) - -LINKAGE = @LT_LIB_LINKAGE@ - -NT_DYN_LIB_LIBS = -llber -llutil $(AC_LIBS) -NT_DYN_LIB_DEFS = -DLBER_DECL=dllimport -NT_DYN_TEST_DEFS = -DLBER_DECL=dllimport -DLDAP_DECL=dllimport - -NT_XXLIBS = $(SECURITY_LIBS) - -UNIX_DYN_LIB_LIBS = -llber $(AC_LIBS) -UNIX_XXLIBS = $(SECURITY_LIBS) - -# Extras for building the library -EXTRA_DEFS = $(@PLAT@_@LIB_LINKAGE@_LIB_DEFS) -EXTRA_LIBS = $(@PLAT@_@LIB_LINKAGE@_LIB_LIBS) $(@PLAT@_XXLIBS) - -# Only the test programs will pick up these defs. -CPPFLAGS = $(@PLAT@_@LIB_LINKAGE@_TEST_DEFS) +NT_LINK_LIBS = -llber $(AC_LIBS) $(SECURITY_LIBS) .links : @for i in $(XXSRCS); do \ @@ -87,3 +72,4 @@ ttest: $(LIBRARY) tmpltest.o $(LDAP_LIBLBER_DEPEND) install-local: $(CFFILES) FORCE -$(MKDIR) $(DESTDIR)$(libdir) $(LTINSTALL) $(INSTALLFLAGS) -m 644 $(LIBRARY) $(DESTDIR)$(libdir) + diff --git a/libraries/libldap_r/thr_nt.c b/libraries/libldap_r/thr_nt.c index 7cecdc259b..a04718806f 100644 --- a/libraries/libldap_r/thr_nt.c +++ b/libraries/libldap_r/thr_nt.c @@ -17,6 +17,9 @@ #include "ldap_pvt_thread.h" +/* mingw compiler very sensitive about getting prototypes right */ +typedef unsigned __stdcall thrfunc_t(void *); + int ldap_int_thread_initialize( void ) { @@ -35,16 +38,15 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread, void *(*start_routine)( void *), void *arg) { - unsigned long tid; + unsigned tid; HANDLE thd; - thd = _beginthreadex( NULL, 0, - (LPTHREAD_START_ROUTINE) start_routine, arg, - 0, &tid ); + thd = (HANDLE) _beginthreadex(NULL, 0, (thrfunc_t *) start_routine, + arg, 0, &tid); *thread = (ldap_pvt_thread_t) thd; - return thd == NULL ? -1 : 0; + return thd == NULL ? -1 : 0; } void diff --git a/libraries/libldbm/Makefile.in b/libraries/libldbm/Makefile.in index df24629c01..95008f31f2 100644 --- a/libraries/libldbm/Makefile.in +++ b/libraries/libldbm/Makefile.in @@ -12,9 +12,6 @@ OBJS = ldbm.o LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries -NT_DYN_LIB_DEFS = -DLDAP_DECL=dllimport -CPPFLAGS = $(@PLAT@_@LIB_LINKAGE@_LIB_DEFS) - XLIBS = -lldbm -lavl XXLIBS = $(LDBM_LIBS) diff --git a/libraries/libldif/Makefile.in b/libraries/libldif/Makefile.in index 8decced43f..c6858f00ff 100644 --- a/libraries/libldif/Makefile.in +++ b/libraries/libldif/Makefile.in @@ -12,6 +12,3 @@ OBJS = line64.o fetch.o LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries -NT_DYN_LIB_DEFS = -DLDAP_DECL=dllimport -DLBER_DECL=dllimport -CPPFLAGS = $(@PLAT@_@LIB_LINKAGE@_LIB_DEFS) - diff --git a/libraries/liblunicode/ucdata/ucdata.h b/libraries/liblunicode/ucdata/ucdata.h index 931b3ccc9b..5d05306c2f 100644 --- a/libraries/liblunicode/ucdata/ucdata.h +++ b/libraries/liblunicode/ucdata/ucdata.h @@ -113,8 +113,9 @@ LDAP_BEGIN_DECL * of properties. The macros that test for various character properties all * call this function with some set of masks. */ -extern int ucisprop LDAP_P((unsigned long code, unsigned long mask1, - unsigned long mask2)); +LDAP_LUNICODE_F (int) +ucisprop LDAP_P((unsigned long code, unsigned long mask1, + unsigned long mask2)); #define ucisalpha(cc) ucisprop(cc, UC_LU|UC_LL|UC_LM|UC_LO|UC_LT, 0) #define ucisdigit(cc) ucisprop(cc, UC_ND, 0) @@ -203,9 +204,9 @@ extern int ucisprop LDAP_P((unsigned long code, unsigned long mask1, * **************************************************************************/ -extern unsigned long uctoupper LDAP_P((unsigned long code)); -extern unsigned long uctolower LDAP_P((unsigned long code)); -extern unsigned long uctotitle LDAP_P((unsigned long code)); +LDAP_LUNICODE_F (unsigned long) uctoupper LDAP_P((unsigned long code)); +LDAP_LUNICODE_F (unsigned long) uctolower LDAP_P((unsigned long code)); +LDAP_LUNICODE_F (unsigned long) uctotitle LDAP_P((unsigned long code)); /************************************************************************** * @@ -218,20 +219,20 @@ extern unsigned long uctotitle LDAP_P((unsigned long code)); * If it returns 0, there is no composition. Any other value indicates a * composition was returned in comp. */ -extern int uccomp LDAP_P((unsigned long node1, unsigned long node2, +LDAP_LUNICODE_F (int) uccomp LDAP_P((unsigned long node1, unsigned long node2, unsigned long *comp)); /* * Does Hangul composition on the string str with length len, and returns * the length of the composed string. */ -extern int uccomp_hangul LDAP_P((unsigned long *str, int len)); +LDAP_LUNICODE_F (int) uccomp_hangul LDAP_P((unsigned long *str, int len)); /* * Does canonical composition on the string str with length len, and returns * the length of the composed string. */ -extern int uccanoncomp LDAP_P((unsigned long *str, int len)); +LDAP_LUNICODE_F (int) uccanoncomp LDAP_P((unsigned long *str, int len)); /************************************************************************** * @@ -244,15 +245,17 @@ extern int uccanoncomp LDAP_P((unsigned long *str, int len)); * there is no decomposition. Any other value indicates a decomposition was * returned. */ -extern int ucdecomp LDAP_P((unsigned long code, unsigned long *num, - unsigned long **decomp)); +LDAP_LUNICODE_F (int) +ucdecomp LDAP_P((unsigned long code, unsigned long *num, + unsigned long **decomp)); /* * If the code is a Hangul syllable, this routine decomposes it into the array * passed. The array size should be at least 3. */ -extern int ucdecomp_hangul LDAP_P((unsigned long code, unsigned long *num, - unsigned long decomp[])); +LDAP_LUNICODE_F (int) +ucdecomp_hangul LDAP_P((unsigned long code, unsigned long *num, + unsigned long decomp[])); /* * This routine does canonical decomposition of the string in of length @@ -260,8 +263,9 @@ extern int ucdecomp_hangul LDAP_P((unsigned long code, unsigned long *num, * The memory for out is allocated by this routine. It returns the length * of the decomposed string if okay, and -1 on error. */ -extern int uccanondecomp LDAP_P((const unsigned long *in, int inlen, - unsigned long **out, int *outlen)); +LDAP_LUNICODE_F (int) +uccanondecomp LDAP_P((const unsigned long *in, int inlen, + unsigned long **out, int *outlen)); /************************************************************************** * @@ -273,7 +277,7 @@ extern int uccanondecomp LDAP_P((const unsigned long *in, int inlen, * This will return the combining class for a character to be used with the * Canonical Ordering algorithm. */ -extern unsigned long uccombining_class LDAP_P((unsigned long code)); +LDAP_LUNICODE_F (unsigned long) uccombining_class LDAP_P((unsigned long code)); /************************************************************************** * @@ -286,14 +290,17 @@ struct ucnumber { int denominator; }; -extern int ucnumber_lookup LDAP_P((unsigned long code, struct ucnumber *num)); -extern int ucdigit_lookup LDAP_P((unsigned long code, int *digit)); +LDAP_LUNICODE_F (int) +ucnumber_lookup LDAP_P((unsigned long code, struct ucnumber *num)); + +LDAP_LUNICODE_F (int) +ucdigit_lookup LDAP_P((unsigned long code, int *digit)); /* * For compatibility with John Cowan's "uctype" package. */ -extern struct ucnumber ucgetnumber LDAP_P((unsigned long code)); -extern int ucgetdigit LDAP_P((unsigned long code)); +LDAP_LUNICODE_F (struct ucnumber) ucgetnumber LDAP_P((unsigned long code)); +LDAP_LUNICODE_F (int) ucgetdigit LDAP_P((unsigned long code)); /************************************************************************** * @@ -318,9 +325,9 @@ extern int ucgetdigit LDAP_P((unsigned long code)); /* * Functions to load, unload, and reload specific data files. */ -extern int ucdata_load LDAP_P((char *paths, int mask)); -extern void ucdata_unload LDAP_P((int mask)); -extern int ucdata_reload LDAP_P((char *paths, int mask)); +LDAP_LUNICODE_F (int) ucdata_load LDAP_P((char *paths, int mask)); +LDAP_LUNICODE_F (void) ucdata_unload LDAP_P((int mask)); +LDAP_LUNICODE_F (int) ucdata_reload LDAP_P((char *paths, int mask)); #ifdef UCDATA_DEPRECATED /* diff --git a/libraries/liblunicode/ucdata/ucpgba.h b/libraries/liblunicode/ucdata/ucpgba.h index a6fdf46637..dfc49bbb81 100644 --- a/libraries/liblunicode/ucdata/ucpgba.h +++ b/libraries/liblunicode/ucdata/ucpgba.h @@ -105,21 +105,23 @@ typedef struct _ucstring_t { * of a string containing no strong direction characters and the default * cursor motion should be provided. */ -extern ucstring_t *ucstring_create LDAP_P((unsigned long *source, - unsigned long start, - unsigned long end, - int default_direction, - int cursor_motion)); +LDAP_LUNICODE_F (ucstring_t *) +ucstring_create LDAP_P((unsigned long *source, + unsigned long start, + unsigned long end, + int default_direction, + int cursor_motion)); /* * This releases the string. */ -extern void ucstring_free LDAP_P((ucstring_t *string)); +LDAP_LUNICODE_F (void) ucstring_free LDAP_P((ucstring_t *string)); /* * This changes the cursor motion flag for the string. */ -extern int ucstring_set_cursor_motion LDAP_P((ucstring_t *string, - int cursor_motion)); +LDAP_LUNICODE_F (int) +ucstring_set_cursor_motion LDAP_P((ucstring_t *string, + int cursor_motion)); /* * This function will move the cursor to the right depending on the @@ -128,7 +130,8 @@ extern int ucstring_set_cursor_motion LDAP_P((ucstring_t *string, * A 0 is returned if no cursor motion is performed, otherwise a * 1 is returned. */ -extern int ucstring_cursor_right LDAP_P((ucstring_t *string, int count)); +LDAP_LUNICODE_F (int) +ucstring_cursor_right LDAP_P((ucstring_t *string, int count)); /* * This function will move the cursor to the left depending on the @@ -137,14 +140,16 @@ extern int ucstring_cursor_right LDAP_P((ucstring_t *string, int count)); * A 0 is returned if no cursor motion is performed, otherwise a * 1 is returned. */ -extern int ucstring_cursor_left LDAP_P((ucstring_t *string, int count)); +LDAP_LUNICODE_F (int) +ucstring_cursor_left LDAP_P((ucstring_t *string, int count)); /* * This routine retrieves the direction of the run containing the cursor * and the actual position in the original text string. */ -extern void ucstring_cursor_info LDAP_P((ucstring_t *string, int *direction, - unsigned long *position)); +LDAP_LUNICODE_F (void) +ucstring_cursor_info LDAP_P((ucstring_t *string, int *direction, + unsigned long *position)); LDAP_END_DECL diff --git a/libraries/liblunicode/ure/ure.h b/libraries/liblunicode/ure/ure.h index f4906b8d90..f6f51ddf3c 100644 --- a/libraries/liblunicode/ure/ure.h +++ b/libraries/liblunicode/ure/ure.h @@ -113,20 +113,22 @@ typedef struct _ure_dfa_t *ure_dfa_t; * *************************************************************************/ -extern ure_buffer_t ure_buffer_create LDAP_P((void)); +LDAP_LUNICODE_F (ure_buffer_t) ure_buffer_create LDAP_P((void)); -extern void ure_buffer_free LDAP_P((ure_buffer_t buf)); +LDAP_LUNICODE_F (void) ure_buffer_free LDAP_P((ure_buffer_t buf)); -extern ure_dfa_t ure_compile LDAP_P((ucs2_t *re, unsigned long relen, - int casefold, ure_buffer_t buf)); +LDAP_LUNICODE_F (ure_dfa_t) +ure_compile LDAP_P((ucs2_t *re, unsigned long relen, + int casefold, ure_buffer_t buf)); -extern void ure_dfa_free LDAP_P((ure_dfa_t dfa)); +LDAP_LUNICODE_F (void) ure_dfa_free LDAP_P((ure_dfa_t dfa)); -extern void ure_write_dfa LDAP_P((ure_dfa_t dfa, FILE *out)); +LDAP_LUNICODE_F (void) ure_write_dfa LDAP_P((ure_dfa_t dfa, FILE *out)); -extern int ure_exec LDAP_P((ure_dfa_t dfa, int flags, - ucs2_t *text, unsigned long textlen, - unsigned long *match_start, unsigned long *match_end)); +LDAP_LUNICODE_F (int) +ure_exec LDAP_P((ure_dfa_t dfa, int flags, ucs2_t *text, + unsigned long textlen, unsigned long *match_start, + unsigned long *match_end)); /************************************************************************* * @@ -135,9 +137,10 @@ extern int ure_exec LDAP_P((ure_dfa_t dfa, int flags, * *************************************************************************/ -extern ucs4_t _ure_tolower LDAP_P((ucs4_t c)); +LDAP_LUNICODE_F (ucs4_t) _ure_tolower LDAP_P((ucs4_t c)); -extern int _ure_matches_properties LDAP_P((unsigned long props, ucs4_t c)); +LDAP_LUNICODE_F (int) +_ure_matches_properties LDAP_P((unsigned long props, ucs4_t c)); LDAP_END_DECL diff --git a/libraries/liblunicode/utbm/utbm.h b/libraries/liblunicode/utbm/utbm.h index 4f85eeb5fa..3b78671d02 100644 --- a/libraries/liblunicode/utbm/utbm.h +++ b/libraries/liblunicode/utbm/utbm.h @@ -64,16 +64,18 @@ typedef struct _utbm_pattern_t *utbm_pattern_t; * *************************************************************************/ -extern utbm_pattern_t utbm_create_pattern LDAP_P((void)); +LDAP_LUNICODE_F (utbm_pattern_t) utbm_create_pattern LDAP_P((void)); -extern void utbm_free_pattern LDAP_P((utbm_pattern_t pattern)); +LDAP_LUNICODE_F (void) utbm_free_pattern LDAP_P((utbm_pattern_t pattern)); -extern void utbm_compile LDAP_P((ucs2_t *pat, unsigned long patlen, - unsigned long flags, utbm_pattern_t pattern)); +LDAP_LUNICODE_F (void) +utbm_compile LDAP_P((ucs2_t *pat, unsigned long patlen, + unsigned long flags, utbm_pattern_t pattern)); -extern int utbm_exec LDAP_P((utbm_pattern_t pat, ucs2_t *text, - unsigned long textlen, unsigned long *match_start, - unsigned long *match_end)); +LDAP_LUNICODE_F (int) +utbm_exec LDAP_P((utbm_pattern_t pat, ucs2_t *text, + unsigned long textlen, unsigned long *match_start, + unsigned long *match_end)); /************************************************************************* * @@ -81,17 +83,17 @@ extern int utbm_exec LDAP_P((utbm_pattern_t pat, ucs2_t *text, * *************************************************************************/ -extern int _utbm_isspace LDAP_P((ucs4_t c, int compress)); +LDAP_LUNICODE_F (int) _utbm_isspace LDAP_P((ucs4_t c, int compress)); -extern int _utbm_iscntrl LDAP_P((ucs4_t c)); +LDAP_LUNICODE_F (int) _utbm_iscntrl LDAP_P((ucs4_t c)); -extern int _utbm_nonspacing LDAP_P((ucs4_t c)); +LDAP_LUNICODE_F (int) _utbm_nonspacing LDAP_P((ucs4_t c)); -extern ucs4_t _utbm_tolower LDAP_P((ucs4_t c)); +LDAP_LUNICODE_F (ucs4_t) _utbm_tolower LDAP_P((ucs4_t c)); -extern ucs4_t _utbm_toupper LDAP_P((ucs4_t c)); +LDAP_LUNICODE_F (ucs4_t) _utbm_toupper LDAP_P((ucs4_t c)); -extern ucs4_t _utbm_totitle LDAP_P((ucs4_t c)); +LDAP_LUNICODE_F (ucs4_t) _utbm_totitle LDAP_P((ucs4_t c)); LDAP_END_DECL diff --git a/libraries/liblutil/Makefile.in b/libraries/liblutil/Makefile.in index 13bac927a1..d825abf6e6 100644 --- a/libraries/liblutil/Makefile.in +++ b/libraries/liblutil/Makefile.in @@ -24,9 +24,6 @@ OBJS = base64.o csn.o debug.o entropy.o sasl.o signal.o hash.o \ LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries -NT_DYN_LIB_DEFS = -DLDAP_DECL=dllimport -CPPFLAGS = $(@PLAT@_@LIB_LINKAGE@_LIB_DEFS) - # These rules are for a Mingw32 build, specifically. # It's ok for them to be here because the clean rule is harmless, and # slapdmsg.res won't get built unless it's declared in OBJS. diff --git a/libraries/liblutil/ntservice.c b/libraries/liblutil/ntservice.c index bc4ae422dc..b0a61bcc5b 100644 --- a/libraries/liblutil/ntservice.c +++ b/libraries/liblutil/ntservice.c @@ -23,8 +23,16 @@ #include +/* + * The whole debug implementation is a bit of a hack. + * We have to define this LDAP_SLAPD_V macro here since the slap.h + * header file isn't included (and really shouldn't be). + * TODO: re-implement debug functions so that the debug level can + * be passed around instead of having to count on the existence of + * ldap_debug, slap_debug, etc. + */ #define ldap_debug slap_debug -extern int slap_debug; +LDAP_SLAPD_V (int) slap_debug; #include "ldap_log.h" #include "ldap_pvt_thread.h" diff --git a/libraries/librewrite/rewrite-int.h b/libraries/librewrite/rewrite-int.h index 4b1d931754..56c11fd638 100644 --- a/libraries/librewrite/rewrite-int.h +++ b/libraries/librewrite/rewrite-int.h @@ -321,14 +321,14 @@ struct rewrite_info { /* * Parses a map (also in legacy 'x' version) */ -extern struct rewrite_map * +LDAP_REWRITE_F (struct rewrite_map *) rewrite_map_parse( struct rewrite_info *info, const char *s, const char **end ); -extern struct rewrite_map * +LDAP_REWRITE_F (struct rewrite_map *) rewrite_xmap_parse( struct rewrite_info *info, const char *s, @@ -338,7 +338,7 @@ rewrite_xmap_parse( /* * Resolves key in val by means of map (also in legacy 'x' version) */ -extern int +LDAP_REWRITE_F (int) rewrite_map_apply( struct rewrite_info *info, struct rewrite_op *op, @@ -347,7 +347,7 @@ rewrite_map_apply( struct berval *val ); -extern int +LDAP_REWRITE_F (int) rewrite_xmap_apply( struct rewrite_info *info, struct rewrite_op *op, @@ -364,7 +364,7 @@ rewrite_xmap_apply( /* * Compiles a substitution pattern */ -extern struct rewrite_subst * +LDAP_REWRITE_F (struct rewrite_subst *) rewrite_subst_compile( struct rewrite_info *info, const char *result @@ -374,7 +374,7 @@ rewrite_subst_compile( * Substitutes a portion of rewritten string according to substitution * pattern using submatches */ -extern int +LDAP_REWRITE_F (int) rewrite_subst_apply( struct rewrite_info *info, struct rewrite_op *op, @@ -392,7 +392,7 @@ rewrite_subst_apply( /* * Compiles the rule and appends it at the running context */ -extern int +LDAP_REWRITE_F (int) rewrite_rule_compile( struct rewrite_info *info, struct rewrite_context *context, @@ -410,7 +410,7 @@ rewrite_rule_compile( * REWRITE_REGEXEC_UNWILL: rule matched; force 'unwilling to perform' * REWRITE_REGEXEC_ERR: an error occurred */ -extern int +LDAP_REWRITE_F (int) rewrite_rule_apply( struct rewrite_info *info, struct rewrite_op *op, @@ -426,7 +426,7 @@ rewrite_rule_apply( /* * Fetches a struct rewrite_session */ -extern struct rewrite_session * +LDAP_REWRITE_F (struct rewrite_session *) rewrite_session_find( struct rewrite_info *info, const void *cookie @@ -435,7 +435,7 @@ rewrite_session_find( /* * Defines and inits a variable with session scope */ -extern int +LDAP_REWRITE_F (int) rewrite_session_var_set( struct rewrite_info *info, const void *cookie, @@ -446,7 +446,7 @@ rewrite_session_var_set( /* * Gets a var with session scope */ -extern int +LDAP_REWRITE_F (int) rewrite_session_var_get( struct rewrite_info *info, const void *cookie, @@ -457,7 +457,7 @@ rewrite_session_var_get( /* * Deletes a session */ -extern int +LDAP_REWRITE_F (int) rewrite_session_delete( struct rewrite_info *info, const void *cookie @@ -466,7 +466,7 @@ rewrite_session_delete( /* * Destroys the cookie tree */ -extern int +LDAP_REWRITE_F (int) rewrite_session_destroy( struct rewrite_info *info ); @@ -479,7 +479,7 @@ rewrite_session_destroy( /* * Finds a var */ -extern struct rewrite_var * +LDAP_REWRITE_F (struct rewrite_var *) rewrite_var_find( Avlnode *tree, const char *name @@ -488,7 +488,7 @@ rewrite_var_find( /* * Inserts a newly created var */ -extern struct rewrite_var * +LDAP_REWRITE_F (struct rewrite_var *) rewrite_var_insert( Avlnode **tree, const char *name, @@ -498,7 +498,7 @@ rewrite_var_insert( /* * Sets/inserts a var */ -extern struct rewrite_var * +LDAP_REWRITE_F (struct rewrite_var *) rewrite_var_set( Avlnode **tree, const char *name, @@ -509,7 +509,7 @@ rewrite_var_set( /* * Deletes a var tree */ -extern int +LDAP_REWRITE_F (int) rewrite_var_delete( Avlnode *tree ); @@ -522,7 +522,7 @@ rewrite_var_delete( /* * Finds the context named rewriteContext in the context tree */ -extern struct rewrite_context * +LDAP_REWRITE_F (struct rewrite_context *) rewrite_context_find( struct rewrite_info *info, const char *rewriteContext @@ -531,7 +531,7 @@ rewrite_context_find( /* * Creates a new context called rewriteContext and stores in into the tree */ -extern struct rewrite_context * +LDAP_REWRITE_F (struct rewrite_context *) rewrite_context_create( struct rewrite_info *info, const char *rewriteContext @@ -543,7 +543,7 @@ rewrite_context_create( * STOP: fine, rule matched; stop processing following rules * UNWILL: rule matched; force 'unwilling to perform' */ -extern int +LDAP_REWRITE_F (int) rewrite_context_apply( struct rewrite_info *info, struct rewrite_op *op, diff --git a/libraries/librewrite/rewrite-map.h b/libraries/librewrite/rewrite-map.h index c01a4c769c..918dc4b063 100644 --- a/libraries/librewrite/rewrite-map.h +++ b/libraries/librewrite/rewrite-map.h @@ -28,7 +28,7 @@ /* * Retrieves a builtin map */ -struct rewrite_builtin_map * +LDAP_REWRITE_F (struct rewrite_builtin_map *) rewrite_builtin_map_find( struct rewrite_info *info, const char *name @@ -38,7 +38,7 @@ rewrite_builtin_map_find( /* * LDAP map */ -void * +LDAP_REWRITE_F (void *) map_ldap_parse( struct rewrite_info *info, const char *fname, @@ -47,7 +47,7 @@ map_ldap_parse( char **argv ); -int +LDAP_REWRITE_F (int) map_ldap_apply( struct rewrite_builtin_map *map, const char *filter, struct berval *val diff --git a/servers/slapd/Makefile.in b/servers/slapd/Makefile.in index a8bdfa687f..ccb98fdd23 100644 --- a/servers/slapd/Makefile.in +++ b/servers/slapd/Makefile.in @@ -46,9 +46,7 @@ XLDFLAGS = $(MODULES_LDFLAGS) $(SLAPD_MODULES) # $(LTHREAD_LIBS) must be last XLIBS = libbackends.a -lavl @LDBM_LIB@ -lldif -llutil -llunicode -lldap_r -llber -XXLIBS = $(LDBM_LIBS) $(SLAPD_LIBS) \ - $(SECURITY_LIBS) \ - $(LDIF_LIBS) $(LUTIL_LIBS) +XXLIBS = $(LDBM_LIBS) $(SLAPD_LIBS) $(SECURITY_LIBS) $(LDIF_LIBS) $(LUTIL_LIBS) XXXLIBS = $(LTHREAD_LIBS) $(MODULES_LIBS) BUILD_OPT = "--enable-slapd" @@ -56,120 +54,217 @@ BUILD_SRV = @BUILD_SLAPD@ all-local-srv: all-cffiles -NT_DYN_DEFS = -DLBER_DECL=dllimport -DLDAP_DECL=dllimport - -DEFINES = $(@PLAT@_@LIB_LINKAGE@_DEFS) - -# The tricky part about building slapd in NT is that it will export symbols -# like a DLL. The symbols that it exports should be representative of all -# of the static symbols that it knows about. - -NT_EXP = slapd.exp -NT_IMPLIB = libslapd.a -NT_DUMMY = symdummy.o - -# Add extra def targets here -EXTRA_DEFS = - -# NT needs this if libltdl is built statically. You'll have to fix the path -# to point to where libltdl was built, then put ltdl.def in EXTRA_DEFS -ltdl.def: ../../../libtool/libltdl/*.o - dlltool --export-all-symbols --output-def $@ $^ - -DYNAMIC_DEFS = liblber.def libldap_r.def - -STATIC_DEFS = libavl.def libldbm.def libldif.def liblutil.def slapd.def \ - $(EXTRA_DEFS) - -libavl.def: $(LDAP_LIBDIR)/libavl/*.o - dlltool --export-all-symbols --output-def $@ `ls $^ | grep -v test` - -liblber.def: $(LDAP_LIBDIR)/liblber/*.o - dlltool --export-all-symbols --output-def $@ `ls $^ | grep -v test` - -libldap_r.def: $(LDAP_LIBDIR)/libldap_r/*.o - dlltool --export-all-symbols --output-def $@ `ls $^ | grep -v test` - -libldbm.def: $(LDAP_LIBDIR)/libldbm/*.o - dlltool --export-all-symbols --output-def $@ `ls $^ | grep -v test` - -libldif.def: $(LDAP_LIBDIR)/libldif/*.o - dlltool --export-all-symbols --output-def $@ `ls $^ | grep -v test` - -liblutil.def: $(LDAP_LIBDIR)/liblutil/*.o - dlltool --export-all-symbols --output-def $@ `ls $^ | grep -v test` - -slapd.def: $(OBJS) version.o - dlltool --export-all-symbols --exclude-symbols main,ServiceMain@8 --output-def $@ `ls $^ | grep -v test` - -# We don't want to include symbols from dynamic libraries. -all.def: $(STATIC_DEFS) $(DYNAMIC_DEFS) - cat $(STATIC_DEFS) | grep " @ " | sed -e 's/ @ [0-9]*//' > $@ - if test "@LIB_LINKAGE@" != "DYN" ; then \ - cat $(DYNAMIC_DEFS) | grep " @ " | sed -e 's/ @ [0-9]*//' >> $@; \ - fi - echo EXPORTS > tmp.def - sort $@ >> tmp.def - rm -f $@ - dlltool --input-def tmp.def --output-def $@ - rm -f tmp.def - -DUMMYTMP = symdummytmp.c - -symdummy.c: all.def $(ALL_DEFS) - rm -f $@ - echo "static void never_called() {" > $(DUMMYTMP) - cat $< | grep " @ " | while read line; \ +NT_SLAPD_DEPENDS = slapd.exp +NT_SLAPD_OBJECTS = slapd.exp symdummy.o $(OBJS) version.o + +UNIX_SLAPD_DEPENDS = libbackends.a version.o +UNIX_SLAPD_OBJECTS = $(OBJS) version.o + +SLAPD_DEPENDS = $(@PLAT@_SLAPD_DEPENDS) +SLAPD_OBJECTS = $(@PLAT@_SLAPD_OBJECTS) + +# Notes about slapd for Windows +# ============================= +# slapd.exe must export all of its global symbols, just like a DLL. +# The purpose of this is to allow dynamic modules (dynamic backends +# or external dynamic modules) to bind with the symbols at run-time. +# +# Exporting symbols from an .EXE is a bit tricky and involves multiple +# steps. First a .DEF file must be generated. The .DEF file indicates +# the set of symbols that are to be exported. Many times, it's possible +# to manually create this file with an editor. However, with slapd, +# we want to export EVERY global symbol that it knows about (NOT including +# symbols that are imported from other DLLs). The set of symbols to +# export INCLUDES symbols from all static libraries that slapd gets +# linked with, e.g. avl, ldbm, ldif, lunicode, lutil, etc. This list +# will also include liblber and libldap_r if they were built as static +# libraries. ALSO included will be symbols from other STATIC libraries +# outside the domain of the OpenLDAP source tree, e.g. regex, ltdl, +# crypto, ssl, sasl, etc. (If these libraries are dynamic, we won't want +# to include their symbols in the list). The correct set of symbols +# CAN be determined at build time. The slapd.def target automatically +# determines the correct set of symbols and generates the slapd.def file. +# +# The slapd.def file, serving multiple purposes, will: +# +# 1) be used to generate libslapd.a, the import library for slapd.exe. +# +# 2) be used to generate the symdummy.c file. +# +# 3) be used to help create slapd.exp, the binary-formated slapd export file. +# +# The import library is used by dynamic modules at link time. With this +# library, dynamic modules indicate to the linker that it will resolve +# these symbols from the slapd.exe binary at run-time. Of course, whenever +# a module imports dynamic symbols, those symbols should be marked with +# the __declspec(dllimport) directive in the header files that the dynamic +# modules build with. In OpenLDAP, this is handled automatically in the +# header files. (See ldap_cdefs.h for an explanation). Writers of +# dynamic backend modules should keep in mind that slapd.exe might export +# other global symbols that are not part of OpenLDAP (e.g. regex, ltdl, +# crypto, ssl, sasl, etc.) When a writer actually uses (i.e. imports) these +# symbols, he must verify that the header files from these external packages +# include a mechanism to mark imported symbols with the __declspec(dllimport) +# directive. Whether or not such a mechanism exists, the writer must be +# able to include these directives appropriately when their symbols are +# being imported from slapd.exe. The directive is not completely necessary +# for functions, but it is required for variables. +# +# The symdummy.c file basically references EVERY symbol available to slapd.exe, +# including symbols that slapd.exe never actually refereneced. The file +# is compiled and included at link time. Without this object file, slapd.exe +# would NOT export symbols that it never referenced. The reason that these +# symbols must still be exported is because a dynamic module may want to +# use a symbol even if it had not been referenced by slapd.exe. +# + +# +# slapd.def REALLY depends upon all slapd objects and all static libraries +# included in $(LIBS), including static libraries outside of OpenLDAP. +# When slapd.def is built, the absolute paths to all static libraries +# (both inside and outside of OpenLDAP) are generated. We don't have +# any way to include this generated list as a dependency of slapd.def (sigh). +# Thus, we do the best we can by depending on version.o, which depends +# on its own very long list of dependencies. +# +slapd.def: libbackends.a version.o + @for i in $(LDFLAGS) ; do \ + path=`expr "$$i" : "-L\(.*\)"`; \ + if test $$? != 0; then continue; fi; \ + paths="$$paths $$path"; \ + done; \ + objs=""; \ + for i in $(OBJS) version.o $(LIBS) ; do \ + case $$i in \ + -l*) \ + obj="" ; \ + done="" ;\ + base=`expr "$$i" : "-l\(.*\)"`; \ + for p in $$paths ; do \ + for ext in la dll a ; do \ + path=$$p/lib$$base.$$ext; \ + test ! -f $$path && continue; \ + if test $$ext = la ; then \ + for t in dlname old_library ; do \ + line=`grep "^$$t=" $$path`; \ + lib=`expr "$$line" : "[^']*'\(.*\)'"`; \ + test -n "$$lib" && test -f $$p/$$lib && \ + path=$$p/$$lib && break; \ + done; \ + test $$t = dlname && ext=dll; \ + test $$t = old_library && ext=a; \ + fi; \ + if test $$ext = a ; then \ + obj=$$path; \ + fi; \ + done=done; \ + break; \ + done; \ + test -n "$$done" && break; \ + done; \ + test -z "$$obj" && continue; \ + ;; \ + *.o | *.a) \ + obj=$$i; \ + esac; \ + objs="$$objs $$obj"; \ + done; \ + echo dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \ + --output-def $@.tmp $$objs; \ + dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \ + --output-def $@.tmp $$objs; + echo EXPORTS > $@ + $(SED) -e 1,2d -e 's/ @ [0-9][0-9]*//' $@.tmp | sort >> $@ + $(RM) $@.tmp + +symdummy.c: slapd.def + $(RM) $@ + @echo "generating $@..."; \ + echo "static void never_called() {" > $@.tmp; \ + cat $< | while read line; \ do \ set dummy $$line; \ case $$# in \ - 5) \ + 3) \ echo "int $$2();" >> $@; \ - echo "$$2();" >> $(DUMMYTMP); \ + echo "$$2();" >> $@.tmp; \ ;; \ - 6) \ + 4) \ echo "extern int $$2;" >> $@; \ - echo "$$2 = 0;" >> $(DUMMYTMP); \ + echo "$$2 = 0;" >> $@.tmp; \ ;; \ esac; \ - done - echo "" >> $@ - echo "}" >> $(DUMMYTMP) - cat $(DUMMYTMP) >> $@ - rm -f $(DUMMYTMP) - -symdummy.o: symdummy.c - $(CC) $(CFLAGS) -c $< - -SLAPD_OBJS = $(OBJS) version.o symdummy.o - -slapd.exp: libbackends.a all.def $(SLAPD_OBJS) - $(LTLINK) -o slapd $(SLAPD_OBJS) $(LIBS) $(WRAP_LIBS) -Wl,--base-file,slapd.base - rm -f slapd.exe - dlltool --dllname slapd.exe --input-def all.def --base-file slapd.base --output-exp $@ - $(LTLINK) -o slapd $(SLAPD_OBJS) $(LIBS) $(WRAP_LIBS) $@ -Wl,--base-file,slapd.base - rm -f slapd.exe - dlltool --dllname slapd.exe --input-def all.def --base-file slapd.base --output-exp $@ - -libslapd.a: all.def - dlltool --dllname slapd.exe --input-def $< --output-lib $@ - -slapd: libbackends.a version.o $(@PLAT@_EXP) $(@PLAT@_DUMMY) - $(LTLINK) -o $@ $(@PLAT@_EXP) $(@PLAT@_DUMMY) $(OBJS) version.o $(LIBS) $(WRAP_LIBS) - (cd tools; $(MAKE) $(MFLAGS) all) + done; \ + echo "" >> $@; \ + echo "}" >> $@.tmp; \ + cat $@.tmp >> $@; \ + $(RM) $@.tmp + +libslapd.a: symdummy.o + dlltool --dllname slapd.exe --input-def slapd.def --output-lib $@ + +slapd.exp: libslapd.a + @echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd \ + $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \ + $(LTLINK) -Wl,--base-file,slapd.base -o slapd \ + $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS) + $(RM) slapd.exe + @echo dlltool --dllname slapd.exe --input-def slapd.def \ + --base-file slapd.base --output-exp $@; \ + dlltool --dllname slapd.exe --input-def slapd.def \ + --base-file slapd.base --output-exp $@; \ + echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \ + $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \ + $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \ + $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS) + $(RM) slapd.exe + @echo dlltool --dllname slapd.exe --input-def slapd.def \ + --base-file slapd.base --output-exp $@; \ + dlltool --dllname slapd.exe --input-def slapd.def \ + --base-file slapd.base --output-exp $@ + +slapd: $(SLAPD_DEPENDS) + $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) $(WRAP_LIBS) + @msg="building dynamic backends..."; \ + for i in back-*; do \ + if test -d $$i -a -f $$i/Makefile ; then \ + grep '^BUILD_MOD[ ]*=[ ]*mod[ ]*$$' $$i/Makefile \ + > /dev/null 2>&1; \ + if test $$? = 0; then \ + if test -n "$$msg"; then \ + echo ""; echo "$$msg"; \ + msg=""; \ + fi; \ + echo ""; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \ + ( cd $$i; $(MAKE) $(MFLAGS) all ); \ + if test $$? != 0 ; then exit 1; fi ; \ + fi; \ + fi; \ + done; \ + echo "" + cd tools; $(MAKE) $(MFLAGS) all sslapd: version.o $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS) -.backend: $(@PLAT@_IMPLIB) FORCE - @for i in back-*; do \ - if test -d $$i -a -f $$i/Makefile ; then \ - echo " "; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \ - ( cd $$i; $(MAKE) $(MFLAGS) all ); \ - if test $$? != 0 ; then exit 1; fi ; \ +# +# In Windows, dynamic backends have to be built after slapd. For this +# reason, we only build static backends now and dynamic backends later. +# +.backend: FORCE + @echo ""; echo "building static backends..."; \ + for i in back-*; do \ + if test -d $$i -a -f $$i/Makefile ; then \ + grep '^BUILD_MOD[ ]*=[ ]*mod[ ]*$$' $$i/Makefile \ + > /dev/null 2>&1; \ + if test $$? != 0; then \ + echo ""; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \ + ( cd $$i; $(MAKE) $(MFLAGS) all ); \ + if test $$? != 0 ; then exit 1; fi ; \ fi; \ + fi; \ done; \ - echo " " + echo "" libbackends.a: .backend @$(RM) -r tmp @@ -178,13 +273,14 @@ libbackends.a: .backend ( \ cd tmp; \ $(AR) x ../$$i; \ - pre=`echo $$i | sed -e 's/\/.*$$//' -e 's/back-//'`; \ + pre=`echo $$i | $(SED) -e 's/\/.*$$//' -e 's/back-//'`; \ for j in *.o; do \ mv $$j $${pre}$$j; \ done; \ $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \ $(RM) *.o __.SYMDEF ________64ELEL_ ; \ echo "added backend library $$i"; \ + echo ""; \ ); \ done @mv -f tmp/libbackends.a ./libbackends.a @@ -192,7 +288,7 @@ libbackends.a: .backend @if test ! -z "$(RANLIB)" ; then \ $(RANLIB) libbackends.a; \ fi - @ls -l libbackends.a + @ls -l libbackends.a; echo "" version.c: $(OBJS) $(SLAPD_LIBDEPEND) @-$(RM) $@ @@ -236,20 +332,30 @@ install-slapd: FORCE -$(MKDIR) $(DESTDIR)$(localstatedir) $(LTINSTALL) $(INSTALLFLAGS) -s -m 755 \ slapd$(EXEEXT) $(DESTDIR)$(libexecdir) - @if test ! -z "$(SLAPD_MODULES)" ; then \ - for i in back-* shell-backends tools; do \ - if test -d $$i -a -f $$i/Makefile ; then \ - echo; echo " cd $$i; $(MAKE) $(MFLAGS) install"; \ - ( cd $$i; $(MAKE) $(MFLAGS) install ); \ - if test $$? != 0 ; then exit 1; fi ; \ - fi; \ - done; \ - fi + @for i in back-* shell-backends tools; do \ + if test -d $$i -a -f $$i/Makefile ; then \ + echo; echo " cd $$i; $(MAKE) $(MFLAGS) install"; \ + ( cd $$i; $(MAKE) $(MFLAGS) install ); \ + if test $$? != 0 ; then exit 1; fi ; \ + fi; \ + done all-cffiles: slapd - $(SED) -e 's;%SYSCONFDIR%;$(sysconfdir);' \ - -e 's;%LOCALSTATEDIR%;$(localstatedir);' \ - -e 's;%MODULEDIR%;$(moduledir);' \ + @if test $(PLAT) = NT; then \ + sysconfdir=`cygpath -w $(sysconfdir) | \ + $(SED) -e 's/\\\\/\\\\\\\\/g'`; \ + localstatedir=`cygpath -w $(localstatedir) | \ + $(SED) -e 's/\\\\/\\\\\\\\/g'`; \ + moduledir=`cygpath -w $(moduledir) | \ + $(SED) -e 's/\\\\/\\\\\\\\/g'`; \ + else \ + sysconfdir=$(sysconfdir); \ + localstatedir=$(localstatedir); \ + moduledir=$(moduledir); \ + fi; \ + $(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \ + -e "s;%LOCALSTATEDIR%;$$localstatedir;" \ + -e "s;%MODULEDIR%;$$moduledir;" \ $(srcdir)/slapd.conf > slapd.conf.tmp ; \ touch all-cffiles diff --git a/servers/slapd/back-bdb/Makefile.in b/servers/slapd/back-bdb/Makefile.in index 42c5953dd8..edba6a3a17 100644 --- a/servers/slapd/back-bdb/Makefile.in +++ b/servers/slapd/back-bdb/Makefile.in @@ -16,18 +16,13 @@ LDAP_LIBDIR= ../../../libraries BUILD_OPT = "--enable-bdb" BUILD_MOD = @BUILD_BDB@ -LINKAGE = @BUILD_BDB_DYNAMIC@ +BUILD_MOD_DYNAMIC = @BUILD_BDB_DYNAMIC@ -DYN_DEFS = -DLBER_DECL=dllimport -DLDAP_DECL=dllimport +mod_DEFS = -DSLAPD_IMPORT +MOD_DEFS = $(@BUILD_BDB@_DEFS) -# TODO -#NT_mod_DYN_MODDEFS = -#NT_mod_STAT_MODDEFS = - -NT_yes_DYN_MODDEFS = $(DYN_DEFS) -NT_yes_STAT_MODDEFS = - -MODDEFS = $(@PLAT@_@BUILD_LDBM@_@LIB_LINKAGE@_MODDEFS) +shared_LDAP_LIBS = $(LDAP_LIBPATH) -lldap_r -llber +NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) LIBBASE = back_bdb diff --git a/servers/slapd/back-dnssrv/Makefile.in b/servers/slapd/back-dnssrv/Makefile.in index 9d01c5a57b..50abb23faf 100644 --- a/servers/slapd/back-dnssrv/Makefile.in +++ b/servers/slapd/back-dnssrv/Makefile.in @@ -18,7 +18,13 @@ LDAP_LIBDIR= ../../../libraries BUILD_OPT = "--enable-dnssrv" BUILD_MOD = @BUILD_DNSSRV@ -LINKAGE = @BUILD_DNSSRV_DYNAMIC@ +BUILD_MOD_DYNAMIC = @BUILD_DNSSRV_DYNAMIC@ + +mod_DEFS = -DSLAPD_IMPORT +MOD_DEFS = $(@BUILD_DNSSRV@_DEFS) + +shared_LDAP_LIBS = $(LDAP_LIBPATH) -lldap_r -llber +NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) LIBBASE = back_dnssrv diff --git a/servers/slapd/back-ldap/Makefile.in b/servers/slapd/back-ldap/Makefile.in index 38f42798c5..0331104677 100644 --- a/servers/slapd/back-ldap/Makefile.in +++ b/servers/slapd/back-ldap/Makefile.in @@ -12,7 +12,13 @@ LDAP_LIBDIR= ../../../libraries BUILD_OPT = "--enable-ldap" BUILD_MOD = @BUILD_LDAP@ -LINKAGE = @BUILD_LDAP_DYNAMIC@ +BUILD_MOD_DYNAMIC = @BUILD_LDAP_DYNAMIC@ + +mod_DEFS = -DSLAPD_IMPORT +MOD_DEFS = $(@BUILD_LDAP@_DEFS) + +shared_LDAP_LIBS = $(LDAP_LIBPATH) -lldap_r -llber +NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) LIBBASE = back_ldap diff --git a/servers/slapd/back-ldbm/Makefile.in b/servers/slapd/back-ldbm/Makefile.in index bdd26ae661..45c280d38f 100644 --- a/servers/slapd/back-ldbm/Makefile.in +++ b/servers/slapd/back-ldbm/Makefile.in @@ -1,33 +1,30 @@ # $OpenLDAP$ -SRCS = idl.c add.c search.c cache.c dbcache.c dn2id.c entry.c id2entry.c \ - index.c id2children.c nextid.c abandon.c compare.c group.c \ - modify.c modrdn.c delete.c init.c config.c bind.c attr.c \ - filterindex.c unbind.c close.c alias.c tools.c key.c \ - extended.c passwd.c sasl.c referral.c attribute.c -OBJS = idl.lo add.lo search.lo cache.lo dbcache.lo dn2id.lo entry.lo id2entry.lo \ - index.lo id2children.lo nextid.lo abandon.lo compare.lo group.lo \ - modify.lo modrdn.lo delete.lo init.lo config.lo bind.lo attr.lo \ - filterindex.lo unbind.lo close.lo alias.lo tools.lo key.lo \ - extended.lo passwd.lo sasl.lo referral.lo attribute.lo +SRCS = idl.c add.c search.c cache.c dbcache.c dn2id.c entry.c \ + id2entry.c index.c id2children.c nextid.c abandon.c \ + compare.c group.c modify.c modrdn.c delete.c init.c \ + config.c bind.c attr.c filterindex.c unbind.c close.c \ + alias.c tools.c key.c extended.c passwd.c sasl.c \ + referral.c attribute.c +OBJS = idl.lo add.lo search.lo cache.lo dbcache.lo dn2id.lo entry.lo \ + id2entry.lo index.lo id2children.lo nextid.lo abandon.lo \ + compare.lo group.lo modify.lo modrdn.lo delete.lo init.lo \ + config.lo bind.lo attr.lo filterindex.lo unbind.lo close.lo \ + alias.lo tools.lo key.lo extended.lo passwd.lo sasl.lo \ + referral.lo attribute.lo LDAP_INCDIR= ../../../include LDAP_LIBDIR= ../../../libraries BUILD_OPT = "--enable-ldbm" BUILD_MOD = @BUILD_LDBM@ -LINKAGE = @BUILD_LDBM_DYNAMIC@ +BUILD_MOD_DYNAMIC = @BUILD_LDBM_DYNAMIC@ -DYN_DEFS = -DLBER_DECL=dllimport -DLDAP_DECL=dllimport +mod_DEFS = -DSLAPD_IMPORT +MOD_DEFS = $(@BUILD_LDBM@_DEFS) -# TODO -#NT_mod_DYN_MODDEFS = -#NT_mod_STAT_MODDEFS = - -NT_yes_DYN_MODDEFS = $(DYN_DEFS) -NT_yes_STAT_MODDEFS = - -MODDEFS = $(@PLAT@_@BUILD_LDBM@_@LIB_LINKAGE@_MODDEFS) +shared_LDAP_LIBS = $(LDAP_LIBPATH) -lldap_r -llber +NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) LIBBASE = back_ldbm diff --git a/servers/slapd/back-meta/Makefile.in b/servers/slapd/back-meta/Makefile.in index 2b796c3224..c6e1e7d6bc 100644 --- a/servers/slapd/back-meta/Makefile.in +++ b/servers/slapd/back-meta/Makefile.in @@ -12,7 +12,13 @@ LDAP_LIBDIR= ../../../libraries BUILD_OPT = "--enable-meta" BUILD_MOD = @BUILD_META@ -LINKAGE = @BUILD_META_DYNAMIC@ +BUILD_MOD_DYNAMIC = @BUILD_META_DYNAMIC@ + +mod_DEFS = -DSLAPD_IMPORT +MOD_DEFS = $(@BUILD_META@_DEFS) + +shared_LDAP_LIBS = $(LDAP_LIBPATH) -lldap_r -llber +NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) LIBBASE = back_meta diff --git a/servers/slapd/back-monitor/Makefile.in b/servers/slapd/back-monitor/Makefile.in index d8bcbd0fb2..5e3ce20328 100644 --- a/servers/slapd/back-monitor/Makefile.in +++ b/servers/slapd/back-monitor/Makefile.in @@ -14,18 +14,13 @@ LDAP_LIBDIR= ../../../libraries BUILD_OPT = "--enable-monitor" BUILD_MOD = @BUILD_MONITOR@ -LINKAGE = @BUILD_MONITOR_DYNAMIC@ +BUILD_MOD_DYNAMIC = @BUILD_MONITOR_DYNAMIC@ -DYN_DEFS = -DLBER_DECL=dllimport -DLDAP_DECL=dllimport +mod_DEFS = -DSLAPD_IMPORT +MOD_DEFS = $(@BUILD_MONITOR@_DEFS) -# TODO -#NT_mod_DYN_MODDEFS = -#NT_mod_STAT_MODDEFS = - -NT_yes_DYN_MODDEFS = $(DYN_DEFS) -NT_yes_STAT_MODDEFS = - -MODDEFS = $(@PLAT@_@BUILD_MONITOR@_@LIB_LINKAGE@_MODDEFS) +shared_LDAP_LIBS = $(LDAP_LIBPATH) -lldap_r -llber +NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) LIBBASE = back_monitor diff --git a/servers/slapd/back-passwd/Makefile.in b/servers/slapd/back-passwd/Makefile.in index a3a7aa5d05..447ebd4269 100644 --- a/servers/slapd/back-passwd/Makefile.in +++ b/servers/slapd/back-passwd/Makefile.in @@ -8,7 +8,13 @@ LDAP_LIBDIR= ../../../libraries BUILD_OPT = "--enable-passwd" BUILD_MOD = @BUILD_PASSWD@ -LINKAGE = @BUILD_PASSWD_DYNAMIC@ +BUILD_MOD_DYNAMIC = @BUILD_PASSWD_DYNAMIC@ + +mod_DEFS = -DSLAPD_IMPORT +MOD_DEFS = $(@BUILD_PASSWD@_DEFS) + +shared_LDAP_LIBS = $(LDAP_LIBPATH) -lldap_r -llber +NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) LIBBASE = back_passwd diff --git a/servers/slapd/back-perl/Makefile.in b/servers/slapd/back-perl/Makefile.in index 3016fa6936..84a8559de8 100644 --- a/servers/slapd/back-perl/Makefile.in +++ b/servers/slapd/back-perl/Makefile.in @@ -20,11 +20,16 @@ LDAP_LIBDIR= ../../../libraries BUILD_OPT = "--enable-perl" BUILD_MOD = @BUILD_PERL@ -LINKAGE = @BUILD_PERL_DYNAMIC@ +BUILD_MOD_DYNAMIC = @BUILD_PERL_DYNAMIC@ PERL_CPPFLAGS = @PERL_CPPFLAGS@ +mod_DEFS = -DSLAPD_IMPORT +MOD_DEFS = $(@BUILD_PERL@_DEFS) + +shared_LDAP_LIBS = $(LDAP_LIBPATH) -lldap_r -llber +NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) + LIBBASE = back_perl -MODLIBS = @MOD_PERL_LDFLAGS@ XINCPATH = -I.. -I$(srcdir)/.. XDEFS = $(PERL_CPPFLAGS) $(MODULES_CPPFLAGS) diff --git a/servers/slapd/back-shell/Makefile.in b/servers/slapd/back-shell/Makefile.in index d7f85df220..cf350bd9be 100644 --- a/servers/slapd/back-shell/Makefile.in +++ b/servers/slapd/back-shell/Makefile.in @@ -2,17 +2,23 @@ ## Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. ## COPYING RESTRICTIONS APPLY, see COPYRIGHT file -SRCS = init.c config.c fork.c search.c bind.c unbind.c add.c delete.c \ - modify.c modrdn.c compare.c abandon.c result.c -OBJS = init.lo config.lo fork.lo search.lo bind.lo unbind.lo add.lo delete.lo \ - modify.lo modrdn.lo compare.lo abandon.lo result.lo +SRCS = init.c config.c fork.c search.c bind.c unbind.c add.c \ + delete.c modify.c modrdn.c compare.c abandon.c result.c +OBJS = init.lo config.lo fork.lo search.lo bind.lo unbind.lo add.lo \ + delete.lo modify.lo modrdn.lo compare.lo abandon.lo result.lo LDAP_INCDIR= ../../../include LDAP_LIBDIR= ../../../libraries BUILD_OPT = "--enable-shell" BUILD_MOD = @BUILD_SHELL@ -LINKAGE = @BUILD_SHELL_DYNAMIC@ +BUILD_MOD_DYNAMIC = @BUILD_SHELL_DYNAMIC@ + +mod_DEFS = -DSLAPD_IMPORT +MOD_DEFS = $(@BUILD_SHELL@_DEFS) + +shared_LDAP_LIBS = $(LDAP_LIBPATH) -lldap_r -llber +NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) LIBBASE = back_shell diff --git a/servers/slapd/back-sql/Makefile.in b/servers/slapd/back-sql/Makefile.in index 5ee2f0c8d6..5406620160 100644 --- a/servers/slapd/back-sql/Makefile.in +++ b/servers/slapd/back-sql/Makefile.in @@ -10,7 +10,13 @@ LDAP_LIBDIR= ../../../libraries BUILD_OPT = "--enable-sql" BUILD_MOD = @BUILD_SQL@ -LINKAGE = @BUILD_SQL_DYNAMIC@ +BUILD_MOD_DYNAMIC = @BUILD_SQL_DYNAMIC@ + +mod_DEFS = -DSLAPD_IMPORT +MOD_DEFS = $(@BUILD_SQL@_DEFS) + +shared_LDAP_LIBS = $(LDAP_LIBPATH) -lldap_r -llber +NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) LIBBASE = back_sql diff --git a/servers/slapd/back-tcl/Makefile.in b/servers/slapd/back-tcl/Makefile.in index abfdd67dbe..d88e954ba2 100644 --- a/servers/slapd/back-tcl/Makefile.in +++ b/servers/slapd/back-tcl/Makefile.in @@ -24,10 +24,15 @@ LDAP_LIBDIR= ../../../libraries BUILD_OPT = "--enable-tcl" BUILD_MOD = @BUILD_TCL@ -LINKAGE = @BUILD_TCL_DYNAMIC@ +BUILD_MOD_DYNAMIC = @BUILD_TCL_DYNAMIC@ + +mod_DEFS = -DSLAPD_IMPORT +MOD_DEFS = $(@BUILD_TCL@_DEFS) + +shared_LDAP_LIBS = $(LDAP_LIBPATH) -lldap_r -llber +NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) LIBBASE = back_tcl -MODLIBS = @MOD_TCL_LIB@ XDEFS = $(MODULES_CPPFLAGS) XINCPATH = -I.. -I$(srcdir)/.. @@ -36,3 +41,4 @@ all-local-lib: ../.backend ../.backend: lib$(LIBBASE).a @touch $@ + diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 85ce098374..688a4ee3e8 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -18,40 +18,48 @@ #include "slap.h" #include "lutil.h" -#ifdef SLAPD_BDB +/* + * If a module is configured as dynamic, its header should not + * get included into slapd. While this is a general rule and does + * not have much of an effect in UNIX, this rule should be adhered + * to for Windows, where dynamic object code should not be implicitly + * imported into slapd without appropriate __declspec(dllimport) directives. + */ + +#if defined(SLAPD_BDB) && !defined(SLAPD_BDB_DYNAMIC) #include "back-bdb/external.h" #endif -#ifdef SLAPD_DNSSRV +#if defined(SLAPD_DNSSRV) && !defined(SLAPD_DNSSRV_DYNAMIC) #include "back-dnssrv/external.h" #endif -#ifdef SLAPD_LDAP +#if defined(SLAPD_LDAP) && !defined(SLAPD_LDAP_DYNAMIC) #include "back-ldap/external.h" #endif -#ifdef SLAPD_LDBM +#if defined(SLAPD_LDBM) && !defined(SLAPD_LDBM_DYNAMIC) #include "back-ldbm/external.h" #endif -#ifdef SLAPD_META +#if defined(SLAPD_META) && !defined(SLAPD_META_DYNAMIC) #include "back-meta/external.h" #endif -#ifdef SLAPD_MONITOR +#if defined(SLAPD_MONITOR) && !defined(SLAPD_MONITOR_DYNAMIC) #include "back-monitor/external.h" #endif -#ifdef SLAPD_PASSWD +#if defined(SLAPD_PASSWD) && !defined(SLAPD_PASSWD_DYNAMIC) #include "back-passwd/external.h" #endif -#ifdef SLAPD_PERL +#if defined(SLAPD_PERL) && !defined(SLAPD_PERL_DYNAMIC) #include "back-perl/external.h" #endif -#ifdef SLAPD_SHELL +#if defined(SLAPD_SHELL) && !defined(SLAPD_SHELL_DYNAMIC) #include "back-shell/external.h" #endif -#ifdef SLAPD_TCL +#if defined(SLAPD_TCL) && !defined(SLAPD_TCL_DYNAMIC) #include "back-tcl/external.h" #endif -#ifdef SLAPD_SQL +#if defined(SLAPD_SQL) && !defined(SLAPD_SQL_DYNAMIC) #include "back-sql/external.h" #endif -#ifdef SLAPD_PRIVATE +#if defined(SLAPD_PRIVATE) && !defined(SLAPD_PRIVATE_DYNAMIC) #include "private/external.h" #endif diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 9a71105692..c13b4ae876 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -17,6 +17,7 @@ #include #include "ldap_pvt.h" +#include "ldap_pvt_thread.h" #include "lutil.h" #include "slap.h" @@ -64,13 +65,6 @@ static int waking; do { if (w) tcp_write( wake_sds[1], "0", 1 ); } while(0) #endif -#ifdef HAVE_NT_SERVICE_MANAGER -/* in nt_main.c */ -/* externs are frowned upon, but so is NT :-) */ -extern ldap_pvt_thread_cond_t started_event; -extern int is_NT_Service; -#endif - #ifndef HAVE_WINSOCK static #endif diff --git a/servers/slapd/main.c b/servers/slapd/main.c index 0411a8d35f..ccb6c0e12c 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -29,13 +29,6 @@ static RETSIGTYPE wait4child( int sig ); #define MAIN_RETURN(x) return struct sockaddr_in bind_addr; -/* in nt_main.c */ -LDAP_LUTIL_V(SERVICE_STATUS) SLAPDServiceStatus; -LDAP_LUTIL_V(SERVICE_STATUS_HANDLE) hSLAPDServiceStatus; -/* externs are frowned upon, but so is NT :-) */ -extern ldap_pvt_thread_cond_t started_event, stopped_event; -extern int is_NT_Service; - void CommenceStartupProcessing( LPCTSTR serverName, void(*stopper)(int)); void ReportSlapdShutdownComplete( void ); diff --git a/servers/slapd/nt_svc.c b/servers/slapd/nt_svc.c index 40a349ec4a..b9f45e2111 100644 --- a/servers/slapd/nt_svc.c +++ b/servers/slapd/nt_svc.c @@ -8,6 +8,7 @@ #include #include #include "slap.h" +#include "lutil.h" #ifdef HAVE_NT_SERVICE_MANAGER @@ -25,7 +26,6 @@ int main( int argc, LPTSTR *argv ) { int length; char filename[MAX_PATH], *fname_start; - extern int is_NT_Service; /* * Because the service was registered as SERVICE_WIN32_OWN_PROCESS, diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index d5034175eb..282dd08357 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -10,8 +10,8 @@ LDAP_BEGIN_DECL -LDAP_SLAPD_F( int ) schema_init_done; -LDAP_SLAPD_F( struct slap_internal_schema ) slap_schema; +LDAP_SLAPD_V( int ) schema_init_done; +LDAP_SLAPD_V( struct slap_internal_schema ) slap_schema; LDAP_SLAPD_F( int ) slap_valid_descr( const char * ); @@ -334,7 +334,7 @@ LDAP_SLAPD_F (void) build_new_dn LDAP_P(( char ** new_dn, * entry.c */ -extern const Entry slap_entry_root; +LDAP_SLAPD_V (const Entry) slap_entry_root; LDAP_SLAPD_F (int) entry_destroy LDAP_P((void)); @@ -468,7 +468,7 @@ LDAP_SLAPD_F (void) *module_resolve LDAP_P(( /* * controls.c */ -LDAP_SLAPD_F (char *) supportedControls[]; +LDAP_SLAPD_V (char *) supportedControls[]; /* * mra.c @@ -853,8 +853,8 @@ LDAP_SLAPD_F (int) slap_passwd_parse( * kerberos.c */ #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND -extern char *ldap_srvtab; -LDAP_SLAPD_F (int) krbv4_ldap_auth(); +LDAP_SLAPD_V (char) *ldap_srvtab; +LDAP_SLAPD_V (int) krbv4_ldap_auth(); #endif /* @@ -863,65 +863,65 @@ LDAP_SLAPD_F (int) krbv4_ldap_auth(); #define SLAP_SB_MAX_INCOMING_DEFAULT ((1<<18) - 1) #define SLAP_SB_MAX_INCOMING_AUTH ((1<<24) - 1) -LDAP_SLAPD_F (ber_len_t) sockbuf_max_incoming; -LDAP_SLAPD_F (ber_len_t) sockbuf_max_incoming_auth; - -LDAP_SLAPD_F (slap_mask_t) global_restrictops; -LDAP_SLAPD_F (slap_mask_t) global_allows; -LDAP_SLAPD_F (slap_mask_t) global_disallows; -LDAP_SLAPD_F (slap_mask_t) global_requires; -LDAP_SLAPD_F (slap_ssf_set_t) global_ssf_set; - -LDAP_SLAPD_F (struct berval **) default_referral; -LDAP_SLAPD_F (char *) replogfile; -LDAP_SLAPD_F (const char) Versionstr[]; -LDAP_SLAPD_F (struct slap_limits_set) deflimit; -LDAP_SLAPD_F (int) g_argc; -LDAP_SLAPD_F (slap_access_t) global_default_access; -LDAP_SLAPD_F (int) global_lastmod; -LDAP_SLAPD_F (int) global_idletimeout; -LDAP_SLAPD_F (int) global_schemacheck; -LDAP_SLAPD_F (char) *global_host; -LDAP_SLAPD_F (char) *global_realm; -LDAP_SLAPD_F (int) sasl_external_x509dn_convert; -LDAP_SLAPD_F (char) *default_passwd_hash; -LDAP_SLAPD_F (int) lber_debug; -LDAP_SLAPD_F (int) ldap_syslog; -LDAP_SLAPD_F (char *) default_search_base; -LDAP_SLAPD_F (char *) default_search_nbase; - -LDAP_SLAPD_F (int) nSaslRegexp; -LDAP_SLAPD_F (SaslRegexp_t*) SaslRegexp; - -LDAP_SLAPD_F (ldap_pvt_thread_mutex_t) num_sent_mutex; -LDAP_SLAPD_F (long) num_bytes_sent; -LDAP_SLAPD_F (long) num_pdu_sent; -LDAP_SLAPD_F (long) num_entries_sent; -LDAP_SLAPD_F (long) num_refs_sent; - -LDAP_SLAPD_F (ldap_pvt_thread_mutex_t) num_ops_mutex; -LDAP_SLAPD_F (long) num_ops_completed; -LDAP_SLAPD_F (long) num_ops_initiated; - -LDAP_SLAPD_F (char *) slapd_pid_file; -LDAP_SLAPD_F (char *) slapd_args_file; -LDAP_SLAPD_F (char) **g_argv; -LDAP_SLAPD_F (time_t) starttime; +LDAP_SLAPD_V (ber_len_t) sockbuf_max_incoming; +LDAP_SLAPD_V (ber_len_t) sockbuf_max_incoming_auth; + +LDAP_SLAPD_V (slap_mask_t) global_restrictops; +LDAP_SLAPD_V (slap_mask_t) global_allows; +LDAP_SLAPD_V (slap_mask_t) global_disallows; +LDAP_SLAPD_V (slap_mask_t) global_requires; +LDAP_SLAPD_V (slap_ssf_set_t) global_ssf_set; + +LDAP_SLAPD_V (struct berval **) default_referral; +LDAP_SLAPD_V (char *) replogfile; +LDAP_SLAPD_V (const char) Versionstr[]; +LDAP_SLAPD_V (struct slap_limits_set) deflimit; +LDAP_SLAPD_V (int) g_argc; +LDAP_SLAPD_V (slap_access_t) global_default_access; +LDAP_SLAPD_V (int) global_lastmod; +LDAP_SLAPD_V (int) global_idletimeout; +LDAP_SLAPD_V (int) global_schemacheck; +LDAP_SLAPD_V (char) *global_host; +LDAP_SLAPD_V (char) *global_realm; +LDAP_SLAPD_V (int) sasl_external_x509dn_convert; +LDAP_SLAPD_V (char) *default_passwd_hash; +LDAP_SLAPD_V (int) lber_debug; +LDAP_SLAPD_V (int) ldap_syslog; +LDAP_SLAPD_V (char *) default_search_base; +LDAP_SLAPD_V (char *) default_search_nbase; + +LDAP_SLAPD_V (int) nSaslRegexp; +LDAP_SLAPD_V (SaslRegexp_t*) SaslRegexp; + +LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) num_sent_mutex; +LDAP_SLAPD_V (long) num_bytes_sent; +LDAP_SLAPD_V (long) num_pdu_sent; +LDAP_SLAPD_V (long) num_entries_sent; +LDAP_SLAPD_V (long) num_refs_sent; + +LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) num_ops_mutex; +LDAP_SLAPD_V (long) num_ops_completed; +LDAP_SLAPD_V (long) num_ops_initiated; + +LDAP_SLAPD_V (char *) slapd_pid_file; +LDAP_SLAPD_V (char *) slapd_args_file; +LDAP_SLAPD_V (char) **g_argv; +LDAP_SLAPD_V (time_t) starttime; /* use time(3) -- no mutex */ #define slap_get_time() time( NULL ) -LDAP_SLAPD_F (ldap_pvt_thread_pool_t) connection_pool; +LDAP_SLAPD_V (ldap_pvt_thread_pool_t) connection_pool; -LDAP_SLAPD_F (ldap_pvt_thread_mutex_t) entry2str_mutex; -LDAP_SLAPD_F (ldap_pvt_thread_mutex_t) replog_mutex; +LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) entry2str_mutex; +LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) replog_mutex; #if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD ) -LDAP_SLAPD_F (ldap_pvt_thread_mutex_t) passwd_mutex; +LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) passwd_mutex; #endif -LDAP_SLAPD_F (ldap_pvt_thread_mutex_t) gmtime_mutex; +LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) gmtime_mutex; -LDAP_SLAPD_F (AccessControl *) global_acl; +LDAP_SLAPD_V (AccessControl *) global_acl; LDAP_SLAPD_F (int) slap_init LDAP_P((int mode, const char* name)); LDAP_SLAPD_F (int) slap_startup LDAP_P(( Backend *be )); @@ -968,7 +968,7 @@ LDAP_SLAPD_F (int) do_unbind LDAP_P((Connection *conn, Operation *op)); LDAP_SLAPD_F (int) do_extended LDAP_P((Connection *conn, Operation *op)); -LDAP_SLAPD_F (ber_socket_t) dtblsize; +LDAP_SLAPD_V (ber_socket_t) dtblsize; LDAP_END_DECL diff --git a/servers/slapd/sets.h b/servers/slapd/sets.h index 134707fe5e..1c7b8fe55e 100644 --- a/servers/slapd/sets.h +++ b/servers/slapd/sets.h @@ -11,8 +11,10 @@ */ typedef char **(*SET_GATHER) (void *cookie, char *name, char *attr); -long set_size (char **set); -void set_dispose (char **set); +LDAP_SLAPD_F (long) set_size (char **set); +LDAP_SLAPD_F (void) set_dispose (char **set); -int set_filter (SET_GATHER gatherer, void *cookie, char *filter, char *user, char *this, char ***results); +LDAP_SLAPD_F (int) +set_filter (SET_GATHER gatherer, void *cookie, char *filter, + char *user, char *this, char ***results); diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index dde81a8749..6c35e4735e 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -131,7 +131,7 @@ LDAP_BEGIN_DECL #define SLAPD_TOP_OID "2.5.6.0" -LDAP_SLAPD_F (int) slap_debug; +LDAP_SLAPD_V (int) slap_debug; typedef unsigned long slap_mask_t; @@ -843,12 +843,12 @@ struct replog_moddn { typedef struct slap_backend_info BackendInfo; /* per backend type */ typedef struct slap_backend_db BackendDB; /* per backend database */ -LDAP_SLAPD_F (int) nBackendInfo; -LDAP_SLAPD_F (int) nBackendDB; -LDAP_SLAPD_F (BackendInfo *) backendInfo; -LDAP_SLAPD_F (BackendDB *) backendDB; +LDAP_SLAPD_V (int) nBackendInfo; +LDAP_SLAPD_V (int) nBackendDB; +LDAP_SLAPD_V (BackendInfo *) backendInfo; +LDAP_SLAPD_V (BackendDB *) backendDB; -LDAP_SLAPD_F (int) slapMode; +LDAP_SLAPD_V (int) slapMode; #define SLAP_UNDEFINED_MODE 0x0000 #define SLAP_SERVER_MODE 0x0001 #define SLAP_TOOL_MODE 0x0002 diff --git a/servers/slapd/tools/Makefile.in b/servers/slapd/tools/Makefile.in index 4cf42801d8..fdeb1de3a9 100644 --- a/servers/slapd/tools/Makefile.in +++ b/servers/slapd/tools/Makefile.in @@ -33,21 +33,17 @@ XXXLIBS = $(MODULES_LIBS) $(LTHREAD_LIBS) PROGRAMS=slapadd slapcat slapindex slappasswd -# CPPFLAGS will include the defines for dynamic libs in Mingw32. -NT_DYN_DEFS = -DLBER_DECL=dllimport -DLDAP_DECL=dllimport -CPPFLAGS = $(@PLAT@_@LIB_LINKAGE@_DEFS) - SRCS = mimic.c slapcommon.c \ slapadd.c slapcat.c slapindex.c slappasswd.c SLAPD_OBJS = ../config.o ../ch_malloc.o ../backend.o ../charray.o \ - ../module.o ../aclparse.o ../filterentry.o \ - ../schema.o ../schema_check.o ../schema_init.o ../schema_prep.o \ - ../schemaparse.o ../ad.o ../at.o ../mr.o ../oc.o ../syntax.o \ - ../acl.o ../phonetic.o ../attr.o ../value.o ../entry.o \ - ../dn.o ../filter.o ../str2filter.o ../ava.o ../init.o \ - ../controls.o ../kerberos.o ../passwd.o ../index.o \ - ../extended.o ../starttls.o ../sets.o ../mra.o \ + ../module.o ../aclparse.o ../filterentry.o ../schema.o \ + ../schema_check.o ../schema_init.o ../schema_prep.o \ + ../schemaparse.o ../ad.o ../at.o ../mr.o ../oc.o \ + ../syntax.o ../acl.o ../phonetic.o ../attr.o ../value.o \ + ../entry.o ../dn.o ../filter.o ../str2filter.o ../ava.o \ + ../init.o ../controls.o ../kerberos.o ../passwd.o \ + ../index.o ../extended.o ../starttls.o ../sets.o ../mra.o \ ../referral.o SLAPOBJS = $(SLAPD_OBJS) slapcommon.o mimic.o