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