1 ## Makefile.in for slapd
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2003 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>.
17 XPROGRAMS=sslapd libbackends.a .backend
21 NT_OBJS = nt_svc.o ../../libraries/liblutil/slapdmsg.res
23 SRCS = main.c globals.c config.c daemon.c \
24 connection.c search.c filter.c add.c cr.c \
25 attr.c entry.c backend.c result.c operation.c \
26 dn.c compare.c modify.c delete.c modrdn.c ch_malloc.c \
27 value.c ava.c bind.c unbind.c abandon.c filterentry.c \
28 phonetic.c acl.c str2filter.c aclparse.c init.c user.c \
29 repl.c lock.c controls.c extended.c kerberos.c passwd.c \
30 schema.c schema_check.c schema_init.c schema_prep.c \
31 schemaparse.c ad.c at.c mr.c syntax.c oc.c saslauthz.c \
32 oidm.c starttls.c index.c sets.c referral.c root_dse.c \
33 sasl.c module.c mra.c mods.c sl_malloc.c limits.c \
34 backglue.c operational.c matchedValues.c cancel.c syncrepl.c \
35 backover.c ctxcsn.c ldapsync.c sessionlog.c $(@PLAT@_SRCS)
37 OBJS = main.o globals.o config.o daemon.o \
38 connection.o search.o filter.o add.o cr.o \
39 attr.o entry.o backend.o result.o operation.o \
40 dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \
41 value.o ava.o bind.o unbind.o abandon.o filterentry.o \
42 phonetic.o acl.o str2filter.o aclparse.o init.o user.o \
43 repl.o lock.o controls.o extended.o kerberos.o passwd.o \
44 schema.o schema_check.o schema_init.o schema_prep.o \
45 schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o \
46 oidm.o starttls.o index.o sets.o referral.o root_dse.o \
47 sasl.o module.o mra.o mods.o sl_malloc.o limits.o \
48 backglue.o operational.o matchedValues.o cancel.o syncrepl.o \
49 backover.o ctxcsn.o ldapsync.o sessionlog.o $(@PLAT@_OBJS)
51 LDAP_INCDIR= ../../include -I$(srcdir)/slapi
52 LDAP_LIBDIR= ../../libraries
55 SLAPD_STATIC_DEPENDS=@SLAPD_NO_STATIC@ libbackends.a
56 SLAPD_STATIC_BACKENDS=@SLAPD_STATIC_BACKENDS@
57 SLAPD_DYNAMIC_BACKENDS=@SLAPD_DYNAMIC_BACKENDS@
59 SLAPI_LIBS=@LIBSLAPI@ @SLAPI_LIBS@
61 XDEFS = $(MODULES_CPPFLAGS)
62 XLDFLAGS = $(MODULES_LDFLAGS)
64 XLIBS = $(SLAPD_STATIC_DEPENDS) $(SLAPD_L)
65 XXLIBS = $(LDBM_LIBS) $(SLAPD_LIBS) $(SECURITY_LIBS) $(LUTIL_LIBS)
66 XXXLIBS = $(LTHREAD_LIBS) $(SLAPI_LIBS) $(MODULES_LIBS)
68 BUILD_OPT = "--enable-slapd"
69 BUILD_SRV = @BUILD_SLAPD@
71 all-local-srv: all-cffiles
73 NT_SLAPD_DEPENDS = slapd.exp
74 NT_SLAPD_OBJECTS = slapd.exp symdummy.o $(OBJS) version.o
76 UNIX_SLAPD_DEPENDS = $(SLAPD_STATIC_DEPENDS) version.o $(SLAPD_L)
77 UNIX_SLAPD_OBJECTS = $(OBJS) version.o
79 SLAPD_DEPENDS = $(@PLAT@_SLAPD_DEPENDS)
80 SLAPD_OBJECTS = $(@PLAT@_SLAPD_OBJECTS)
82 # Notes about slapd for Windows
83 # =============================
84 # slapd.exe must export all of its global symbols, just like a DLL.
85 # The purpose of this is to allow dynamic modules (dynamic backends
86 # or external dynamic modules) to bind with the symbols at run-time.
88 # Exporting symbols from an .EXE is a bit tricky and involves multiple
89 # steps. First a .DEF file must be generated. The .DEF file indicates
90 # the set of symbols that are to be exported. Many times, it's possible
91 # to manually create this file with an editor. However, with slapd,
92 # we want to export EVERY global symbol that it knows about (NOT including
93 # symbols that are imported from other DLLs). The set of symbols to
94 # export INCLUDES symbols from all static libraries that slapd gets
95 # linked with, e.g. avl, ldbm, lunicode, lutil, etc. This list
96 # will also include liblber and libldap_r if they were built as static
97 # libraries. ALSO included will be symbols from other STATIC libraries
98 # outside the domain of the OpenLDAP source tree, e.g. regex, ltdl,
99 # crypto, ssl, sasl, etc. (If these libraries are dynamic, we won't want
100 # to include their symbols in the list). The correct set of symbols
101 # CAN be determined at build time. The slapd.def target automatically
102 # determines the correct set of symbols and generates the slapd.def file.
104 # The slapd.def file, serving multiple purposes, will:
106 # 1) be used to generate libslapd.a, the import library for slapd.exe.
108 # 2) be used to generate the symdummy.c file.
110 # 3) be used to help create slapd.exp, the binary-formated slapd export file.
112 # The import library is used by dynamic modules at link time. With this
113 # library, dynamic modules indicate to the linker that it will resolve
114 # these symbols from the slapd.exe binary at run-time. Of course, whenever
115 # a module imports dynamic symbols, those symbols should be marked with
116 # the __declspec(dllimport) directive in the header files that the dynamic
117 # modules build with. In OpenLDAP, this is handled automatically in the
118 # header files. (See ldap_cdefs.h for an explanation). Writers of
119 # dynamic backend modules should keep in mind that slapd.exe might export
120 # other global symbols that are not part of OpenLDAP (e.g. regex, ltdl,
121 # crypto, ssl, sasl, etc.) When a writer actually uses (i.e. imports) these
122 # symbols, he must verify that the header files from these external packages
123 # include a mechanism to mark imported symbols with the __declspec(dllimport)
124 # directive. Whether or not such a mechanism exists, the writer must be
125 # able to include these directives appropriately when their symbols are
126 # being imported from slapd.exe. The directive is not completely necessary
127 # for functions, but it is required for variables.
129 # The symdummy.c file basically references EVERY symbol available to slapd.exe,
130 # including symbols that slapd.exe never actually refereneced. The file
131 # is compiled and included at link time. Without this object file, slapd.exe
132 # would NOT export symbols that it never referenced. The reason that these
133 # symbols must still be exported is because a dynamic module may want to
134 # use a symbol even if it had not been referenced by slapd.exe.
138 # slapd.def REALLY depends upon all slapd objects and all static libraries
139 # included in $(LIBS), including static libraries outside of OpenLDAP.
140 # When slapd.def is built, the absolute paths to all static libraries
141 # (both inside and outside of OpenLDAP) are generated. We don't have
142 # any way to include this generated list as a dependency of slapd.def (sigh).
143 # Thus, we do the best we can by depending on version.o, which depends
144 # on its own very long list of dependencies.
146 slapd.def: libbackends.a version.o
147 @for i in $(LDFLAGS) ; do \
148 path=`expr "$$i" : "-L\(.*\)"`; \
149 if test $$? != 0; then continue; fi; \
150 paths="$$paths $$path"; \
153 for i in $(OBJS) version.o $(LIBS) ; do \
158 base=`expr "$$i" : "-l\(.*\)"`; \
159 for p in $$paths ; do \
160 for ext in la dll a ; do \
161 path=$$p/lib$$base.$$ext; \
162 test ! -f $$path && continue; \
163 if test $$ext = la ; then \
164 for t in dlname old_library ; do \
165 line=`grep "^$$t=" $$path`; \
166 lib=`expr "$$line" : "[^']*'\(.*\)'"`; \
167 test -n "$$lib" && test -f $$p/$$lib && \
168 path=$$p/$$lib && break; \
170 test $$t = dlname && ext=dll; \
171 test $$t = old_library && ext=a; \
173 if test $$ext = a ; then \
179 test -n "$$done" && break; \
181 test -z "$$obj" && continue; \
186 objs="$$objs $$obj"; \
188 echo dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
189 --output-def $@.tmp $$objs; \
190 dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
191 --output-def $@.tmp $$objs;
193 $(SED) -e 1,2d -e 's/ @ [0-9][0-9]*//' $@.tmp | sort >> $@
196 symdummy.c: slapd.def
198 @echo "generating $@..."; \
199 echo "static void never_called() {" > $@.tmp; \
200 cat $< | while read line; \
205 echo "int $$2();" >> $@; \
206 echo "$$2();" >> $@.tmp; \
209 echo "extern int $$2;" >> $@; \
210 echo "$$2 = 0;" >> $@.tmp; \
215 echo "}" >> $@.tmp; \
219 libslapd.a: symdummy.o
220 dlltool --dllname slapd.exe --input-def slapd.def --output-lib $@
222 slapd.exp: libslapd.a
223 @echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
224 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
225 $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
226 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
228 @echo dlltool --dllname slapd.exe --input-def slapd.def \
229 --base-file slapd.base --output-exp $@; \
230 dlltool --dllname slapd.exe --input-def slapd.def \
231 --base-file slapd.base --output-exp $@; \
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 $@
242 slapi/.libs/libslapi.a: FORCE
243 (cd slapi; $(MAKE) $(MFLAGS) all)
245 libslapi.a: slapi/.libs/libslapi.a
246 cp slapi/.libs/libslapi.a .
248 slapd: $(SLAPD_DEPENDS) @LIBSLAPI@
249 $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) \
253 $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS)
255 tools $(SLAPD_DYNAMIC_BACKENDS): slapd
256 cd $@; $(MAKE) $(MFLAGS) all
260 # In Windows, dynamic backends have to be built after slapd. For this
261 # reason, we only build static backends now and dynamic backends later.
264 @if test -n "$(SLAPD_STATIC_BACKENDS)"; then \
265 echo "building static backends..."; \
266 for i in XX $(SLAPD_STATIC_BACKENDS); do \
267 if test $$i != XX; then \
268 echo " "; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \
269 ( cd $$i; $(MAKE) $(MFLAGS) all ); \
270 if test $$? != 0; then exit 1; fi; \
276 libbackends.a: .backend
279 @-for i in back-*/*.a; do \
283 pre=`echo $$i | $(SED) -e 's/\/.*$$//' -e 's/back-//'`; \
287 $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \
288 $(RM) *.o __.SYMDEF ________64ELEL_ ; \
289 echo "added backend library $$i"; \
293 @mv -f tmp/libbackends.a ./libbackends.a
295 @if test ! -z "$(RANLIB)" ; then \
296 $(RANLIB) libbackends.a; \
298 @ls -l libbackends.a; echo ""
302 $(MKVERSION) -s -n Versionstr slapd > $@
304 version.o: version.c $(OBJS) $(SLAPD_LIBDEPEND)
306 depend-local-srv: FORCE
307 @for i in back-* shell-backends slapi tools; do \
308 if test -d $$i -a -f $$i/Makefile ; then \
309 echo; echo " cd $$i; $(MAKE) $(MFLAGS) depend"; \
310 ( cd $$i; $(MAKE) $(MFLAGS) depend ); \
311 if test $$? != 0 ; then exit 1; fi ; \
317 rm -f *.exp *.def *.base *.a *.objs symdummy.c
319 clean-local-srv: FORCE
320 @for i in back-* shell-backends slapi tools; do \
321 if test -d $$i -a -f $$i/Makefile ; then \
322 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
323 ( cd $$i; $(MAKE) $(MFLAGS) clean ); \
324 if test $$? != 0 ; then exit 1; fi ; \
327 rm -f *.tmp all-cffiles
329 veryclean-local-srv: FORCE
330 @for i in back-* shell-backends slapi tools; do \
331 if test -d $$i -a -f $$i/Makefile ; then \
332 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
333 ( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \
337 install-local-srv: install-slapd install-conf install-schema install-tools
340 -$(MKDIR) $(DESTDIR)$(libexecdir)
341 -$(MKDIR) $(DESTDIR)$(localstatedir)
342 $(LTINSTALL) $(INSTALLFLAGS) -s -m 755 \
343 slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
344 @for i in back-* shell-backends slapi tools; do \
345 if test -d $$i -a -f $$i/Makefile ; then \
346 echo; echo " cd $$i; $(MAKE) $(MFLAGS) install"; \
347 ( cd $$i; $(MAKE) $(MFLAGS) install ); \
348 if test $$? != 0 ; then exit 1; fi ; \
352 all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS) tools
353 @if test $(PLAT) = NT; then \
354 sysconfdir=`cygpath -w $(sysconfdir) | \
355 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
356 localstatedir=`cygpath -w $(localstatedir) | \
357 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
358 moduledir=`cygpath -w $(moduledir) | \
359 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
361 sysconfdir=$(sysconfdir); \
362 localstatedir=$(localstatedir); \
363 moduledir=$(moduledir); \
365 $(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \
366 -e "s;%LOCALSTATEDIR%;$$localstatedir;" \
367 -e "s;%MODULEDIR%;$$moduledir;" \
368 $(srcdir)/slapd.conf > slapd.conf.tmp ; \
371 install-schema: FORCE
372 @-$(MKDIR) $(DESTDIR)$(schemadir)
373 i="$(srcdir)/schema/README" ; \
374 SF=`basename $$i` ; \
375 SD="$(DESTDIR)$(schemadir)/$$SF" ; \
376 echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
377 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD
378 for i in $(srcdir)/schema/*.schema ; do \
379 SF=`basename $$i` ; \
380 SD="$(DESTDIR)$(schemadir)/$$SF" ; \
381 if test ! -f $$SD ; then \
382 echo "installing $$SF in $(schemadir)" ; \
383 echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
384 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
386 echo "PRESERVING EXISTING SCHEMA FILE $$SD" ; \
388 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD.default ; \
392 @-$(MKDIR) $(DESTDIR)$(sysconfdir)
393 @-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data
394 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf.default
395 if test ! -f $(DESTDIR)$(sysconfdir)/slapd.conf; then \
396 echo "installing slapd.conf in $(sysconfdir)"; \
397 echo "$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \
398 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \
400 echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.conf" ; \
404 @-$(MKDIR) $(DESTDIR)$(sbindir)
405 (cd tools; $(MAKE) $(MFLAGS) install)