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