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