1 ## Makefile.in for slapd
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2010 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 slapschema
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 lock.c controls.c extended.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 backglue.c 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 \
41 aci.c alock.c txn.c slapschema.c \
44 OBJS = main.o globals.o bconfig.o config.o daemon.o \
45 connection.o search.o filter.o add.o cr.o \
46 attr.o entry.o backend.o backends.o result.o operation.o \
47 dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \
48 value.o ava.o bind.o unbind.o abandon.o filterentry.o \
49 phonetic.o acl.o str2filter.o aclparse.o init.o user.o \
50 lock.o controls.o extended.o passwd.o \
51 schema.o schema_check.o schema_init.o schema_prep.o \
52 schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o \
53 oidm.o starttls.o index.o sets.o referral.o root_dse.o \
54 sasl.o module.o mra.o mods.o sl_malloc.o zn_malloc.o limits.o \
55 operational.o matchedValues.o cancel.o syncrepl.o \
56 backglue.o backover.o ctxcsn.o ldapsync.o frontend.o \
57 slapadd.o slapcat.o slapcommon.o slapdn.o slapindex.o \
58 slappasswd.o slaptest.o slapauth.o slapacl.o component.o \
59 aci.o alock.o txn.o slapschema.o \
62 LDAP_INCDIR= ../../include -I$(srcdir) -I$(srcdir)/slapi -I.
63 LDAP_LIBDIR= ../../libraries
66 SLAPD_STATIC_DEPENDS=@SLAPD_NO_STATIC@ libbackends.a liboverlays.a
67 SLAPD_STATIC_BACKENDS=@SLAPD_STATIC_BACKENDS@
68 SLAPD_DYNAMIC_BACKENDS=@SLAPD_DYNAMIC_BACKENDS@
70 SLAPI_LIBS=@LIBSLAPI@ @SLAPI_LIBS@
72 XDEFS = $(MODULES_CPPFLAGS)
73 XLDFLAGS = $(MODULES_LDFLAGS)
75 XLIBS = $(SLAPD_STATIC_DEPENDS) $(SLAPD_L) $(MODULES_LIBS)
76 XXLIBS = $(SLAPD_LIBS) $(SECURITY_LIBS) $(LUTIL_LIBS)
77 XXXLIBS = $(LTHREAD_LIBS) $(SLAPI_LIBS)
79 BUILD_OPT = "--enable-slapd"
80 BUILD_SRV = @BUILD_SLAPD@
82 all-local-srv: all-cffiles
84 NT_SLAPD_DEPENDS = slapd.exp
85 NT_SLAPD_OBJECTS = slapd.exp symdummy.o $(OBJS) version.o
87 UNIX_SLAPD_DEPENDS = $(SLAPD_STATIC_DEPENDS) version.o $(SLAPD_L)
88 UNIX_SLAPD_OBJECTS = $(OBJS) version.o
90 SLAPD_DEPENDS = $(@PLAT@_SLAPD_DEPENDS)
91 SLAPD_OBJECTS = $(@PLAT@_SLAPD_OBJECTS)
93 # Notes about slapd for Windows
94 # =============================
95 # slapd.exe must export all of its global symbols, just like a DLL.
96 # The purpose of this is to allow dynamic modules (dynamic backends
97 # or external dynamic modules) to bind with the symbols at run-time.
99 # Exporting symbols from an .EXE is a bit tricky and involves multiple
100 # steps. First a .DEF file must be generated. The .DEF file indicates
101 # the set of symbols that are to be exported. Many times, it's possible
102 # to manually create this file with an editor. However, with slapd,
103 # we want to export EVERY global symbol that it knows about (NOT including
104 # symbols that are imported from other DLLs). The set of symbols to
105 # export INCLUDES symbols from all static libraries that slapd gets
106 # linked with, e.g. avl, lunicode, lutil, etc. This list
107 # will also include liblber and libldap_r if they were built as static
108 # libraries. ALSO included will be symbols from other STATIC libraries
109 # outside the domain of the OpenLDAP source tree, e.g. regex, ltdl,
110 # crypto, ssl, sasl, etc. (If these libraries are dynamic, we won't want
111 # to include their symbols in the list). The correct set of symbols
112 # CAN be determined at build time. The slapd.def target automatically
113 # determines the correct set of symbols and generates the slapd.def file.
115 # The slapd.def file, serving multiple purposes, will:
117 # 1) be used to generate libslapd.a, the import library for slapd.exe.
119 # 2) be used to generate the symdummy.c file.
121 # 3) be used to help create slapd.exp, the binary-formated slapd export file.
123 # The import library is used by dynamic modules at link time. With this
124 # library, dynamic modules indicate to the linker that it will resolve
125 # these symbols from the slapd.exe binary at run-time. Of course, whenever
126 # a module imports dynamic symbols, those symbols should be marked with
127 # the __declspec(dllimport) directive in the header files that the dynamic
128 # modules build with. In OpenLDAP, this is handled automatically in the
129 # header files. (See ldap_cdefs.h for an explanation). Writers of
130 # dynamic backend modules should keep in mind that slapd.exe might export
131 # other global symbols that are not part of OpenLDAP (e.g. regex, ltdl,
132 # crypto, ssl, sasl, etc.) When a writer actually uses (i.e. imports) these
133 # symbols, he must verify that the header files from these external packages
134 # include a mechanism to mark imported symbols with the __declspec(dllimport)
135 # directive. Whether or not such a mechanism exists, the writer must be
136 # able to include these directives appropriately when their symbols are
137 # being imported from slapd.exe. The directive is not completely necessary
138 # for functions, but it is required for variables.
140 # The symdummy.c file basically references EVERY symbol available to slapd.exe,
141 # including symbols that slapd.exe never actually referenced. The file
142 # is compiled and included at link time. Without this object file, slapd.exe
143 # would NOT export symbols that it never referenced. The reason that these
144 # symbols must still be exported is because a dynamic module may want to
145 # use a symbol even if it had not been referenced by slapd.exe.
149 # slapd.def REALLY depends upon all slapd objects and all static libraries
150 # included in $(LIBS), including static libraries outside of OpenLDAP.
151 # When slapd.def is built, the absolute paths to all static libraries
152 # (both inside and outside of OpenLDAP) are generated. We don't have
153 # any way to include this generated list as a dependency of slapd.def (sigh).
154 # Thus, we do the best we can by depending on version.o, which depends
155 # on its own very long list of dependencies.
157 slapd.def: libbackends.a liboverlays.a version.o
158 @for i in XX $(LDFLAGS) ; do \
159 path=`expr "$$i" : "-L\(.*\)"`; \
160 if test $$? != 0; then continue; fi; \
161 paths="$$paths $$path"; \
164 for i in $(OBJS) version.o $(LIBS) ; do \
169 base=`expr "$$i" : "-l\(.*\)"`; \
170 for p in . $$paths ; do \
171 for ext in la dll dll.a a ; do \
172 path=$$p/lib$$base.$$ext; \
173 test ! -f $$path && continue; \
174 if test $$ext = la ; then \
175 for t in dlname old_library ; do \
176 line=`grep "^$$t=" $$path`; \
177 lib=`expr "$$line" : "[^']*'\(.*\)'"`; \
178 test -n "$$lib" && test -f $$p/$$lib && \
179 path=$$p/$$lib && break; \
181 test $$t = dlname && ext=dll; \
182 test $$t = old_library && ext=a; \
184 if test $$ext = a ; then \
190 test -n "$$done" && break; \
192 test -z "$$obj" && continue; \
195 if test -n "$(LTSTATIC)"; then \
196 base=`expr "$$i" : ".*/\(.*\).la"`; \
197 path=`expr "$$i" : "\(.*/\).*"`; \
198 obj=$$path.libs/$$base.a; \
206 objs="$$objs $$obj"; \
208 echo dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
209 --output-def $@.tmp $$objs; \
210 dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
211 --output-def $@.tmp $$objs;
213 $(SED) -e 1,2d -e 's/ @ [0-9][0-9]*//' $@.tmp | sort >> $@
216 symdummy.c: slapd.def
218 @echo "generating $@..."; \
219 echo "static void never_called() {" > $@.tmp; \
220 cat $< | while read line; \
225 echo "int $$2();" >> $@; \
226 echo "$$2();" >> $@.tmp; \
229 echo "extern int $$2;" >> $@; \
230 echo "$$2 = 0;" >> $@.tmp; \
235 echo "}" >> $@.tmp; \
239 libslapd.a: symdummy.o
240 dlltool --dllname slapd.exe --input-def slapd.def --output-lib $@
242 slapd.exp: libslapd.a
243 @echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
244 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
245 $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
246 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
248 @echo dlltool --dllname slapd.exe --input-def slapd.def \
249 --base-file slapd.base --output-exp $@; \
250 dlltool --dllname slapd.exe --input-def slapd.def \
251 --base-file slapd.base --output-exp $@; \
252 echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
253 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
254 $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
255 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
257 @echo dlltool --dllname slapd.exe --input-def slapd.def \
258 --base-file slapd.base --output-exp $@; \
259 dlltool --dllname slapd.exe --input-def slapd.def \
260 --base-file slapd.base --output-exp $@
262 slapi/.libs/libslapi.a: FORCE
263 (cd slapi; $(MAKE) $(MFLAGS) all)
265 libslapi.a: slapi/.libs/libslapi.a
266 cp slapi/.libs/libslapi.a .
268 slapd: $(SLAPD_DEPENDS) @LIBSLAPI@
269 $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) \
272 for i in $(SLAPTOOLS); do \
273 $(LN_S) slapd$(EXEEXT) $$i$(EXEEXT); done
277 $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS)
279 dummy $(SLAPD_DYNAMIC_BACKENDS): slapd
280 cd $@; $(MAKE) $(MFLAGS) all
283 dynamic_overlays: slapd
284 cd overlays; $(MAKE) $(MFLAGS) dynamic
287 # In Windows, dynamic backends have to be built after slapd. For this
288 # reason, we only build static backends now and dynamic backends later.
291 @if test -n "$(SLAPD_STATIC_BACKENDS)"; then \
292 echo "building static backends..."; \
293 for i in XX $(SLAPD_STATIC_BACKENDS); do \
294 if test $$i != XX; then \
295 echo " "; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \
296 ( cd $$i; $(MAKE) $(MFLAGS) all ); \
297 if test $$? != 0; then exit 1; fi; \
303 libbackends.a: .backend
306 @-for i in back-*/*.a; do \
310 pre=`echo $$i | $(SED) -e 's/\/.*$$//' -e 's/back-//'`; \
314 $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \
315 $(RM) *.o __.SYMDEF ________64ELEL_ ; \
316 echo "added backend library $$i"; \
320 @mv -f tmp/libbackends.a ./libbackends.a
322 @if test ! -z "$(RANLIB)" ; then \
323 $(RANLIB) libbackends.a; \
325 @ls -l libbackends.a; echo ""
328 cd overlays; $(MAKE) $(MFLAGS) static
332 $(MKVERSION) -s -n Versionstr slapd > $@
334 version.o: version.c $(OBJS) $(SLAPD_LIBDEPEND)
336 backends.o: backends.c $(srcdir)/slap.h
338 depend-local-srv: FORCE
339 @for i in $(SUBDIRS); do \
340 if test -d $$i && test -f $$i/Makefile ; then \
341 echo; echo " cd $$i; $(MAKE) $(MFLAGS) depend"; \
342 ( cd $$i; $(MAKE) $(MFLAGS) depend ); \
343 if test $$? != 0 ; then exit 1; fi ; \
349 $(RM) *.exp *.def *.base *.a *.objs symdummy.c
354 clean-local-srv: FORCE
355 @for i in $(SUBDIRS); do \
356 if test -d $$i && test -f $$i/Makefile ; then \
357 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
358 ( cd $$i; $(MAKE) $(MFLAGS) clean ); \
359 if test $$? != 0 ; then exit 1; fi ; \
362 $(RM) *.tmp all-cffiles
364 veryclean-local-srv: FORCE
365 @for i in $(SUBDIRS); do \
366 if test -d $$i && test -f $$i/Makefile ; then \
367 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
368 ( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \
372 install-local-srv: install-slapd install-tools \
373 install-conf install-db-config install-schema install-tools
376 -$(MKDIR) $(DESTDIR)$(libexecdir)
377 -$(MKDIR) $(DESTDIR)$(localstatedir)/run
378 $(LTINSTALL) $(INSTALLFLAGS) $(STRIP) -m 755 \
379 slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
380 @for i in $(SUBDIRS); do \
381 if test -d $$i && test -f $$i/Makefile ; then \
382 echo; echo " cd $$i; $(MAKE) $(MFLAGS) install"; \
383 ( cd $$i; $(MAKE) $(MFLAGS) install ); \
384 if test $$? != 0 ; then exit 1; fi ; \
388 all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS) dynamic_overlays
389 @if test $(PLAT) = NT; then \
390 sysconfdir=`cygpath -w $(sysconfdir) | \
391 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
392 localstatedir=`cygpath -w $(localstatedir) | \
393 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
394 moduledir=`cygpath -w $(moduledir) | \
395 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
397 sysconfdir=$(sysconfdir); \
398 localstatedir=$(localstatedir); \
399 moduledir=$(moduledir); \
401 $(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \
402 -e "s;%LOCALSTATEDIR%;$$localstatedir;" \
403 -e "s;%MODULEDIR%;$$moduledir;" \
404 $(srcdir)/slapd.conf > slapd.conf.tmp ; \
407 install-schema: FORCE
408 @if test -d $(DESTDIR)$(schemadir) ; then \
409 echo "MOVING EXISTING SCHEMA DIR to $(DESTDIR)$(schemadir).$$$$" ; \
410 mv $(DESTDIR)$(schemadir) $(DESTDIR)$(schemadir).$$$$ ; \
412 $(MKDIR) $(DESTDIR)$(schemadir)
413 @SD=$(DESTDIR)$(schemadir) ; \
414 files=`cd $(srcdir)/schema ; echo README *.ldif *.schema` ; \
415 for i in $$files ; do \
416 echo $(INSTALL) $(INSTALLFLAGS) -m 444 schema/$$i $$SD/$$i ; \
417 $(INSTALL) $(INSTALLFLAGS) -m 444 $(srcdir)/schema/$$i $$SD/$$i ; \
421 @-$(MKDIR) $(DESTDIR)$(sysconfdir)
422 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf.default
423 if test ! -f $(DESTDIR)$(sysconfdir)/slapd.conf; then \
424 echo "installing slapd.conf in $(sysconfdir)"; \
425 echo "$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \
426 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \
428 echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.conf" ; \
431 install-db-config: FORCE
432 @-$(MKDIR) $(DESTDIR)$(localstatedir) $(DESTDIR)$(sysconfdir)
433 @-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data
434 $(INSTALL) $(INSTALLFLAGS) -m 600 $(srcdir)/DB_CONFIG \
435 $(DESTDIR)$(localstatedir)/openldap-data/DB_CONFIG.example
436 $(INSTALL) $(INSTALLFLAGS) -m 600 $(srcdir)/DB_CONFIG \
437 $(DESTDIR)$(sysconfdir)/DB_CONFIG.example
440 -$(MKDIR) $(DESTDIR)$(sbindir)
441 for i in $(SLAPTOOLS); do \
442 $(RM) $(DESTDIR)$(sbindir)/$$i$(EXEEXT); \
443 $(LN_S) -f $(DESTDIR)$(libexecdir)/slapd$(EXEEXT) $(DESTDIR)$(sbindir)/$$i$(EXEEXT); \