1 ## Makefile.in for slapd
3 ## Copyright 1998-2003 The OpenLDAP Foundation.
4 ## All rights reserved.
6 ## Redistribution and use in source and binary forms, with or without
7 ## modification, are permitted only as authorized by the OpenLDAP
10 ## A copy of this license is available in the file LICENSE in the
11 ## top-level directory of the distribution or, alternatively, at
12 ## <http://www.OpenLDAP.org/license.html>.
15 XPROGRAMS=sslapd libbackends.a .backend
19 NT_OBJS = nt_svc.o ../../libraries/liblutil/slapdmsg.res
21 SRCS = main.c globals.c config.c daemon.c \
22 connection.c search.c filter.c add.c cr.c \
23 attr.c entry.c backend.c result.c operation.c \
24 dn.c compare.c modify.c delete.c modrdn.c ch_malloc.c \
25 value.c ava.c bind.c unbind.c abandon.c filterentry.c \
26 phonetic.c acl.c str2filter.c aclparse.c init.c user.c \
27 repl.c lock.c controls.c extended.c kerberos.c passwd.c \
28 schema.c schema_check.c schema_init.c schema_prep.c \
29 schemaparse.c ad.c at.c mr.c syntax.c oc.c saslauthz.c \
30 oidm.c starttls.c index.c sets.c referral.c root_dse.c \
31 sasl.c module.c mra.c mods.c sl_malloc.c limits.c \
32 backglue.c operational.c matchedValues.c cancel.c syncrepl.c \
33 backover.c ctxcsn.c ldapsync.c sessionlog.c $(@PLAT@_SRCS)
35 OBJS = main.o globals.o config.o daemon.o \
36 connection.o search.o filter.o add.o cr.o \
37 attr.o entry.o backend.o result.o operation.o \
38 dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \
39 value.o ava.o bind.o unbind.o abandon.o filterentry.o \
40 phonetic.o acl.o str2filter.o aclparse.o init.o user.o \
41 repl.o lock.o controls.o extended.o kerberos.o passwd.o \
42 schema.o schema_check.o schema_init.o schema_prep.o \
43 schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o \
44 oidm.o starttls.o index.o sets.o referral.o root_dse.o \
45 sasl.o module.o mra.o mods.o sl_malloc.o limits.o \
46 backglue.o operational.o matchedValues.o cancel.o syncrepl.o \
47 backover.o ctxcsn.o ldapsync.o sessionlog.o $(@PLAT@_OBJS)
49 LDAP_INCDIR= ../../include -I$(srcdir)/slapi
50 LDAP_LIBDIR= ../../libraries
53 SLAPD_STATIC_DEPENDS=@SLAPD_NO_STATIC@ libbackends.a
54 SLAPD_STATIC_BACKENDS=@SLAPD_STATIC_BACKENDS@
55 SLAPD_DYNAMIC_BACKENDS=@SLAPD_DYNAMIC_BACKENDS@
57 SLAPI_LIBS=@LIBSLAPI@ @SLAPI_LIBS@
59 XDEFS = $(MODULES_CPPFLAGS)
60 XLDFLAGS = $(MODULES_LDFLAGS)
62 XLIBS = $(SLAPD_STATIC_DEPENDS) $(SLAPD_L)
63 XXLIBS = $(LDBM_LIBS) $(SLAPD_LIBS) $(SECURITY_LIBS) $(LUTIL_LIBS)
64 XXXLIBS = $(LTHREAD_LIBS) $(SLAPI_LIBS) $(MODULES_LIBS)
66 BUILD_OPT = "--enable-slapd"
67 BUILD_SRV = @BUILD_SLAPD@
69 all-local-srv: all-cffiles
71 NT_SLAPD_DEPENDS = slapd.exp
72 NT_SLAPD_OBJECTS = slapd.exp symdummy.o $(OBJS) version.o
74 UNIX_SLAPD_DEPENDS = $(SLAPD_STATIC_DEPENDS) version.o $(SLAPD_L)
75 UNIX_SLAPD_OBJECTS = $(OBJS) version.o
77 SLAPD_DEPENDS = $(@PLAT@_SLAPD_DEPENDS)
78 SLAPD_OBJECTS = $(@PLAT@_SLAPD_OBJECTS)
80 # Notes about slapd for Windows
81 # =============================
82 # slapd.exe must export all of its global symbols, just like a DLL.
83 # The purpose of this is to allow dynamic modules (dynamic backends
84 # or external dynamic modules) to bind with the symbols at run-time.
86 # Exporting symbols from an .EXE is a bit tricky and involves multiple
87 # steps. First a .DEF file must be generated. The .DEF file indicates
88 # the set of symbols that are to be exported. Many times, it's possible
89 # to manually create this file with an editor. However, with slapd,
90 # we want to export EVERY global symbol that it knows about (NOT including
91 # symbols that are imported from other DLLs). The set of symbols to
92 # export INCLUDES symbols from all static libraries that slapd gets
93 # linked with, e.g. avl, ldbm, lunicode, lutil, etc. This list
94 # will also include liblber and libldap_r if they were built as static
95 # libraries. ALSO included will be symbols from other STATIC libraries
96 # outside the domain of the OpenLDAP source tree, e.g. regex, ltdl,
97 # crypto, ssl, sasl, etc. (If these libraries are dynamic, we won't want
98 # to include their symbols in the list). The correct set of symbols
99 # CAN be determined at build time. The slapd.def target automatically
100 # determines the correct set of symbols and generates the slapd.def file.
102 # The slapd.def file, serving multiple purposes, will:
104 # 1) be used to generate libslapd.a, the import library for slapd.exe.
106 # 2) be used to generate the symdummy.c file.
108 # 3) be used to help create slapd.exp, the binary-formated slapd export file.
110 # The import library is used by dynamic modules at link time. With this
111 # library, dynamic modules indicate to the linker that it will resolve
112 # these symbols from the slapd.exe binary at run-time. Of course, whenever
113 # a module imports dynamic symbols, those symbols should be marked with
114 # the __declspec(dllimport) directive in the header files that the dynamic
115 # modules build with. In OpenLDAP, this is handled automatically in the
116 # header files. (See ldap_cdefs.h for an explanation). Writers of
117 # dynamic backend modules should keep in mind that slapd.exe might export
118 # other global symbols that are not part of OpenLDAP (e.g. regex, ltdl,
119 # crypto, ssl, sasl, etc.) When a writer actually uses (i.e. imports) these
120 # symbols, he must verify that the header files from these external packages
121 # include a mechanism to mark imported symbols with the __declspec(dllimport)
122 # directive. Whether or not such a mechanism exists, the writer must be
123 # able to include these directives appropriately when their symbols are
124 # being imported from slapd.exe. The directive is not completely necessary
125 # for functions, but it is required for variables.
127 # The symdummy.c file basically references EVERY symbol available to slapd.exe,
128 # including symbols that slapd.exe never actually refereneced. The file
129 # is compiled and included at link time. Without this object file, slapd.exe
130 # would NOT export symbols that it never referenced. The reason that these
131 # symbols must still be exported is because a dynamic module may want to
132 # use a symbol even if it had not been referenced by slapd.exe.
136 # slapd.def REALLY depends upon all slapd objects and all static libraries
137 # included in $(LIBS), including static libraries outside of OpenLDAP.
138 # When slapd.def is built, the absolute paths to all static libraries
139 # (both inside and outside of OpenLDAP) are generated. We don't have
140 # any way to include this generated list as a dependency of slapd.def (sigh).
141 # Thus, we do the best we can by depending on version.o, which depends
142 # on its own very long list of dependencies.
144 slapd.def: libbackends.a version.o
145 @for i in $(LDFLAGS) ; do \
146 path=`expr "$$i" : "-L\(.*\)"`; \
147 if test $$? != 0; then continue; fi; \
148 paths="$$paths $$path"; \
151 for i in $(OBJS) version.o $(LIBS) ; do \
156 base=`expr "$$i" : "-l\(.*\)"`; \
157 for p in $$paths ; do \
158 for ext in la dll a ; do \
159 path=$$p/lib$$base.$$ext; \
160 test ! -f $$path && continue; \
161 if test $$ext = la ; then \
162 for t in dlname old_library ; do \
163 line=`grep "^$$t=" $$path`; \
164 lib=`expr "$$line" : "[^']*'\(.*\)'"`; \
165 test -n "$$lib" && test -f $$p/$$lib && \
166 path=$$p/$$lib && break; \
168 test $$t = dlname && ext=dll; \
169 test $$t = old_library && ext=a; \
171 if test $$ext = a ; then \
177 test -n "$$done" && break; \
179 test -z "$$obj" && continue; \
184 objs="$$objs $$obj"; \
186 echo dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
187 --output-def $@.tmp $$objs; \
188 dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
189 --output-def $@.tmp $$objs;
191 $(SED) -e 1,2d -e 's/ @ [0-9][0-9]*//' $@.tmp | sort >> $@
194 symdummy.c: slapd.def
196 @echo "generating $@..."; \
197 echo "static void never_called() {" > $@.tmp; \
198 cat $< | while read line; \
203 echo "int $$2();" >> $@; \
204 echo "$$2();" >> $@.tmp; \
207 echo "extern int $$2;" >> $@; \
208 echo "$$2 = 0;" >> $@.tmp; \
213 echo "}" >> $@.tmp; \
217 libslapd.a: symdummy.o
218 dlltool --dllname slapd.exe --input-def slapd.def --output-lib $@
220 slapd.exp: libslapd.a
221 @echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
222 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
223 $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
224 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
226 @echo dlltool --dllname slapd.exe --input-def slapd.def \
227 --base-file slapd.base --output-exp $@; \
228 dlltool --dllname slapd.exe --input-def slapd.def \
229 --base-file slapd.base --output-exp $@; \
230 echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
231 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
232 $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
233 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
235 @echo dlltool --dllname slapd.exe --input-def slapd.def \
236 --base-file slapd.base --output-exp $@; \
237 dlltool --dllname slapd.exe --input-def slapd.def \
238 --base-file slapd.base --output-exp $@
240 slapi/.libs/libslapi.a: FORCE
241 (cd slapi; $(MAKE) $(MFLAGS) all)
243 libslapi.a: slapi/.libs/libslapi.a
244 cp slapi/.libs/libslapi.a .
246 slapd: $(SLAPD_DEPENDS) @LIBSLAPI@
247 $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) \
251 $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS)
253 tools $(SLAPD_DYNAMIC_BACKENDS): slapd
254 cd $@; $(MAKE) $(MFLAGS) all
258 # In Windows, dynamic backends have to be built after slapd. For this
259 # reason, we only build static backends now and dynamic backends later.
262 @if test -n "$(SLAPD_STATIC_BACKENDS)"; then \
263 echo "building static backends..."; \
264 for i in XX $(SLAPD_STATIC_BACKENDS); do \
265 if test $$i != XX; then \
266 echo " "; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \
267 ( cd $$i; $(MAKE) $(MFLAGS) all ); \
268 if test $$? != 0; then exit 1; fi; \
274 libbackends.a: .backend
277 @-for i in back-*/*.a; do \
281 pre=`echo $$i | $(SED) -e 's/\/.*$$//' -e 's/back-//'`; \
285 $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \
286 $(RM) *.o __.SYMDEF ________64ELEL_ ; \
287 echo "added backend library $$i"; \
291 @mv -f tmp/libbackends.a ./libbackends.a
293 @if test ! -z "$(RANLIB)" ; then \
294 $(RANLIB) libbackends.a; \
296 @ls -l libbackends.a; echo ""
300 $(MKVERSION) -s -n Versionstr slapd > $@
302 version.o: version.c $(OBJS) $(SLAPD_LIBDEPEND)
304 depend-local-srv: FORCE
305 @for i in back-* shell-backends slapi tools; do \
306 if test -d $$i -a -f $$i/Makefile ; then \
307 echo; echo " cd $$i; $(MAKE) $(MFLAGS) depend"; \
308 ( cd $$i; $(MAKE) $(MFLAGS) depend ); \
309 if test $$? != 0 ; then exit 1; fi ; \
315 rm -f *.exp *.def *.base *.a *.objs symdummy.c
317 clean-local-srv: FORCE
318 @for i in back-* shell-backends slapi tools; do \
319 if test -d $$i -a -f $$i/Makefile ; then \
320 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
321 ( cd $$i; $(MAKE) $(MFLAGS) clean ); \
322 if test $$? != 0 ; then exit 1; fi ; \
325 rm -f *.tmp all-cffiles
327 veryclean-local-srv: FORCE
328 @for i in back-* shell-backends slapi tools; do \
329 if test -d $$i -a -f $$i/Makefile ; then \
330 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
331 ( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \
335 install-local-srv: install-slapd install-conf install-schema install-tools
338 -$(MKDIR) $(DESTDIR)$(libexecdir)
339 -$(MKDIR) $(DESTDIR)$(localstatedir)
340 $(LTINSTALL) $(INSTALLFLAGS) -s -m 755 \
341 slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
342 @for i in back-* shell-backends slapi tools; do \
343 if test -d $$i -a -f $$i/Makefile ; then \
344 echo; echo " cd $$i; $(MAKE) $(MFLAGS) install"; \
345 ( cd $$i; $(MAKE) $(MFLAGS) install ); \
346 if test $$? != 0 ; then exit 1; fi ; \
350 all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS) tools
351 @if test $(PLAT) = NT; then \
352 sysconfdir=`cygpath -w $(sysconfdir) | \
353 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
354 localstatedir=`cygpath -w $(localstatedir) | \
355 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
356 moduledir=`cygpath -w $(moduledir) | \
357 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
359 sysconfdir=$(sysconfdir); \
360 localstatedir=$(localstatedir); \
361 moduledir=$(moduledir); \
363 $(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \
364 -e "s;%LOCALSTATEDIR%;$$localstatedir;" \
365 -e "s;%MODULEDIR%;$$moduledir;" \
366 $(srcdir)/slapd.conf > slapd.conf.tmp ; \
369 install-schema: FORCE
370 @-$(MKDIR) $(DESTDIR)$(schemadir)
371 i="$(srcdir)/schema/README" ; \
372 SF=`basename $$i` ; \
373 SD="$(DESTDIR)$(schemadir)/$$SF" ; \
374 echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
375 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD
376 for i in $(srcdir)/schema/*.schema ; do \
377 SF=`basename $$i` ; \
378 SD="$(DESTDIR)$(schemadir)/$$SF" ; \
379 if test ! -f $$SD ; then \
380 echo "installing $$SF in $(schemadir)" ; \
381 echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
382 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
384 echo "PRESERVING EXISTING SCHEMA FILE $$SD" ; \
386 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD.default ; \
390 @-$(MKDIR) $(DESTDIR)$(sysconfdir)
391 @-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data
392 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf.default
393 if test ! -f $(DESTDIR)$(sysconfdir)/slapd.conf; then \
394 echo "installing slapd.conf in $(sysconfdir)"; \
395 echo "$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \
396 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \
398 echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.conf" ; \
402 @-$(MKDIR) $(DESTDIR)$(sbindir)
403 (cd tools; $(MAKE) $(MFLAGS) install)