3 ## Makefile.in for slapd
6 XPROGRAMS=sslapd libbackends.a .backend
10 NT_OBJS = nt_svc.o ../../libraries/liblutil/slapdmsg.res
12 SRCS = main.c globals.c config.c daemon.c \
13 connection.c search.c filter.c add.c cr.c \
14 attr.c entry.c backend.c result.c operation.c \
15 dn.c compare.c modify.c delete.c modrdn.c ch_malloc.c \
16 value.c ava.c bind.c unbind.c abandon.c filterentry.c \
17 phonetic.c acl.c str2filter.c aclparse.c init.c user.c \
18 repl.c lock.c controls.c extended.c kerberos.c passwd.c \
19 schema.c schema_check.c schema_init.c schema_prep.c \
20 schemaparse.c ad.c at.c mr.c syntax.c oc.c saslauthz.c \
21 oidm.c starttls.c index.c sets.c referral.c \
22 root_dse.c sasl.c module.c mra.c mods.c \
23 limits.c backglue.c operational.c matchedValues.c cancel.c \
26 OBJS = main.o globals.o config.o daemon.o \
27 connection.o search.o filter.o add.o cr.o \
28 attr.o entry.o backend.o result.o operation.o \
29 dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \
30 value.o ava.o bind.o unbind.o abandon.o filterentry.o \
31 phonetic.o acl.o str2filter.o aclparse.o init.o user.o \
32 repl.o lock.o controls.o extended.o kerberos.o passwd.o \
33 schema.o schema_check.o schema_init.o schema_prep.o \
34 schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o \
35 oidm.o starttls.o index.o sets.o referral.o \
36 root_dse.o sasl.o module.o mra.o mods.o \
37 limits.o backglue.o operational.o matchedValues.o cancel.o \
40 LDAP_INCDIR= ../../include -I$(srcdir)/slapi
41 LDAP_LIBDIR= ../../libraries
44 SLAPD_STATIC_DEPENDS=@SLAPD_NO_STATIC@ libbackends.a
45 SLAPD_STATIC_BACKENDS=@SLAPD_STATIC_BACKENDS@
46 SLAPD_DYNAMIC_BACKENDS=@SLAPD_DYNAMIC_BACKENDS@
48 XDEFS = $(MODULES_CPPFLAGS)
49 XLDFLAGS = $(MODULES_LDFLAGS)
51 XLIBS = $(SLAPD_STATIC_DEPENDS) $(SLAPD_L)
52 XXLIBS = $(LDBM_LIBS) $(SLAPD_LIBS) $(SECURITY_LIBS) $(LDIF_LIBS) $(LUTIL_LIBS)
53 XXXLIBS = $(LTHREAD_LIBS) $(SLAPI_LIBS) @LIBSLAPI@ $(MODULES_LIBS)
55 BUILD_OPT = "--enable-slapd"
56 BUILD_SRV = @BUILD_SLAPD@
58 all-local-srv: all-cffiles
60 NT_SLAPD_DEPENDS = slapd.exp
61 NT_SLAPD_OBJECTS = slapd.exp symdummy.o $(OBJS) version.o
63 UNIX_SLAPD_DEPENDS = $(SLAPD_STATIC_DEPENDS) version.o $(SLAPD_L)
64 UNIX_SLAPD_OBJECTS = $(OBJS) version.o
66 SLAPD_DEPENDS = $(@PLAT@_SLAPD_DEPENDS)
67 SLAPD_OBJECTS = $(@PLAT@_SLAPD_OBJECTS)
69 # Notes about slapd for Windows
70 # =============================
71 # slapd.exe must export all of its global symbols, just like a DLL.
72 # The purpose of this is to allow dynamic modules (dynamic backends
73 # or external dynamic modules) to bind with the symbols at run-time.
75 # Exporting symbols from an .EXE is a bit tricky and involves multiple
76 # steps. First a .DEF file must be generated. The .DEF file indicates
77 # the set of symbols that are to be exported. Many times, it's possible
78 # to manually create this file with an editor. However, with slapd,
79 # we want to export EVERY global symbol that it knows about (NOT including
80 # symbols that are imported from other DLLs). The set of symbols to
81 # export INCLUDES symbols from all static libraries that slapd gets
82 # linked with, e.g. avl, ldbm, ldif, lunicode, lutil, etc. This list
83 # will also include liblber and libldap_r if they were built as static
84 # libraries. ALSO included will be symbols from other STATIC libraries
85 # outside the domain of the OpenLDAP source tree, e.g. regex, ltdl,
86 # crypto, ssl, sasl, etc. (If these libraries are dynamic, we won't want
87 # to include their symbols in the list). The correct set of symbols
88 # CAN be determined at build time. The slapd.def target automatically
89 # determines the correct set of symbols and generates the slapd.def file.
91 # The slapd.def file, serving multiple purposes, will:
93 # 1) be used to generate libslapd.a, the import library for slapd.exe.
95 # 2) be used to generate the symdummy.c file.
97 # 3) be used to help create slapd.exp, the binary-formated slapd export file.
99 # The import library is used by dynamic modules at link time. With this
100 # library, dynamic modules indicate to the linker that it will resolve
101 # these symbols from the slapd.exe binary at run-time. Of course, whenever
102 # a module imports dynamic symbols, those symbols should be marked with
103 # the __declspec(dllimport) directive in the header files that the dynamic
104 # modules build with. In OpenLDAP, this is handled automatically in the
105 # header files. (See ldap_cdefs.h for an explanation). Writers of
106 # dynamic backend modules should keep in mind that slapd.exe might export
107 # other global symbols that are not part of OpenLDAP (e.g. regex, ltdl,
108 # crypto, ssl, sasl, etc.) When a writer actually uses (i.e. imports) these
109 # symbols, he must verify that the header files from these external packages
110 # include a mechanism to mark imported symbols with the __declspec(dllimport)
111 # directive. Whether or not such a mechanism exists, the writer must be
112 # able to include these directives appropriately when their symbols are
113 # being imported from slapd.exe. The directive is not completely necessary
114 # for functions, but it is required for variables.
116 # The symdummy.c file basically references EVERY symbol available to slapd.exe,
117 # including symbols that slapd.exe never actually refereneced. The file
118 # is compiled and included at link time. Without this object file, slapd.exe
119 # would NOT export symbols that it never referenced. The reason that these
120 # symbols must still be exported is because a dynamic module may want to
121 # use a symbol even if it had not been referenced by slapd.exe.
125 # slapd.def REALLY depends upon all slapd objects and all static libraries
126 # included in $(LIBS), including static libraries outside of OpenLDAP.
127 # When slapd.def is built, the absolute paths to all static libraries
128 # (both inside and outside of OpenLDAP) are generated. We don't have
129 # any way to include this generated list as a dependency of slapd.def (sigh).
130 # Thus, we do the best we can by depending on version.o, which depends
131 # on its own very long list of dependencies.
133 slapd.def: libbackends.a version.o
134 @for i in $(LDFLAGS) ; do \
135 path=`expr "$$i" : "-L\(.*\)"`; \
136 if test $$? != 0; then continue; fi; \
137 paths="$$paths $$path"; \
140 for i in $(OBJS) version.o $(LIBS) ; do \
145 base=`expr "$$i" : "-l\(.*\)"`; \
146 for p in $$paths ; do \
147 for ext in la dll a ; do \
148 path=$$p/lib$$base.$$ext; \
149 test ! -f $$path && continue; \
150 if test $$ext = la ; then \
151 for t in dlname old_library ; do \
152 line=`grep "^$$t=" $$path`; \
153 lib=`expr "$$line" : "[^']*'\(.*\)'"`; \
154 test -n "$$lib" && test -f $$p/$$lib && \
155 path=$$p/$$lib && break; \
157 test $$t = dlname && ext=dll; \
158 test $$t = old_library && ext=a; \
160 if test $$ext = a ; then \
166 test -n "$$done" && break; \
168 test -z "$$obj" && continue; \
173 objs="$$objs $$obj"; \
175 echo dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
176 --output-def $@.tmp $$objs; \
177 dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
178 --output-def $@.tmp $$objs;
180 $(SED) -e 1,2d -e 's/ @ [0-9][0-9]*//' $@.tmp | sort >> $@
183 symdummy.c: slapd.def
185 @echo "generating $@..."; \
186 echo "static void never_called() {" > $@.tmp; \
187 cat $< | while read line; \
192 echo "int $$2();" >> $@; \
193 echo "$$2();" >> $@.tmp; \
196 echo "extern int $$2;" >> $@; \
197 echo "$$2 = 0;" >> $@.tmp; \
202 echo "}" >> $@.tmp; \
206 libslapd.a: symdummy.o
207 dlltool --dllname slapd.exe --input-def slapd.def --output-lib $@
209 slapd.exp: libslapd.a
210 @echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
211 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
212 $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
213 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
215 @echo dlltool --dllname slapd.exe --input-def slapd.def \
216 --base-file slapd.base --output-exp $@; \
217 dlltool --dllname slapd.exe --input-def slapd.def \
218 --base-file slapd.base --output-exp $@; \
219 echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
220 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
221 $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
222 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
224 @echo dlltool --dllname slapd.exe --input-def slapd.def \
225 --base-file slapd.base --output-exp $@; \
226 dlltool --dllname slapd.exe --input-def slapd.def \
227 --base-file slapd.base --output-exp $@
230 (cd slapi; $(MAKE) $(MFLAGS) all)
231 cp slapi/.libs/libslapi.a .
233 .slapi: $(SLAPD_OBJECTS)
234 $(AR) ruv slapi/libtmpslapd.a $(OBJS)
235 (cd slapi; $(MAKE) $(MFLAGS) all)
237 slapd: $(SLAPD_DEPENDS) @LIBSLAPI@
238 $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) \
242 $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS)
244 tools $(SLAPD_DYNAMIC_BACKENDS): slapd
245 cd $@; $(MAKE) $(MFLAGS) all
249 # In Windows, dynamic backends have to be built after slapd. For this
250 # reason, we only build static backends now and dynamic backends later.
253 @if test -n "$(SLAPD_STATIC_BACKENDS)"; then \
254 echo "building static backends..."; \
255 for i in XX $(SLAPD_STATIC_BACKENDS); do \
256 if test $$i != XX; then \
257 echo " "; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \
258 ( cd $$i; $(MAKE) $(MFLAGS) all ); \
259 if test $$? != 0; then exit 1; fi; \
265 libbackends.a: .backend
268 @-for i in back-*/*.a; do \
272 pre=`echo $$i | $(SED) -e 's/\/.*$$//' -e 's/back-//'`; \
276 $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \
277 $(RM) *.o __.SYMDEF ________64ELEL_ ; \
278 echo "added backend library $$i"; \
282 @mv -f tmp/libbackends.a ./libbackends.a
284 @if test ! -z "$(RANLIB)" ; then \
285 $(RANLIB) libbackends.a; \
287 @ls -l libbackends.a; echo ""
289 version.c: $(OBJS) $(SLAPD_LIBDEPEND)
291 $(MKVERSION) -s -n Versionstr slapd > $@
293 depend-local-srv: FORCE
294 @for i in back-* shell-backends slapi tools; do \
295 if test -d $$i -a -f $$i/Makefile ; then \
296 echo; echo " cd $$i; $(MAKE) $(MFLAGS) depend"; \
297 ( cd $$i; $(MAKE) $(MFLAGS) depend ); \
298 if test $$? != 0 ; then exit 1; fi ; \
304 rm -f *.exp *.def *.base *.a *.objs symdummy.c
306 clean-local-srv: FORCE
307 @for i in back-* shell-backends slapi tools; do \
308 if test -d $$i -a -f $$i/Makefile ; then \
309 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
310 ( cd $$i; $(MAKE) $(MFLAGS) clean ); \
311 if test $$? != 0 ; then exit 1; fi ; \
314 rm -f *.tmp all-cffiles
316 veryclean-local-srv: FORCE
317 @for i in back-* shell-backends slapi tools; do \
318 if test -d $$i -a -f $$i/Makefile ; then \
319 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
320 ( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \
324 install-local-srv: install-slapd install-conf install-schema install-tools
327 -$(MKDIR) $(DESTDIR)$(libexecdir)
328 -$(MKDIR) $(DESTDIR)$(localstatedir)
329 $(LTINSTALL) $(INSTALLFLAGS) -s -m 755 \
330 slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
331 @for i in back-* shell-backends slapi tools; do \
332 if test -d $$i -a -f $$i/Makefile ; then \
333 echo; echo " cd $$i; $(MAKE) $(MFLAGS) install"; \
334 ( cd $$i; $(MAKE) $(MFLAGS) install ); \
335 if test $$? != 0 ; then exit 1; fi ; \
339 all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS) tools
340 @if test $(PLAT) = NT; then \
341 sysconfdir=`cygpath -w $(sysconfdir) | \
342 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
343 localstatedir=`cygpath -w $(localstatedir) | \
344 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
345 moduledir=`cygpath -w $(moduledir) | \
346 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
348 sysconfdir=$(sysconfdir); \
349 localstatedir=$(localstatedir); \
350 moduledir=$(moduledir); \
352 $(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \
353 -e "s;%LOCALSTATEDIR%;$$localstatedir;" \
354 -e "s;%MODULEDIR%;$$moduledir;" \
355 $(srcdir)/slapd.conf > slapd.conf.tmp ; \
358 install-schema: FORCE
359 @-$(MKDIR) $(DESTDIR)$(schemadir)
360 for i in $(srcdir)/schema/*.schema ; do \
361 SF=`basename $$i` ; \
362 SD="$(DESTDIR)$(schemadir)/$$SF" ; \
363 if test ! -f $$SD ; then \
364 echo "installing $$SF in $(schemadir)" ; \
365 echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
366 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
368 echo "PRESERVING EXISTING SCHEMA FILE $$SD" ; \
370 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD.default ; \
374 @-$(MKDIR) $(DESTDIR)$(sysconfdir)
375 @-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data
376 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf.default
377 if test ! -f $(DESTDIR)$(sysconfdir)/slapd.conf; then \
378 echo "installing slapd.conf in $(sysconfdir)"; \
379 echo "$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \
380 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \
382 echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.conf" ; \
386 @-$(MKDIR) $(DESTDIR)$(sbindir)
387 (cd tools; $(MAKE) $(MFLAGS) install)