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