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