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 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 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 backover.c ctxcsn.c ldapsync.c sessionlog.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 config.o daemon.o \
44 connection.o search.o filter.o add.o cr.o \
45 attr.o entry.o backend.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 limits.o \
54 backglue.o operational.o matchedValues.o cancel.o syncrepl.o \
55 backover.o ctxcsn.o ldapsync.o sessionlog.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)/slapi -I.
61 LDAP_LIBDIR= ../../libraries
64 SLAPD_STATIC_DEPENDS=@SLAPD_NO_STATIC@ libbackends.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) liboverlays.a
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 = liboverlays.a $(@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; \
195 objs="$$objs $$obj"; \
197 echo dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
198 --output-def $@.tmp $$objs; \
199 dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
200 --output-def $@.tmp $$objs;
202 $(SED) -e 1,2d -e 's/ @ [0-9][0-9]*//' $@.tmp | sort >> $@
205 symdummy.c: slapd.def
207 @echo "generating $@..."; \
208 echo "static void never_called() {" > $@.tmp; \
209 cat $< | while read line; \
214 echo "int $$2();" >> $@; \
215 echo "$$2();" >> $@.tmp; \
218 echo "extern int $$2;" >> $@; \
219 echo "$$2 = 0;" >> $@.tmp; \
224 echo "}" >> $@.tmp; \
228 libslapd.a: symdummy.o
229 dlltool --dllname slapd.exe --input-def slapd.def --output-lib $@
231 slapd.exp: libslapd.a
232 @echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
233 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
234 $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
235 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
237 @echo dlltool --dllname slapd.exe --input-def slapd.def \
238 --base-file slapd.base --output-exp $@; \
239 dlltool --dllname slapd.exe --input-def slapd.def \
240 --base-file slapd.base --output-exp $@; \
241 echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
242 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
243 $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
244 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
246 @echo dlltool --dllname slapd.exe --input-def slapd.def \
247 --base-file slapd.base --output-exp $@; \
248 dlltool --dllname slapd.exe --input-def slapd.def \
249 --base-file slapd.base --output-exp $@
251 slapi/.libs/libslapi.a: FORCE
252 (cd slapi; $(MAKE) $(MFLAGS) all)
254 libslapi.a: slapi/.libs/libslapi.a
255 cp slapi/.libs/libslapi.a .
257 slapd: $(SLAPD_DEPENDS) @LIBSLAPI@
258 $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) \
261 for i in $(SLAPTOOLS); do \
262 $(LN_S) slapd$(EXEEXT) $$i$(EXEEXT); done
266 $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS)
268 $(SLAPD_DYNAMIC_BACKENDS): slapd
269 cd $@; $(MAKE) $(MFLAGS) all
273 # In Windows, dynamic backends have to be built after slapd. For this
274 # reason, we only build static backends now and dynamic backends later.
277 @if test -n "$(SLAPD_STATIC_BACKENDS)"; then \
278 echo "building static backends..."; \
279 for i in XX $(SLAPD_STATIC_BACKENDS); do \
280 if test $$i != XX; then \
281 echo " "; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \
282 ( cd $$i; $(MAKE) $(MFLAGS) all ); \
283 if test $$? != 0; then exit 1; fi; \
289 libbackends.a: .backend
292 @-for i in back-*/*.a; do \
296 pre=`echo $$i | $(SED) -e 's/\/.*$$//' -e 's/back-//'`; \
300 $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \
301 $(RM) *.o __.SYMDEF ________64ELEL_ ; \
302 echo "added backend library $$i"; \
306 @mv -f tmp/libbackends.a ./libbackends.a
308 @if test ! -z "$(RANLIB)" ; then \
309 $(RANLIB) libbackends.a; \
311 @ls -l libbackends.a; echo ""
314 @cd overlays; $(MAKE) $(MFLAGS) all
318 $(MKVERSION) -s -n Versionstr slapd > $@
320 version.o: version.c $(OBJS) $(SLAPD_LIBDEPEND)
322 depend-local-srv: FORCE
323 @for i in $(SUBDIRS); do \
324 if test -d $$i -a -f $$i/Makefile ; then \
325 echo; echo " cd $$i; $(MAKE) $(MFLAGS) depend"; \
326 ( cd $$i; $(MAKE) $(MFLAGS) depend ); \
327 if test $$? != 0 ; then exit 1; fi ; \
333 $(RM) *.exp *.def *.base *.a *.objs symdummy.c
335 clean-local-srv: FORCE
336 @for i in $(SUBDIRS); do \
337 if test -d $$i -a -f $$i/Makefile ; then \
338 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
339 ( cd $$i; $(MAKE) $(MFLAGS) clean ); \
340 if test $$? != 0 ; then exit 1; fi ; \
343 $(RM) *.tmp all-cffiles
345 veryclean-local-srv: FORCE
346 @for i in $(SUBDIRS); do \
347 if test -d $$i -a -f $$i/Makefile ; then \
348 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
349 ( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \
353 install-local-srv: install-slapd install-tools \
354 install-conf install-db-config install-schema install-tools
357 -$(MKDIR) $(DESTDIR)$(libexecdir)
358 -$(MKDIR) $(DESTDIR)$(localstatedir)/run
359 $(LTINSTALL) $(INSTALLFLAGS) -s -m 755 \
360 slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
361 @for i in $(SUBDIRS); do \
362 if test -d $$i -a -f $$i/Makefile ; then \
363 echo; echo " cd $$i; $(MAKE) $(MFLAGS) install"; \
364 ( cd $$i; $(MAKE) $(MFLAGS) install ); \
365 if test $$? != 0 ; then exit 1; fi ; \
369 all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS)
370 @if test $(PLAT) = NT; then \
371 sysconfdir=`cygpath -w $(sysconfdir) | \
372 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
373 localstatedir=`cygpath -w $(localstatedir) | \
374 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
375 moduledir=`cygpath -w $(moduledir) | \
376 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
378 sysconfdir=$(sysconfdir); \
379 localstatedir=$(localstatedir); \
380 moduledir=$(moduledir); \
382 $(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \
383 -e "s;%LOCALSTATEDIR%;$$localstatedir;" \
384 -e "s;%MODULEDIR%;$$moduledir;" \
385 $(srcdir)/slapd.conf > slapd.conf.tmp ; \
388 install-schema: FORCE
389 @-$(MKDIR) $(DESTDIR)$(schemadir)
390 i="$(srcdir)/schema/README" ; \
391 SF=`basename $$i` ; \
392 SD="$(DESTDIR)$(schemadir)/$$SF" ; \
393 echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
394 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD
395 for i in $(srcdir)/schema/*.schema ; do \
396 SF=`basename $$i` ; \
397 SD="$(DESTDIR)$(schemadir)/$$SF" ; \
398 if test ! -f $$SD ; then \
399 echo "installing $$SF in $(schemadir)" ; \
400 echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
401 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
403 echo "PRESERVING EXISTING SCHEMA FILE $$SD" ; \
405 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD.default ; \
409 @-$(MKDIR) $(DESTDIR)$(sysconfdir)
410 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf.default
411 if test ! -f $(DESTDIR)$(sysconfdir)/slapd.conf; then \
412 echo "installing slapd.conf in $(sysconfdir)"; \
413 echo "$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \
414 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \
416 echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.conf" ; \
419 install-db-config: FORCE
420 @-$(MKDIR) $(DESTDIR)$(localstatedir) $(DESTDIR)$(sysconfdir)
421 @-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data
422 $(INSTALL) $(INSTALLFLAGS) -m 600 $(srcdir)/DB_CONFIG \
423 $(DESTDIR)$(localstatedir)/openldap-data/DB_CONFIG.example
424 $(INSTALL) $(INSTALLFLAGS) -m 600 $(srcdir)/DB_CONFIG \
425 $(DESTDIR)$(sysconfdir)/DB_CONFIG.example
428 -$(MKDIR) $(DESTDIR)$(sbindir)
429 for i in $(SLAPTOOLS); do \
430 $(RM) $(DESTDIR)$(sbindir)/$$i$(EXEEXT); \
431 $(LN_S) -f $(DESTDIR)$(libexecdir)/slapd$(EXEEXT) $(DESTDIR)$(sbindir)/$$i$(EXEEXT); \