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