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