1 ## Makefile.in for slapd
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2004 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 SLAPTOOLS=slapadd slapcat slapindex slappasswd
17 PROGRAMS=slapd $(SLAPTOOLS)
18 XPROGRAMS=sslapd libbackends.a .backend liboverlays.a
21 SUBDIRS=back-* shell-backends slapi overlays
24 NT_OBJS = nt_svc.o ../../libraries/liblutil/slapdmsg.res
26 SRCS = main.c globals.c config.c daemon.c \
27 connection.c search.c filter.c add.c cr.c \
28 attr.c entry.c backend.c result.c operation.c \
29 dn.c compare.c modify.c delete.c modrdn.c ch_malloc.c \
30 value.c ava.c bind.c unbind.c abandon.c filterentry.c \
31 phonetic.c acl.c str2filter.c aclparse.c init.c user.c \
32 repl.c lock.c controls.c extended.c kerberos.c passwd.c \
33 schema.c schema_check.c schema_init.c schema_prep.c \
34 schemaparse.c ad.c at.c mr.c syntax.c oc.c saslauthz.c \
35 oidm.c starttls.c index.c sets.c referral.c root_dse.c \
36 sasl.c module.c mra.c mods.c sl_malloc.c limits.c \
37 backglue.c operational.c matchedValues.c cancel.c syncrepl.c \
38 slapadd.c slapcat.c slapcommon.c slapindex.c slappasswd.c \
39 backover.c ctxcsn.c ldapsync.c sessionlog.c $(@PLAT@_SRCS)
41 OBJS = main.o globals.o config.o daemon.o \
42 connection.o search.o filter.o add.o cr.o \
43 attr.o entry.o backend.o result.o operation.o \
44 dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \
45 value.o ava.o bind.o unbind.o abandon.o filterentry.o \
46 phonetic.o acl.o str2filter.o aclparse.o init.o user.o \
47 repl.o lock.o controls.o extended.o kerberos.o passwd.o \
48 schema.o schema_check.o schema_init.o schema_prep.o \
49 schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o \
50 oidm.o starttls.o index.o sets.o referral.o root_dse.o \
51 sasl.o module.o mra.o mods.o sl_malloc.o limits.o \
52 backglue.o operational.o matchedValues.o cancel.o syncrepl.o \
53 slapadd.o slapcat.o slapcommon.o slapindex.o slappasswd.o \
54 backover.o ctxcsn.o ldapsync.o sessionlog.o $(@PLAT@_OBJS)
56 LDAP_INCDIR= ../../include -I$(srcdir)/slapi
57 LDAP_LIBDIR= ../../libraries
60 SLAPD_STATIC_DEPENDS=@SLAPD_NO_STATIC@ libbackends.a
61 SLAPD_STATIC_BACKENDS=@SLAPD_STATIC_BACKENDS@
62 SLAPD_DYNAMIC_BACKENDS=@SLAPD_DYNAMIC_BACKENDS@
64 SLAPI_LIBS=@LIBSLAPI@ @SLAPI_LIBS@
66 XDEFS = $(MODULES_CPPFLAGS)
67 XLDFLAGS = $(MODULES_LDFLAGS)
69 XLIBS = $(SLAPD_STATIC_DEPENDS) $(SLAPD_L) liboverlays.a
70 XXLIBS = $(LDBM_LIBS) $(SLAPD_LIBS) $(SECURITY_LIBS) $(LUTIL_LIBS)
71 XXXLIBS = $(LTHREAD_LIBS) $(SLAPI_LIBS) $(MODULES_LIBS)
73 BUILD_OPT = "--enable-slapd"
74 BUILD_SRV = @BUILD_SLAPD@
76 all-local-srv: all-cffiles
78 NT_SLAPD_DEPENDS = slapd.exp
79 NT_SLAPD_OBJECTS = slapd.exp symdummy.o $(OBJS) version.o
81 UNIX_SLAPD_DEPENDS = $(SLAPD_STATIC_DEPENDS) version.o $(SLAPD_L)
82 UNIX_SLAPD_OBJECTS = $(OBJS) version.o
84 SLAPD_DEPENDS = liboverlays.a $(@PLAT@_SLAPD_DEPENDS)
85 SLAPD_OBJECTS = $(@PLAT@_SLAPD_OBJECTS)
87 # Notes about slapd for Windows
88 # =============================
89 # slapd.exe must export all of its global symbols, just like a DLL.
90 # The purpose of this is to allow dynamic modules (dynamic backends
91 # or external dynamic modules) to bind with the symbols at run-time.
93 # Exporting symbols from an .EXE is a bit tricky and involves multiple
94 # steps. First a .DEF file must be generated. The .DEF file indicates
95 # the set of symbols that are to be exported. Many times, it's possible
96 # to manually create this file with an editor. However, with slapd,
97 # we want to export EVERY global symbol that it knows about (NOT including
98 # symbols that are imported from other DLLs). The set of symbols to
99 # export INCLUDES symbols from all static libraries that slapd gets
100 # linked with, e.g. avl, ldbm, lunicode, lutil, etc. This list
101 # will also include liblber and libldap_r if they were built as static
102 # libraries. ALSO included will be symbols from other STATIC libraries
103 # outside the domain of the OpenLDAP source tree, e.g. regex, ltdl,
104 # crypto, ssl, sasl, etc. (If these libraries are dynamic, we won't want
105 # to include their symbols in the list). The correct set of symbols
106 # CAN be determined at build time. The slapd.def target automatically
107 # determines the correct set of symbols and generates the slapd.def file.
109 # The slapd.def file, serving multiple purposes, will:
111 # 1) be used to generate libslapd.a, the import library for slapd.exe.
113 # 2) be used to generate the symdummy.c file.
115 # 3) be used to help create slapd.exp, the binary-formated slapd export file.
117 # The import library is used by dynamic modules at link time. With this
118 # library, dynamic modules indicate to the linker that it will resolve
119 # these symbols from the slapd.exe binary at run-time. Of course, whenever
120 # a module imports dynamic symbols, those symbols should be marked with
121 # the __declspec(dllimport) directive in the header files that the dynamic
122 # modules build with. In OpenLDAP, this is handled automatically in the
123 # header files. (See ldap_cdefs.h for an explanation). Writers of
124 # dynamic backend modules should keep in mind that slapd.exe might export
125 # other global symbols that are not part of OpenLDAP (e.g. regex, ltdl,
126 # crypto, ssl, sasl, etc.) When a writer actually uses (i.e. imports) these
127 # symbols, he must verify that the header files from these external packages
128 # include a mechanism to mark imported symbols with the __declspec(dllimport)
129 # directive. Whether or not such a mechanism exists, the writer must be
130 # able to include these directives appropriately when their symbols are
131 # being imported from slapd.exe. The directive is not completely necessary
132 # for functions, but it is required for variables.
134 # The symdummy.c file basically references EVERY symbol available to slapd.exe,
135 # including symbols that slapd.exe never actually refereneced. The file
136 # is compiled and included at link time. Without this object file, slapd.exe
137 # would NOT export symbols that it never referenced. The reason that these
138 # symbols must still be exported is because a dynamic module may want to
139 # use a symbol even if it had not been referenced by slapd.exe.
143 # slapd.def REALLY depends upon all slapd objects and all static libraries
144 # included in $(LIBS), including static libraries outside of OpenLDAP.
145 # When slapd.def is built, the absolute paths to all static libraries
146 # (both inside and outside of OpenLDAP) are generated. We don't have
147 # any way to include this generated list as a dependency of slapd.def (sigh).
148 # Thus, we do the best we can by depending on version.o, which depends
149 # on its own very long list of dependencies.
151 slapd.def: libbackends.a liboverlays.a version.o
152 @for i in $(LDFLAGS) ; do \
153 path=`expr "$$i" : "-L\(.*\)"`; \
154 if test $$? != 0; then continue; fi; \
155 paths="$$paths $$path"; \
158 for i in $(OBJS) version.o $(LIBS) ; do \
163 base=`expr "$$i" : "-l\(.*\)"`; \
164 for p in $$paths ; do \
165 for ext in la dll a ; do \
166 path=$$p/lib$$base.$$ext; \
167 test ! -f $$path && continue; \
168 if test $$ext = la ; then \
169 for t in dlname old_library ; do \
170 line=`grep "^$$t=" $$path`; \
171 lib=`expr "$$line" : "[^']*'\(.*\)'"`; \
172 test -n "$$lib" && test -f $$p/$$lib && \
173 path=$$p/$$lib && break; \
175 test $$t = dlname && ext=dll; \
176 test $$t = old_library && ext=a; \
178 if test $$ext = a ; then \
184 test -n "$$done" && break; \
186 test -z "$$obj" && continue; \
191 objs="$$objs $$obj"; \
193 echo dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
194 --output-def $@.tmp $$objs; \
195 dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
196 --output-def $@.tmp $$objs;
198 $(SED) -e 1,2d -e 's/ @ [0-9][0-9]*//' $@.tmp | sort >> $@
201 symdummy.c: slapd.def
203 @echo "generating $@..."; \
204 echo "static void never_called() {" > $@.tmp; \
205 cat $< | while read line; \
210 echo "int $$2();" >> $@; \
211 echo "$$2();" >> $@.tmp; \
214 echo "extern int $$2;" >> $@; \
215 echo "$$2 = 0;" >> $@.tmp; \
220 echo "}" >> $@.tmp; \
224 libslapd.a: symdummy.o
225 dlltool --dllname slapd.exe --input-def slapd.def --output-lib $@
227 slapd.exp: libslapd.a
228 @echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
229 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
230 $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
231 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
233 @echo dlltool --dllname slapd.exe --input-def slapd.def \
234 --base-file slapd.base --output-exp $@; \
235 dlltool --dllname slapd.exe --input-def slapd.def \
236 --base-file slapd.base --output-exp $@; \
237 echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
238 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
239 $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
240 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
242 @echo dlltool --dllname slapd.exe --input-def slapd.def \
243 --base-file slapd.base --output-exp $@; \
244 dlltool --dllname slapd.exe --input-def slapd.def \
245 --base-file slapd.base --output-exp $@
247 slapi/.libs/libslapi.a: FORCE
248 (cd slapi; $(MAKE) $(MFLAGS) all)
250 libslapi.a: slapi/.libs/libslapi.a
251 cp slapi/.libs/libslapi.a .
253 slapd: $(SLAPD_DEPENDS) @LIBSLAPI@
254 $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) \
257 for i in $(SLAPTOOLS); do \
258 $(LN_S) slapd $$i; done
262 $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS)
266 # In Windows, dynamic backends have to be built after slapd. For this
267 # reason, we only build static backends now and dynamic backends later.
270 @if test -n "$(SLAPD_STATIC_BACKENDS)"; then \
271 echo "building static backends..."; \
272 for i in XX $(SLAPD_STATIC_BACKENDS); do \
273 if test $$i != XX; then \
274 echo " "; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \
275 ( cd $$i; $(MAKE) $(MFLAGS) all ); \
276 if test $$? != 0; then exit 1; fi; \
282 libbackends.a: .backend
285 @-for i in back-*/*.a; do \
289 pre=`echo $$i | $(SED) -e 's/\/.*$$//' -e 's/back-//'`; \
293 $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \
294 $(RM) *.o __.SYMDEF ________64ELEL_ ; \
295 echo "added backend library $$i"; \
299 @mv -f tmp/libbackends.a ./libbackends.a
301 @if test ! -z "$(RANLIB)" ; then \
302 $(RANLIB) libbackends.a; \
304 @ls -l libbackends.a; echo ""
307 @cd overlays; $(MAKE) $(MFLAGS) all
311 $(MKVERSION) -s -n Versionstr slapd > $@
313 version.o: version.c $(OBJS) $(SLAPD_LIBDEPEND)
315 depend-local-srv: FORCE
316 @for i in $(SUBDIRS); do \
317 if test -d $$i -a -f $$i/Makefile ; then \
318 echo; echo " cd $$i; $(MAKE) $(MFLAGS) depend"; \
319 ( cd $$i; $(MAKE) $(MFLAGS) depend ); \
320 if test $$? != 0 ; then exit 1; fi ; \
326 rm -f *.exp *.def *.base *.a *.objs symdummy.c
328 clean-local-srv: FORCE
329 @for i in $(SUBDIRS); do \
330 if test -d $$i -a -f $$i/Makefile ; then \
331 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
332 ( cd $$i; $(MAKE) $(MFLAGS) clean ); \
333 if test $$? != 0 ; then exit 1; fi ; \
336 rm -f *.tmp all-cffiles
338 veryclean-local-srv: FORCE
339 @for i in $(SUBDIRS); do \
340 if test -d $$i -a -f $$i/Makefile ; then \
341 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
342 ( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \
346 install-local-srv: install-slapd install-conf install-schema install-tools
349 -$(MKDIR) $(DESTDIR)$(libexecdir)
350 -$(MKDIR) $(DESTDIR)$(localstatedir)/run
351 $(LTINSTALL) $(INSTALLFLAGS) -s -m 755 \
352 slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
353 @for i in $(SUBDIRS); do \
354 if test -d $$i -a -f $$i/Makefile ; then \
355 echo; echo " cd $$i; $(MAKE) $(MFLAGS) install"; \
356 ( cd $$i; $(MAKE) $(MFLAGS) install ); \
357 if test $$? != 0 ; then exit 1; fi ; \
361 all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS)
362 @if test $(PLAT) = NT; then \
363 sysconfdir=`cygpath -w $(sysconfdir) | \
364 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
365 localstatedir=`cygpath -w $(localstatedir) | \
366 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
367 moduledir=`cygpath -w $(moduledir) | \
368 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
370 sysconfdir=$(sysconfdir); \
371 localstatedir=$(localstatedir); \
372 moduledir=$(moduledir); \
374 $(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \
375 -e "s;%LOCALSTATEDIR%;$$localstatedir;" \
376 -e "s;%MODULEDIR%;$$moduledir;" \
377 $(srcdir)/slapd.conf > slapd.conf.tmp ; \
380 install-schema: FORCE
381 @-$(MKDIR) $(DESTDIR)$(schemadir)
382 i="$(srcdir)/schema/README" ; \
383 SF=`basename $$i` ; \
384 SD="$(DESTDIR)$(schemadir)/$$SF" ; \
385 echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
386 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD
387 for i in $(srcdir)/schema/*.schema ; do \
388 SF=`basename $$i` ; \
389 SD="$(DESTDIR)$(schemadir)/$$SF" ; \
390 if test ! -f $$SD ; then \
391 echo "installing $$SF in $(schemadir)" ; \
392 echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
393 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
395 echo "PRESERVING EXISTING SCHEMA FILE $$SD" ; \
397 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD.default ; \
401 @-$(MKDIR) $(DESTDIR)$(sysconfdir)
402 @-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data
403 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf.default
404 if test ! -f $(DESTDIR)$(sysconfdir)/slapd.conf; then \
405 echo "installing slapd.conf in $(sysconfdir)"; \
406 echo "$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \
407 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \
409 echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.conf" ; \
413 -$(MKDIR) $(DESTDIR)$(sbindir)
414 cd $(DESTDIR)$(sbindir); rm -f $(SLAPTOOLS); \
415 for i in $(SLAPTOOLS); do \
416 $(LN_S) $(DESTDIR)$(libexecdir)/slapd $$i; done