]> git.sur5r.net Git - openldap/blob - servers/slapd/Makefile.in
ITS#2864 don't use sl_mark/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-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 NT_SRCS = nt_svc.c
21 NT_OBJS = nt_svc.o ../../libraries/liblutil/slapdmsg.res
22
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)
36
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)
50
51 LDAP_INCDIR= ../../include -I$(srcdir)/slapi
52 LDAP_LIBDIR= ../../libraries
53
54 SLAP_DIR=
55 SLAPD_STATIC_DEPENDS=@SLAPD_NO_STATIC@ libbackends.a liboverlays.a
56 SLAPD_STATIC_BACKENDS=@SLAPD_STATIC_BACKENDS@
57 SLAPD_DYNAMIC_BACKENDS=@SLAPD_DYNAMIC_BACKENDS@
58
59 SLAPI_LIBS=@LIBSLAPI@ @SLAPI_LIBS@
60
61 XDEFS = $(MODULES_CPPFLAGS)
62 XLDFLAGS = $(MODULES_LDFLAGS)
63
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)
67
68 BUILD_OPT = "--enable-slapd"
69 BUILD_SRV = @BUILD_SLAPD@
70
71 all-local-srv: all-cffiles
72
73 NT_SLAPD_DEPENDS = slapd.exp
74 NT_SLAPD_OBJECTS = slapd.exp symdummy.o $(OBJS) version.o
75
76 UNIX_SLAPD_DEPENDS = $(SLAPD_STATIC_DEPENDS) version.o $(SLAPD_L)
77 UNIX_SLAPD_OBJECTS = $(OBJS) version.o
78
79 SLAPD_DEPENDS = $(@PLAT@_SLAPD_DEPENDS)
80 SLAPD_OBJECTS = $(@PLAT@_SLAPD_OBJECTS)
81
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.
87
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.
103 #
104 # The slapd.def file, serving multiple purposes, will:
105 #
106 # 1) be used to generate libslapd.a, the import library for slapd.exe.
107 #
108 # 2) be used to generate the symdummy.c file.
109 #
110 # 3) be used to help create slapd.exp, the binary-formated slapd export file.
111 #
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.
128 #
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.
135 #
136
137 #
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.
145 #
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"; \
151         done; \
152         objs=""; \
153         for i in $(OBJS) version.o $(LIBS) ; do \
154             obj="" ; \
155             case $$i in \
156                 -l*) \
157                     done="" ;\
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; \
169                                 done; \
170                                 test $$t = dlname && ext=dll; \
171                                 test $$t = old_library && ext=a; \
172                             fi; \
173                             if test $$ext = a ; then \
174                                 obj=$$path; \
175                             fi; \
176                             done=done; \
177                             break; \
178                         done; \
179                         test -n "$$done" && break; \
180                     done; \
181                     test -z "$$obj" && continue; \
182                     ;; \
183                 *.o | *.a) \
184                     obj=$$i; \
185             esac; \
186             objs="$$objs $$obj"; \
187         done; \
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;
192         echo EXPORTS > $@
193         $(SED) -e 1,2d -e 's/ @ [0-9][0-9]*//' $@.tmp | sort >> $@
194         $(RM) $@.tmp
195
196 symdummy.c: slapd.def
197         $(RM) $@
198         @echo "generating $@..."; \
199         echo "static void never_called() {" > $@.tmp; \
200         cat $< | while read line; \
201         do \
202             set dummy $$line; \
203             case $$# in \
204                 3) \
205                     echo "int $$2();" >> $@; \
206                     echo "$$2();" >> $@.tmp; \
207                     ;; \
208                 4) \
209                     echo "extern int $$2;" >> $@; \
210                     echo "$$2 = 0;" >> $@.tmp; \
211                     ;; \
212             esac; \
213         done; \
214         echo "" >> $@; \
215         echo "}" >> $@.tmp; \
216         cat $@.tmp >> $@; \
217         $(RM) $@.tmp
218
219 libslapd.a: symdummy.o
220         dlltool --dllname slapd.exe --input-def slapd.def --output-lib $@
221
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)
227         $(RM) slapd.exe
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)
236         $(RM) slapd.exe
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 $@
241
242 slapi/.libs/libslapi.a: FORCE
243         (cd slapi; $(MAKE) $(MFLAGS) all)
244
245 libslapi.a: slapi/.libs/libslapi.a
246         cp slapi/.libs/libslapi.a .
247
248 slapd: $(SLAPD_DEPENDS) @LIBSLAPI@
249         $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) \
250                 $(WRAP_LIBS)
251
252 sslapd: version.o
253         $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS)
254
255 tools $(SLAPD_DYNAMIC_BACKENDS): slapd
256         cd $@; $(MAKE) $(MFLAGS) all
257         @touch $@
258
259 #
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.
262 #
263 .backend: FORCE
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; \
271                 fi; \
272             done; \
273             echo " "; \
274         fi
275
276 libbackends.a: .backend
277         @$(RM) -r tmp
278         @$(MKDIR) tmp
279         @-for i in back-*/*.a; do \
280                 ( \
281                   cd tmp; \
282                   $(AR) x ../$$i; \
283                   pre=`echo $$i | $(SED) -e 's/\/.*$$//' -e 's/back-//'`; \
284                   for j in *.o; do \
285                         mv $$j $${pre}$$j; \
286                   done; \
287                   $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \
288                   $(RM) *.o __.SYMDEF  ________64ELEL_ ; \
289                   echo "added backend library $$i"; \
290                   echo ""; \
291                 ); \
292         done
293         @mv -f tmp/libbackends.a ./libbackends.a
294         @$(RM) -r tmp
295         @if test ! -z "$(RANLIB)" ; then \
296                 $(RANLIB) libbackends.a; \
297         fi
298         @ls -l libbackends.a; echo ""
299
300 liboverlays.a: FORCE
301         @cd overlays; $(MAKE) $(MFLAGS) all
302
303 version.c: Makefile
304         @-$(RM) $@
305         $(MKVERSION) -s -n Versionstr slapd > $@
306
307 version.o: version.c $(OBJS) $(SLAPD_LIBDEPEND) 
308
309 depend-local-srv: FORCE
310         @for i in back-* shell-backends slapi tools; do \
311                 if test -d $$i -a -f $$i/Makefile ; then \
312                         echo; echo "  cd $$i; $(MAKE) $(MFLAGS) depend"; \
313                         ( cd $$i; $(MAKE) $(MFLAGS) depend ); \
314                         if test $$? != 0 ; then exit 1; fi ; \
315                 fi; \
316         done
317         @echo ""
318
319 clean-local:
320         rm -f *.exp *.def *.base *.a *.objs symdummy.c
321
322 clean-local-srv: FORCE
323         @for i in back-* shell-backends slapi tools; do \
324                 if test -d $$i -a -f $$i/Makefile ; then \
325                         echo; echo "  cd $$i; $(MAKE) $(MFLAGS) clean"; \
326                         ( cd $$i; $(MAKE) $(MFLAGS) clean ); \
327                         if test $$? != 0 ; then exit 1; fi ; \
328                 fi; \
329         done
330         rm -f *.tmp all-cffiles
331
332 veryclean-local-srv: FORCE
333         @for i in back-* shell-backends slapi tools; do \
334                 if test -d $$i -a -f $$i/Makefile ; then \
335                         echo; echo "  cd $$i; $(MAKE) $(MFLAGS) clean"; \
336                         ( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \
337                 fi; \
338         done
339
340 install-local-srv: install-slapd install-conf install-schema install-tools
341
342 install-slapd: FORCE
343         -$(MKDIR) $(DESTDIR)$(libexecdir)
344         -$(MKDIR) $(DESTDIR)$(localstatedir)
345         $(LTINSTALL) $(INSTALLFLAGS) -s -m 755 \
346                 slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
347         @for i in back-* shell-backends slapi tools; do \
348             if test -d $$i -a -f $$i/Makefile ; then \
349                 echo; echo "  cd $$i; $(MAKE) $(MFLAGS) install"; \
350                 ( cd $$i; $(MAKE) $(MFLAGS) install ); \
351                 if test $$? != 0 ; then exit 1; fi ; \
352             fi; \
353         done
354
355 all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS) tools
356         @if test $(PLAT) = NT; then \
357             sysconfdir=`cygpath -w $(sysconfdir) | \
358                 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
359             localstatedir=`cygpath -w $(localstatedir) | \
360                 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
361             moduledir=`cygpath -w $(moduledir) | \
362                 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
363         else \
364             sysconfdir=$(sysconfdir); \
365             localstatedir=$(localstatedir); \
366             moduledir=$(moduledir); \
367         fi; \
368         $(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \
369                 -e "s;%LOCALSTATEDIR%;$$localstatedir;" \
370                 -e "s;%MODULEDIR%;$$moduledir;" \
371                 $(srcdir)/slapd.conf > slapd.conf.tmp ; \
372         touch all-cffiles
373
374 install-schema: FORCE
375         @-$(MKDIR) $(DESTDIR)$(schemadir)
376         i="$(srcdir)/schema/README" ; \
377         SF=`basename $$i` ; \
378         SD="$(DESTDIR)$(schemadir)/$$SF" ; \
379         echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
380         $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD
381         for i in $(srcdir)/schema/*.schema ; do \
382                 SF=`basename $$i` ; \
383                 SD="$(DESTDIR)$(schemadir)/$$SF" ; \
384                 if test ! -f $$SD ; then \
385                         echo "installing $$SF in $(schemadir)" ; \
386                         echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
387                         $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
388                 else \
389                         echo "PRESERVING EXISTING SCHEMA FILE $$SD" ; \
390                 fi ; \
391                 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD.default ; \
392         done
393
394 install-conf: FORCE
395         @-$(MKDIR) $(DESTDIR)$(sysconfdir)
396         @-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data
397         $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf.default
398         if test ! -f $(DESTDIR)$(sysconfdir)/slapd.conf; then \
399                 echo "installing slapd.conf in $(sysconfdir)"; \
400                 echo "$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \
401                 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \
402         else \
403                 echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.conf" ; \
404         fi
405
406 install-tools: FORCE
407         @-$(MKDIR) $(DESTDIR)$(sbindir)
408         (cd tools; $(MAKE) $(MFLAGS) install)
409