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