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 daemon.c connection.c search.c filter.c add.c charray.c \
13 attr.c entry.c config.c backend.c result.c operation.c \
14 dn.c compare.c modify.c delete.c modrdn.c ch_malloc.c \
15 value.c ava.c bind.c unbind.c abandon.c filterentry.c \
16 phonetic.c acl.c str2filter.c aclparse.c init.c user.c \
17 repl.c lock.c controls.c extended.c kerberos.c passwd.c \
18 schema.c schema_check.c schema_init.c schema_prep.c \
19 schemaparse.c ad.c at.c mr.c syntax.c oc.c saslauthz.c \
20 oidm.c starttls.c index.c sets.c referral.c \
21 root_dse.c sasl.c module.c suffixalias.c mra.c mods.c \
22 limits.c backglue.c operational.c matchedValues.c \
25 OBJS = main.o daemon.o connection.o search.o filter.o add.o charray.o \
26 attr.o entry.o config.o backend.o result.o operation.o \
27 dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \
28 value.o ava.o bind.o unbind.o abandon.o filterentry.o \
29 phonetic.o acl.o str2filter.o aclparse.o init.o user.o \
30 repl.o lock.o controls.o extended.o kerberos.o passwd.o \
31 schema.o schema_check.o schema_init.o schema_prep.o \
32 schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o \
33 oidm.o starttls.o index.o sets.o referral.o \
34 root_dse.o sasl.o module.o suffixalias.o mra.o mods.o \
35 limits.o backglue.o operational.o matchedValues.o \
38 LDAP_INCDIR= ../../include
39 LDAP_LIBDIR= ../../libraries
42 SLAPD_STATIC_BACKENDS=@SLAPD_STATIC_BACKENDS@
43 SLAPD_DYNAMIC_BACKENDS=@SLAPD_DYNAMIC_BACKENDS@
45 XDEFS = $(MODULES_CPPFLAGS)
46 XLDFLAGS = $(MODULES_LDFLAGS)
48 XLIBS = libbackends.a $(SLAPD_L)
49 XXLIBS = $(LDBM_LIBS) $(SLAPD_LIBS) $(SECURITY_LIBS) $(LDIF_LIBS) $(LUTIL_LIBS)
50 XXXLIBS = $(LTHREAD_LIBS) $(MODULES_LIBS)
52 BUILD_OPT = "--enable-slapd"
53 BUILD_SRV = @BUILD_SLAPD@
55 all-local-srv: all-cffiles
57 NT_SLAPD_DEPENDS = slapd.exp
58 NT_SLAPD_OBJECTS = slapd.exp symdummy.o $(OBJS) version.o
60 UNIX_SLAPD_DEPENDS = libbackends.a version.o $(SLAPD_L)
61 UNIX_SLAPD_OBJECTS = $(OBJS) version.o
63 SLAPD_DEPENDS = $(@PLAT@_SLAPD_DEPENDS)
64 SLAPD_OBJECTS = $(@PLAT@_SLAPD_OBJECTS)
66 # Notes about slapd for Windows
67 # =============================
68 # slapd.exe must export all of its global symbols, just like a DLL.
69 # The purpose of this is to allow dynamic modules (dynamic backends
70 # or external dynamic modules) to bind with the symbols at run-time.
72 # Exporting symbols from an .EXE is a bit tricky and involves multiple
73 # steps. First a .DEF file must be generated. The .DEF file indicates
74 # the set of symbols that are to be exported. Many times, it's possible
75 # to manually create this file with an editor. However, with slapd,
76 # we want to export EVERY global symbol that it knows about (NOT including
77 # symbols that are imported from other DLLs). The set of symbols to
78 # export INCLUDES symbols from all static libraries that slapd gets
79 # linked with, e.g. avl, ldbm, ldif, lunicode, lutil, etc. This list
80 # will also include liblber and libldap_r if they were built as static
81 # libraries. ALSO included will be symbols from other STATIC libraries
82 # outside the domain of the OpenLDAP source tree, e.g. regex, ltdl,
83 # crypto, ssl, sasl, etc. (If these libraries are dynamic, we won't want
84 # to include their symbols in the list). The correct set of symbols
85 # CAN be determined at build time. The slapd.def target automatically
86 # determines the correct set of symbols and generates the slapd.def file.
88 # The slapd.def file, serving multiple purposes, will:
90 # 1) be used to generate libslapd.a, the import library for slapd.exe.
92 # 2) be used to generate the symdummy.c file.
94 # 3) be used to help create slapd.exp, the binary-formated slapd export file.
96 # The import library is used by dynamic modules at link time. With this
97 # library, dynamic modules indicate to the linker that it will resolve
98 # these symbols from the slapd.exe binary at run-time. Of course, whenever
99 # a module imports dynamic symbols, those symbols should be marked with
100 # the __declspec(dllimport) directive in the header files that the dynamic
101 # modules build with. In OpenLDAP, this is handled automatically in the
102 # header files. (See ldap_cdefs.h for an explanation). Writers of
103 # dynamic backend modules should keep in mind that slapd.exe might export
104 # other global symbols that are not part of OpenLDAP (e.g. regex, ltdl,
105 # crypto, ssl, sasl, etc.) When a writer actually uses (i.e. imports) these
106 # symbols, he must verify that the header files from these external packages
107 # include a mechanism to mark imported symbols with the __declspec(dllimport)
108 # directive. Whether or not such a mechanism exists, the writer must be
109 # able to include these directives appropriately when their symbols are
110 # being imported from slapd.exe. The directive is not completely necessary
111 # for functions, but it is required for variables.
113 # The symdummy.c file basically references EVERY symbol available to slapd.exe,
114 # including symbols that slapd.exe never actually refereneced. The file
115 # is compiled and included at link time. Without this object file, slapd.exe
116 # would NOT export symbols that it never referenced. The reason that these
117 # symbols must still be exported is because a dynamic module may want to
118 # use a symbol even if it had not been referenced by slapd.exe.
122 # slapd.def REALLY depends upon all slapd objects and all static libraries
123 # included in $(LIBS), including static libraries outside of OpenLDAP.
124 # When slapd.def is built, the absolute paths to all static libraries
125 # (both inside and outside of OpenLDAP) are generated. We don't have
126 # any way to include this generated list as a dependency of slapd.def (sigh).
127 # Thus, we do the best we can by depending on version.o, which depends
128 # on its own very long list of dependencies.
130 slapd.def: libbackends.a version.o
131 @for i in $(LDFLAGS) ; do \
132 path=`expr "$$i" : "-L\(.*\)"`; \
133 if test $$? != 0; then continue; fi; \
134 paths="$$paths $$path"; \
137 for i in $(OBJS) version.o $(LIBS) ; do \
142 base=`expr "$$i" : "-l\(.*\)"`; \
143 for p in $$paths ; do \
144 for ext in la dll a ; do \
145 path=$$p/lib$$base.$$ext; \
146 test ! -f $$path && continue; \
147 if test $$ext = la ; then \
148 for t in dlname old_library ; do \
149 line=`grep "^$$t=" $$path`; \
150 lib=`expr "$$line" : "[^']*'\(.*\)'"`; \
151 test -n "$$lib" && test -f $$p/$$lib && \
152 path=$$p/$$lib && break; \
154 test $$t = dlname && ext=dll; \
155 test $$t = old_library && ext=a; \
157 if test $$ext = a ; then \
163 test -n "$$done" && break; \
165 test -z "$$obj" && continue; \
170 objs="$$objs $$obj"; \
172 echo dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
173 --output-def $@.tmp $$objs; \
174 dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
175 --output-def $@.tmp $$objs;
177 $(SED) -e 1,2d -e 's/ @ [0-9][0-9]*//' $@.tmp | sort >> $@
180 symdummy.c: slapd.def
182 @echo "generating $@..."; \
183 echo "static void never_called() {" > $@.tmp; \
184 cat $< | while read line; \
189 echo "int $$2();" >> $@; \
190 echo "$$2();" >> $@.tmp; \
193 echo "extern int $$2;" >> $@; \
194 echo "$$2 = 0;" >> $@.tmp; \
199 echo "}" >> $@.tmp; \
203 libslapd.a: symdummy.o
204 dlltool --dllname slapd.exe --input-def slapd.def --output-lib $@
206 slapd.exp: libslapd.a
207 @echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
208 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
209 $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
210 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
212 @echo dlltool --dllname slapd.exe --input-def slapd.def \
213 --base-file slapd.base --output-exp $@; \
214 dlltool --dllname slapd.exe --input-def slapd.def \
215 --base-file slapd.base --output-exp $@; \
216 echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
217 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
218 $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
219 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
221 @echo dlltool --dllname slapd.exe --input-def slapd.def \
222 --base-file slapd.base --output-exp $@; \
223 dlltool --dllname slapd.exe --input-def slapd.def \
224 --base-file slapd.base --output-exp $@
226 slapd: $(SLAPD_DEPENDS)
227 $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) $(WRAP_LIBS)
228 @if test -n "$(SLAPD_DYNAMIC_BACKENDS)"; then \
229 echo "building dynamic backends..."; \
230 for i in XX $(SLAPD_DYNAMIC_BACKENDS); do \
231 if test $$i != XX; then \
232 echo " "; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \
233 ( cd $$i; $(MAKE) $(MFLAGS) all ); \
234 if test $$? != 0; then exit 1; fi; \
239 cd tools; $(MAKE) $(MFLAGS) all
242 $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS)
245 # In Windows, dynamic backends have to be built after slapd. For this
246 # reason, we only build static backends now and dynamic backends later.
249 @if test -n "$(SLAPD_STATIC_BACKENDS)"; then \
250 echo "building static backends..."; \
251 for i in XX $(SLAPD_STATIC_BACKENDS); do \
252 if test $$i != XX; then \
253 echo " "; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \
254 ( cd $$i; $(MAKE) $(MFLAGS) all ); \
255 if test $$? != 0; then exit 1; fi; \
261 libbackends.a: .backend
264 @-for i in back-*/*.a; do \
268 pre=`echo $$i | $(SED) -e 's/\/.*$$//' -e 's/back-//'`; \
272 $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \
273 $(RM) *.o __.SYMDEF ________64ELEL_ ; \
274 echo "added backend library $$i"; \
278 @mv -f tmp/libbackends.a ./libbackends.a
280 @if test ! -z "$(RANLIB)" ; then \
281 $(RANLIB) libbackends.a; \
283 @ls -l libbackends.a; echo ""
285 version.c: $(OBJS) $(SLAPD_LIBDEPEND)
287 $(MKVERSION) -s -n Versionstr slapd > $@
289 depend-local-srv: FORCE
290 @for i in back-* shell-backends tools; do \
291 if test -d $$i -a -f $$i/Makefile ; then \
292 echo; echo " cd $$i; $(MAKE) $(MFLAGS) depend"; \
293 ( cd $$i; $(MAKE) $(MFLAGS) depend ); \
294 if test $$? != 0 ; then exit 1; fi ; \
300 rm -f *.exp *.def *.base *.a *.objs symdummy.c
302 clean-local-srv: FORCE
303 @for i in back-* shell-backends tools; do \
304 if test -d $$i -a -f $$i/Makefile ; then \
305 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
306 ( cd $$i; $(MAKE) $(MFLAGS) clean ); \
307 if test $$? != 0 ; then exit 1; fi ; \
310 rm -f *.tmp all-cffiles
312 veryclean-local-srv: FORCE
313 @for i in back-* shell-backends tools; do \
314 if test -d $$i -a -f $$i/Makefile ; then \
315 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
316 ( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \
320 install-local-srv: install-slapd install-conf install-schema install-tools
323 -$(MKDIR) $(DESTDIR)$(libexecdir)
324 -$(MKDIR) $(DESTDIR)$(localstatedir)
325 $(LTINSTALL) $(INSTALLFLAGS) -s -m 755 \
326 slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
327 @for i in back-* shell-backends tools; do \
328 if test -d $$i -a -f $$i/Makefile ; then \
329 echo; echo " cd $$i; $(MAKE) $(MFLAGS) install"; \
330 ( cd $$i; $(MAKE) $(MFLAGS) install ); \
331 if test $$? != 0 ; then exit 1; fi ; \
336 @if test $(PLAT) = NT; then \
337 sysconfdir=`cygpath -w $(sysconfdir) | \
338 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
339 localstatedir=`cygpath -w $(localstatedir) | \
340 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
341 moduledir=`cygpath -w $(moduledir) | \
342 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
344 sysconfdir=$(sysconfdir); \
345 localstatedir=$(localstatedir); \
346 moduledir=$(moduledir); \
348 $(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \
349 -e "s;%LOCALSTATEDIR%;$$localstatedir;" \
350 -e "s;%MODULEDIR%;$$moduledir;" \
351 $(srcdir)/slapd.conf > slapd.conf.tmp ; \
354 install-schema: FORCE
355 @-$(MKDIR) $(DESTDIR)$(schemadir)
356 for i in $(srcdir)/schema/*.schema ; do \
357 SF=`basename $$i` ; \
358 SD="$(DESTDIR)$(schemadir)/$$SF" ; \
359 if test ! -f $$SD ; then \
360 echo "installing $$SF in $(schemadir)" ; \
361 echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
362 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
364 echo "PRESERVING EXISTING SCHEMA FILE $$SD" ; \
366 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD.default ; \
370 @-$(MKDIR) $(DESTDIR)$(sysconfdir)
371 @-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data
372 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf.default
373 if test ! -f $(DESTDIR)$(sysconfdir)/slapd.conf; then \
374 echo "installing slapd.conf in $(sysconfdir)"; \
375 echo "$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \
376 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \
378 echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.conf" ; \
382 @-$(MKDIR) $(DESTDIR)$(sbindir)
383 (cd tools; $(MAKE) $(MFLAGS) install)