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