3 ## Makefile.in for slapd
6 XPROGRAMS=sslapd libbackends.a .backend
10 NT_OBJS = nt_svc.o ../../libraries/liblutil/slapdmsg.res
12 SRCS = main.c daemon.c connection.c search.c filter.c add.c cr.c \
13 attr.c entry.c config.c backend.c result.c operation.c \
14 dn.c compare.c modify.c delete.c modrdn.c ch_malloc.c \
15 value.c ava.c bind.c unbind.c abandon.c filterentry.c \
16 phonetic.c acl.c str2filter.c aclparse.c init.c user.c \
17 repl.c lock.c controls.c extended.c kerberos.c passwd.c \
18 schema.c schema_check.c schema_init.c schema_prep.c \
19 schemaparse.c ad.c at.c mr.c syntax.c oc.c saslauthz.c \
20 oidm.c starttls.c index.c sets.c referral.c \
21 root_dse.c sasl.c module.c suffixalias.c mra.c mods.c \
22 limits.c backglue.c operational.c matchedValues.c cancel.c \
25 OBJS = main.o daemon.o connection.o search.o filter.o add.o cr.o \
26 attr.o entry.o config.o backend.o result.o operation.o \
27 dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \
28 value.o ava.o bind.o unbind.o abandon.o filterentry.o \
29 phonetic.o acl.o str2filter.o aclparse.o init.o user.o \
30 repl.o lock.o controls.o extended.o kerberos.o passwd.o \
31 schema.o schema_check.o schema_init.o schema_prep.o \
32 schemaparse.o ad.o at.o mr.o syntax.o oc.o saslauthz.o \
33 oidm.o starttls.o index.o sets.o referral.o \
34 root_dse.o sasl.o module.o suffixalias.o mra.o mods.o \
35 limits.o backglue.o operational.o matchedValues.o cancel.o \
38 LDAP_INCDIR= ../../include -I$(srcdir)/slapi
39 LDAP_LIBDIR= ../../libraries
42 SLAPD_STATIC_DEPENDS=@SLAPD_NO_STATIC@ libbackends.a
43 SLAPD_STATIC_BACKENDS=@SLAPD_STATIC_BACKENDS@
44 SLAPD_DYNAMIC_BACKENDS=@SLAPD_DYNAMIC_BACKENDS@
46 XDEFS = $(MODULES_CPPFLAGS)
47 XLDFLAGS = $(MODULES_LDFLAGS)
49 XLIBS = $(SLAPD_STATIC_DEPENDS) $(SLAPD_L)
50 XXLIBS = $(LDBM_LIBS) $(SLAPD_LIBS) $(SECURITY_LIBS) $(LDIF_LIBS) $(LUTIL_LIBS)
51 XXXLIBS = $(LTHREAD_LIBS) $(SLAPI_LIBS) @LIBSLAPI@ $(MODULES_LIBS)
53 BUILD_OPT = "--enable-slapd"
54 BUILD_SRV = @BUILD_SLAPD@
56 all-local-srv: all-cffiles
58 NT_SLAPD_DEPENDS = slapd.exp
59 NT_SLAPD_OBJECTS = slapd.exp symdummy.o $(OBJS) version.o
61 UNIX_SLAPD_DEPENDS = $(SLAPD_STATIC_DEPENDS) version.o $(SLAPD_L)
62 UNIX_SLAPD_OBJECTS = $(OBJS) version.o
64 SLAPD_DEPENDS = $(@PLAT@_SLAPD_DEPENDS)
65 SLAPD_OBJECTS = $(@PLAT@_SLAPD_OBJECTS)
67 # Notes about slapd for Windows
68 # =============================
69 # slapd.exe must export all of its global symbols, just like a DLL.
70 # The purpose of this is to allow dynamic modules (dynamic backends
71 # or external dynamic modules) to bind with the symbols at run-time.
73 # Exporting symbols from an .EXE is a bit tricky and involves multiple
74 # steps. First a .DEF file must be generated. The .DEF file indicates
75 # the set of symbols that are to be exported. Many times, it's possible
76 # to manually create this file with an editor. However, with slapd,
77 # we want to export EVERY global symbol that it knows about (NOT including
78 # symbols that are imported from other DLLs). The set of symbols to
79 # export INCLUDES symbols from all static libraries that slapd gets
80 # linked with, e.g. avl, ldbm, ldif, lunicode, lutil, etc. This list
81 # will also include liblber and libldap_r if they were built as static
82 # libraries. ALSO included will be symbols from other STATIC libraries
83 # outside the domain of the OpenLDAP source tree, e.g. regex, ltdl,
84 # crypto, ssl, sasl, etc. (If these libraries are dynamic, we won't want
85 # to include their symbols in the list). The correct set of symbols
86 # CAN be determined at build time. The slapd.def target automatically
87 # determines the correct set of symbols and generates the slapd.def file.
89 # The slapd.def file, serving multiple purposes, will:
91 # 1) be used to generate libslapd.a, the import library for slapd.exe.
93 # 2) be used to generate the symdummy.c file.
95 # 3) be used to help create slapd.exp, the binary-formated slapd export file.
97 # The import library is used by dynamic modules at link time. With this
98 # library, dynamic modules indicate to the linker that it will resolve
99 # these symbols from the slapd.exe binary at run-time. Of course, whenever
100 # a module imports dynamic symbols, those symbols should be marked with
101 # the __declspec(dllimport) directive in the header files that the dynamic
102 # modules build with. In OpenLDAP, this is handled automatically in the
103 # header files. (See ldap_cdefs.h for an explanation). Writers of
104 # dynamic backend modules should keep in mind that slapd.exe might export
105 # other global symbols that are not part of OpenLDAP (e.g. regex, ltdl,
106 # crypto, ssl, sasl, etc.) When a writer actually uses (i.e. imports) these
107 # symbols, he must verify that the header files from these external packages
108 # include a mechanism to mark imported symbols with the __declspec(dllimport)
109 # directive. Whether or not such a mechanism exists, the writer must be
110 # able to include these directives appropriately when their symbols are
111 # being imported from slapd.exe. The directive is not completely necessary
112 # for functions, but it is required for variables.
114 # The symdummy.c file basically references EVERY symbol available to slapd.exe,
115 # including symbols that slapd.exe never actually refereneced. The file
116 # is compiled and included at link time. Without this object file, slapd.exe
117 # would NOT export symbols that it never referenced. The reason that these
118 # symbols must still be exported is because a dynamic module may want to
119 # use a symbol even if it had not been referenced by slapd.exe.
123 # slapd.def REALLY depends upon all slapd objects and all static libraries
124 # included in $(LIBS), including static libraries outside of OpenLDAP.
125 # When slapd.def is built, the absolute paths to all static libraries
126 # (both inside and outside of OpenLDAP) are generated. We don't have
127 # any way to include this generated list as a dependency of slapd.def (sigh).
128 # Thus, we do the best we can by depending on version.o, which depends
129 # on its own very long list of dependencies.
131 slapd.def: libbackends.a version.o
132 @for i in $(LDFLAGS) ; do \
133 path=`expr "$$i" : "-L\(.*\)"`; \
134 if test $$? != 0; then continue; fi; \
135 paths="$$paths $$path"; \
138 for i in $(OBJS) version.o $(LIBS) ; do \
143 base=`expr "$$i" : "-l\(.*\)"`; \
144 for p in $$paths ; do \
145 for ext in la dll a ; do \
146 path=$$p/lib$$base.$$ext; \
147 test ! -f $$path && continue; \
148 if test $$ext = la ; then \
149 for t in dlname old_library ; do \
150 line=`grep "^$$t=" $$path`; \
151 lib=`expr "$$line" : "[^']*'\(.*\)'"`; \
152 test -n "$$lib" && test -f $$p/$$lib && \
153 path=$$p/$$lib && break; \
155 test $$t = dlname && ext=dll; \
156 test $$t = old_library && ext=a; \
158 if test $$ext = a ; then \
164 test -n "$$done" && break; \
166 test -z "$$obj" && continue; \
171 objs="$$objs $$obj"; \
173 echo dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
174 --output-def $@.tmp $$objs; \
175 dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
176 --output-def $@.tmp $$objs;
178 $(SED) -e 1,2d -e 's/ @ [0-9][0-9]*//' $@.tmp | sort >> $@
181 symdummy.c: slapd.def
183 @echo "generating $@..."; \
184 echo "static void never_called() {" > $@.tmp; \
185 cat $< | while read line; \
190 echo "int $$2();" >> $@; \
191 echo "$$2();" >> $@.tmp; \
194 echo "extern int $$2;" >> $@; \
195 echo "$$2 = 0;" >> $@.tmp; \
200 echo "}" >> $@.tmp; \
204 libslapd.a: symdummy.o
205 dlltool --dllname slapd.exe --input-def slapd.def --output-lib $@
207 slapd.exp: libslapd.a
208 @echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
209 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
210 $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
211 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
213 @echo dlltool --dllname slapd.exe --input-def slapd.def \
214 --base-file slapd.base --output-exp $@; \
215 dlltool --dllname slapd.exe --input-def slapd.def \
216 --base-file slapd.base --output-exp $@; \
217 echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
218 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
219 $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
220 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
222 @echo dlltool --dllname slapd.exe --input-def slapd.def \
223 --base-file slapd.base --output-exp $@; \
224 dlltool --dllname slapd.exe --input-def slapd.def \
225 --base-file slapd.base --output-exp $@
228 (cd slapi; $(MAKE) $(MFLAGS) all)
229 cp slapi/.libs/libslapi.a .
231 .slapi: $(SLAPD_OBJECTS)
232 $(AR) ruv slapi/libtmpslapd.a $(OBJS)
233 (cd slapi; $(MAKE) $(MFLAGS) all)
235 slapd: $(SLAPD_DEPENDS) @LIBSLAPI@
236 $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) \
240 $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS)
242 tools $(SLAPD_DYNAMIC_BACKENDS): slapd
243 cd $@; $(MAKE) $(MFLAGS) all
247 # In Windows, dynamic backends have to be built after slapd. For this
248 # reason, we only build static backends now and dynamic backends later.
251 @if test -n "$(SLAPD_STATIC_BACKENDS)"; then \
252 echo "building static backends..."; \
253 for i in XX $(SLAPD_STATIC_BACKENDS); do \
254 if test $$i != XX; then \
255 echo " "; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \
256 ( cd $$i; $(MAKE) $(MFLAGS) all ); \
257 if test $$? != 0; then exit 1; fi; \
263 libbackends.a: .backend
266 @-for i in back-*/*.a; do \
270 pre=`echo $$i | $(SED) -e 's/\/.*$$//' -e 's/back-//'`; \
274 $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \
275 $(RM) *.o __.SYMDEF ________64ELEL_ ; \
276 echo "added backend library $$i"; \
280 @mv -f tmp/libbackends.a ./libbackends.a
282 @if test ! -z "$(RANLIB)" ; then \
283 $(RANLIB) libbackends.a; \
285 @ls -l libbackends.a; echo ""
287 version.c: $(OBJS) $(SLAPD_LIBDEPEND)
289 $(MKVERSION) -s -n Versionstr slapd > $@
291 depend-local-srv: FORCE
292 @for i in back-* shell-backends slapi tools; do \
293 if test -d $$i -a -f $$i/Makefile ; then \
294 echo; echo " cd $$i; $(MAKE) $(MFLAGS) depend"; \
295 ( cd $$i; $(MAKE) $(MFLAGS) depend ); \
296 if test $$? != 0 ; then exit 1; fi ; \
302 rm -f *.exp *.def *.base *.a *.objs symdummy.c
304 clean-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) clean"; \
308 ( cd $$i; $(MAKE) $(MFLAGS) clean ); \
309 if test $$? != 0 ; then exit 1; fi ; \
312 rm -f *.tmp all-cffiles
314 veryclean-local-srv: FORCE
315 @for i in back-* shell-backends slapi tools; do \
316 if test -d $$i -a -f $$i/Makefile ; then \
317 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \
318 ( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \
322 install-local-srv: install-slapd install-conf install-schema install-tools
325 -$(MKDIR) $(DESTDIR)$(libexecdir)
326 -$(MKDIR) $(DESTDIR)$(localstatedir)
327 $(LTINSTALL) $(INSTALLFLAGS) -s -m 755 \
328 slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
329 @for i in back-* shell-backends slapi tools; do \
330 if test -d $$i -a -f $$i/Makefile ; then \
331 echo; echo " cd $$i; $(MAKE) $(MFLAGS) install"; \
332 ( cd $$i; $(MAKE) $(MFLAGS) install ); \
333 if test $$? != 0 ; then exit 1; fi ; \
337 all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS) tools
338 @if test $(PLAT) = NT; then \
339 sysconfdir=`cygpath -w $(sysconfdir) | \
340 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
341 localstatedir=`cygpath -w $(localstatedir) | \
342 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
343 moduledir=`cygpath -w $(moduledir) | \
344 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
346 sysconfdir=$(sysconfdir); \
347 localstatedir=$(localstatedir); \
348 moduledir=$(moduledir); \
350 $(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \
351 -e "s;%LOCALSTATEDIR%;$$localstatedir;" \
352 -e "s;%MODULEDIR%;$$moduledir;" \
353 $(srcdir)/slapd.conf > slapd.conf.tmp ; \
356 install-schema: FORCE
357 @-$(MKDIR) $(DESTDIR)$(schemadir)
358 for i in $(srcdir)/schema/*.schema ; do \
359 SF=`basename $$i` ; \
360 SD="$(DESTDIR)$(schemadir)/$$SF" ; \
361 if test ! -f $$SD ; then \
362 echo "installing $$SF in $(schemadir)" ; \
363 echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
364 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
366 echo "PRESERVING EXISTING SCHEMA FILE $$SD" ; \
368 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD.default ; \
372 @-$(MKDIR) $(DESTDIR)$(sysconfdir)
373 @-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data
374 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf.default
375 if test ! -f $(DESTDIR)$(sysconfdir)/slapd.conf; then \
376 echo "installing slapd.conf in $(sysconfdir)"; \
377 echo "$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \
378 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \
380 echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.conf" ; \
384 @-$(MKDIR) $(DESTDIR)$(sbindir)
385 (cd tools; $(MAKE) $(MFLAGS) install)