1 ## Makefile.in for slapd
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2005 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 slapdn slapindex slappasswd slaptest slapauth slapacl
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 bconfig.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 zn_malloc.c limits.c \
37 operational.c matchedValues.c cancel.c syncrepl.c \
38 backover.c ctxcsn.c ldapsync.c frontend.c \
39 slapadd.c slapcat.c slapcommon.c slapdn.c slapindex.c \
40 slappasswd.c slaptest.c slapauth.c slapacl.c component.c \
43 OBJS = main.o globals.o bconfig.o config.o daemon.o \
44 connection.o search.o filter.o add.o cr.o \
45 attr.o entry.o backend.o backends.o result.o operation.o \
46 dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \
47 value.o ava.o bind.o unbind.o abandon.o filterentry.o \
48 phonetic.o acl.o str2filter.o aclparse.o init.o user.o \
49 repl.o lock.o controls.o extended.o kerberos.o passwd.o \
50 schema.o schema_check.o schema_init.o schema_prep.o \
51 schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o \
52 oidm.o starttls.o index.o sets.o referral.o root_dse.o \
53 sasl.o module.o mra.o mods.o sl_malloc.o zn_malloc.o limits.o \
54 operational.o matchedValues.o cancel.o syncrepl.o \
55 backover.o ctxcsn.o ldapsync.o frontend.o \
56 slapadd.o slapcat.o slapcommon.o slapdn.o slapindex.o \
57 slappasswd.o slaptest.o slapauth.o slapacl.o component.o \
60 LDAP_INCDIR= ../../include -I$(srcdir) -I$(srcdir)/slapi -I.
61 LDAP_LIBDIR= ../../libraries
64 SLAPD_STATIC_DEPENDS=@SLAPD_NO_STATIC@ libbackends.a liboverlays.a
65 SLAPD_STATIC_BACKENDS=@SLAPD_STATIC_BACKENDS@
66 SLAPD_DYNAMIC_BACKENDS=@SLAPD_DYNAMIC_BACKENDS@
68 SLAPI_LIBS=@LIBSLAPI@ @SLAPI_LIBS@
70 XDEFS = $(MODULES_CPPFLAGS)
71 XLDFLAGS = $(MODULES_LDFLAGS)
73 XLIBS = $(SLAPD_STATIC_DEPENDS) $(SLAPD_L)
74 XXLIBS = $(SLAPD_LIBS) $(SECURITY_LIBS) $(LUTIL_LIBS)
75 XXXLIBS = $(LTHREAD_LIBS) $(SLAPI_LIBS) $(MODULES_LIBS)
77 BUILD_OPT = "--enable-slapd"
78 BUILD_SRV = @BUILD_SLAPD@
80 all-local-srv: all-cffiles
82 NT_SLAPD_DEPENDS = slapd.exp
83 NT_SLAPD_OBJECTS = slapd.exp symdummy.o $(OBJS) version.o
85 UNIX_SLAPD_DEPENDS = $(SLAPD_STATIC_DEPENDS) version.o $(SLAPD_L)
86 UNIX_SLAPD_OBJECTS = $(OBJS) version.o
88 SLAPD_DEPENDS = $(@PLAT@_SLAPD_DEPENDS)
89 SLAPD_OBJECTS = $(@PLAT@_SLAPD_OBJECTS)
91 # Notes about slapd for Windows
92 # =============================
93 # slapd.exe must export all of its global symbols, just like a DLL.
94 # The purpose of this is to allow dynamic modules (dynamic backends
95 # or external dynamic modules) to bind with the symbols at run-time.
97 # Exporting symbols from an .EXE is a bit tricky and involves multiple
98 # steps. First a .DEF file must be generated. The .DEF file indicates
99 # the set of symbols that are to be exported. Many times, it's possible
100 # to manually create this file with an editor. However, with slapd,
101 # we want to export EVERY global symbol that it knows about (NOT including
102 # symbols that are imported from other DLLs). The set of symbols to
103 # export INCLUDES symbols from all static libraries that slapd gets
104 # linked with, e.g. avl, ldbm, lunicode, lutil, etc. This list
105 # will also include liblber and libldap_r if they were built as static
106 # libraries. ALSO included will be symbols from other STATIC libraries
107 # outside the domain of the OpenLDAP source tree, e.g. regex, ltdl,
108 # crypto, ssl, sasl, etc. (If these libraries are dynamic, we won't want
109 # to include their symbols in the list). The correct set of symbols
110 # CAN be determined at build time. The slapd.def target automatically
111 # determines the correct set of symbols and generates the slapd.def file.
113 # The slapd.def file, serving multiple purposes, will:
115 # 1) be used to generate libslapd.a, the import library for slapd.exe.
117 # 2) be used to generate the symdummy.c file.
119 # 3) be used to help create slapd.exp, the binary-formated slapd export file.
121 # The import library is used by dynamic modules at link time. With this
122 # library, dynamic modules indicate to the linker that it will resolve
123 # these symbols from the slapd.exe binary at run-time. Of course, whenever
124 # a module imports dynamic symbols, those symbols should be marked with
125 # the __declspec(dllimport) directive in the header files that the dynamic
126 # modules build with. In OpenLDAP, this is handled automatically in the
127 # header files. (See ldap_cdefs.h for an explanation). Writers of
128 # dynamic backend modules should keep in mind that slapd.exe might export
129 # other global symbols that are not part of OpenLDAP (e.g. regex, ltdl,
130 # crypto, ssl, sasl, etc.) When a writer actually uses (i.e. imports) these
131 # symbols, he must verify that the header files from these external packages
132 # include a mechanism to mark imported symbols with the __declspec(dllimport)
133 # directive. Whether or not such a mechanism exists, the writer must be
134 # able to include these directives appropriately when their symbols are
135 # being imported from slapd.exe. The directive is not completely necessary
136 # for functions, but it is required for variables.
138 # The symdummy.c file basically references EVERY symbol available to slapd.exe,
139 # including symbols that slapd.exe never actually refereneced. The file
140 # is compiled and included at link time. Without this object file, slapd.exe
141 # would NOT export symbols that it never referenced. The reason that these
142 # symbols must still be exported is because a dynamic module may want to
143 # use a symbol even if it had not been referenced by slapd.exe.
147 # slapd.def REALLY depends upon all slapd objects and all static libraries
148 # included in $(LIBS), including static libraries outside of OpenLDAP.
149 # When slapd.def is built, the absolute paths to all static libraries
150 # (both inside and outside of OpenLDAP) are generated. We don't have
151 # any way to include this generated list as a dependency of slapd.def (sigh).
152 # Thus, we do the best we can by depending on version.o, which depends
153 # on its own very long list of dependencies.
155 slapd.def: libbackends.a liboverlays.a version.o
156 @for i in $(LDFLAGS) ; do \
157 path=`expr "$$i" : "-L\(.*\)"`; \
158 if test $$? != 0; then continue; fi; \
159 paths="$$paths $$path"; \
162 for i in $(OBJS) version.o $(LIBS) ; do \
167 base=`expr "$$i" : "-l\(.*\)"`; \
168 for p in $$paths ; do \
169 for ext in la dll a ; do \
170 path=$$p/lib$$base.$$ext; \
171 test ! -f $$path && continue; \
172 if test $$ext = la ; then \
173 for t in dlname old_library ; do \
174 line=`grep "^$$t=" $$path`; \
175 lib=`expr "$$line" : "[^']*'\(.*\)'"`; \
176 test -n "$$lib" && test -f $$p/$$lib && \
177 path=$$p/$$lib && break; \
179 test $$t = dlname && ext=dll; \
180 test $$t = old_library && ext=a; \
182 if test $$ext = a ; then \
188 test -n "$$done" && break; \
190 test -z "$$obj" && continue; \
193 if test -n "$LTSTATIC"; then \
194 base=`expr "$$i" : ".*/\(.*\).la"`; \
195 path=`expr "$$i" : "\(.*/\).*"`; \
196 obj=$$path.libs/$$base.a; \
202 objs="$$objs $$obj"; \
204 echo dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
205 --output-def $@.tmp $$objs; \
206 dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
207 --output-def $@.tmp $$objs;
209 $(SED) -e 1,2d -e 's/ @ [0-9][0-9]*//' $@.tmp | sort >> $@
212 symdummy.c: slapd.def
214 @echo "generating $@..."; \
215 echo "static void never_called() {" > $@.tmp; \
216 cat $< | while read line; \
221 echo "int $$2();" >> $@; \
222 echo "$$2();" >> $@.tmp; \
225 echo "extern int $$2;" >> $@; \
226 echo "$$2 = 0;" >> $@.tmp; \
231 echo "}" >> $@.tmp; \
235 libslapd.a: symdummy.o
236 dlltool --dllname slapd.exe --input-def slapd.def --output-lib $@
238 slapd.exp: libslapd.a
239 @echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
240 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
241 $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
242 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
244 @echo dlltool --dllname slapd.exe --input-def slapd.def \
245 --base-file slapd.base --output-exp $@; \
246 dlltool --dllname slapd.exe --input-def slapd.def \
247 --base-file slapd.base --output-exp $@; \
248 echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
249 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
250 $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
251 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
253 @echo dlltool --dllname slapd.exe --input-def slapd.def \
254 --base-file slapd.base --output-exp $@; \
255 dlltool --dllname slapd.exe --input-def slapd.def \
256 --base-file slapd.base --output-exp $@
258 slapi/.libs/libslapi.a: FORCE
259 (cd slapi; $(MAKE) $(MFLAGS) all)
261 libslapi.a: slapi/.libs/libslapi.a
262 cp slapi/.libs/libslapi.a .
264 slapd: $(SLAPD_DEPENDS) @LIBSLAPI@
265 $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) \
268 for i in $(SLAPTOOLS); do \
269 $(LN_S) slapd$(EXEEXT) $$i$(EXEEXT); done
273 $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS)
275 dummy $(SLAPD_DYNAMIC_BACKENDS): slapd
276 cd $@; $(MAKE) $(MFLAGS) all
279 dynamic_overlays: slapd
280 cd overlays; $(MAKE) $(MFLAGS) dynamic
283 # In Windows, dynamic backends have to be built after slapd. For this
284 # reason, we only build static backends now and dynamic backends later.
287 @if test -n "$(SLAPD_STATIC_BACKENDS)"; then \
288 echo "building static backends..."; \
289 for i in XX $(SLAPD_STATIC_BACKENDS); do \
290 if test $$i != XX; then \
291 echo " "; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \
292 ( cd $$i; $(MAKE) $(MFLAGS) all ); \
293 if test $$? != 0; then exit 1; fi; \
299 libbackends.a: .backend
302 @-for i in back-*/*.a; do \
306 pre=`echo $$i | $(SED) -e 's/\/.*$$//' -e 's/back-//'`; \
310 $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \
311 $(RM) *.o __.SYMDEF ________64ELEL_ ; \
312 echo "added backend library $$i"; \
316 @mv -f tmp/libbackends.a ./libbackends.a
318 @if test ! -z "$(RANLIB)" ; then \
319 $(RANLIB) libbackends.a; \
321 @ls -l libbackends.a; echo ""
324 cd overlays; $(MAKE) $(MFLAGS) static
328 $(MKVERSION) -s -n Versionstr slapd > $@
330 version.o: version.c $(OBJS) $(SLAPD_LIBDEPEND)
332 backends.o: backends.c $(srcdir)/slap.h
334 depend-local-srv: FORCE
335 @for i in $(SUBDIRS); do \
336 if test -d $$i -a -f $$i/Makefile ; then \
337 echo; echo " cd $$i; $(MAKE) $(MFLAGS) depend"; \
338 ( cd $$i; $(MAKE) $(MFLAGS) depend ); \
339 if test $$? != 0 ; then exit 1; fi ; \
345 $(RM) *.exp *.def *.base *.a *.objs symdummy.c
350 clean-local-srv: FORCE
351 @for i in $(SUBDIRS); do \
352 if test -d $$i -a -f $$i/Makefile ; then \
353 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
354 ( cd $$i; $(MAKE) $(MFLAGS) clean ); \
355 if test $$? != 0 ; then exit 1; fi ; \
358 $(RM) *.tmp all-cffiles
360 veryclean-local-srv: FORCE
361 @for i in $(SUBDIRS); do \
362 if test -d $$i -a -f $$i/Makefile ; then \
363 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
364 ( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \
368 install-local-srv: install-slapd install-tools \
369 install-conf install-db-config install-schema install-tools
372 -$(MKDIR) $(DESTDIR)$(libexecdir)
373 -$(MKDIR) $(DESTDIR)$(localstatedir)/run
374 $(LTINSTALL) $(INSTALLFLAGS) $(STRIP) -m 755 \
375 slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
376 @for i in $(SUBDIRS); do \
377 if test -d $$i -a -f $$i/Makefile ; then \
378 echo; echo " cd $$i; $(MAKE) $(MFLAGS) install"; \
379 ( cd $$i; $(MAKE) $(MFLAGS) install ); \
380 if test $$? != 0 ; then exit 1; fi ; \
384 all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS) dynamic_overlays
385 @if test $(PLAT) = NT; then \
386 sysconfdir=`cygpath -w $(sysconfdir) | \
387 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
388 localstatedir=`cygpath -w $(localstatedir) | \
389 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
390 moduledir=`cygpath -w $(moduledir) | \
391 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
393 sysconfdir=$(sysconfdir); \
394 localstatedir=$(localstatedir); \
395 moduledir=$(moduledir); \
397 $(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \
398 -e "s;%LOCALSTATEDIR%;$$localstatedir;" \
399 -e "s;%MODULEDIR%;$$moduledir;" \
400 $(srcdir)/slapd.conf > slapd.conf.tmp ; \
403 install-schema: FORCE
404 @if test -d $(DESTDIR)$(schemadir) ; then \
405 echo "MOVING EXISTING SCHEMA DIR to $(DESTDIR)$(schemadir).$$$$" ; \
406 mv $(DESTDIR)$(schemadir) $(DESTDIR)$(schemadir).$$$$ ; \
408 $(MKDIR) $(DESTDIR)$(schemadir)
409 @SD=$(DESTDIR)$(schemadir) ; \
410 files=`cd $(srcdir)/schema ; echo README *.ldif *.schema` ; \
411 for i in $$files ; do \
412 echo $(INSTALL) $(INSTALLFLAGS) -m 444 schema/$$i $$SD/$$i ; \
413 $(INSTALL) $(INSTALLFLAGS) -m 444 $(srcdir)/schema/$$i $$SD/$$i ; \
417 @-$(MKDIR) $(DESTDIR)$(sysconfdir)
418 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf.default
419 if test ! -f $(DESTDIR)$(sysconfdir)/slapd.conf; then \
420 echo "installing slapd.conf in $(sysconfdir)"; \
421 echo "$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \
422 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \
424 echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.conf" ; \
427 install-db-config: FORCE
428 @-$(MKDIR) $(DESTDIR)$(localstatedir) $(DESTDIR)$(sysconfdir)
429 @-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data
430 $(INSTALL) $(INSTALLFLAGS) -m 600 $(srcdir)/DB_CONFIG \
431 $(DESTDIR)$(localstatedir)/openldap-data/DB_CONFIG.example
432 $(INSTALL) $(INSTALLFLAGS) -m 600 $(srcdir)/DB_CONFIG \
433 $(DESTDIR)$(sysconfdir)/DB_CONFIG.example
436 -$(MKDIR) $(DESTDIR)$(sbindir)
437 for i in $(SLAPTOOLS); do \
438 $(RM) $(DESTDIR)$(sbindir)/$$i$(EXEEXT); \
439 $(LN_S) -f $(DESTDIR)$(libexecdir)/slapd$(EXEEXT) $(DESTDIR)$(sbindir)/$$i$(EXEEXT); \