]> git.sur5r.net Git - openldap/blob - servers/slapd/Makefile.in
Windoes compatibility tweaks
[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-2004 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 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 limits.c \
37                 backglue.c operational.c matchedValues.c cancel.c syncrepl.c \
38                 backover.c ctxcsn.c ldapsync.c sessionlog.c \
39                 slapadd.c slapcat.c slapcommon.c slapdn.c slapindex.c \
40                 slappasswd.c slaptest.c slapauth.c slapacl.c \
41                 $(@PLAT@_SRCS)
42
43 OBJS    = main.o globals.o config.o daemon.o \
44                 connection.o search.o filter.o add.o cr.o \
45                 attr.o entry.o backend.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 limits.o \
54                 backglue.o operational.o matchedValues.o cancel.o syncrepl.o \
55                 backover.o ctxcsn.o ldapsync.o sessionlog.o \
56                 slapadd.o slapcat.o slapcommon.o slapdn.o slapindex.o \
57                 slappasswd.o slaptest.o slapauth.o slapacl.o \
58                 $(@PLAT@_OBJS)
59
60 LDAP_INCDIR= ../../include -I$(srcdir)/slapi
61 LDAP_LIBDIR= ../../libraries
62
63 SLAP_DIR=
64 SLAPD_STATIC_DEPENDS=@SLAPD_NO_STATIC@ libbackends.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) liboverlays.a
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 = liboverlays.a $(@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                 *.o | *.a) \
193                     obj=$$i; \
194             esac; \
195             objs="$$objs $$obj"; \
196         done; \
197         echo dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
198                         --output-def $@.tmp $$objs; \
199         dlltool --exclude-symbols main,ServiceMain@8 --export-all-symbols \
200                         --output-def $@.tmp $$objs;
201         echo EXPORTS > $@
202         $(SED) -e 1,2d -e 's/ @ [0-9][0-9]*//' $@.tmp | sort >> $@
203         $(RM) $@.tmp
204
205 symdummy.c: slapd.def
206         $(RM) $@
207         @echo "generating $@..."; \
208         echo "static void never_called() {" > $@.tmp; \
209         cat $< | while read line; \
210         do \
211             set dummy $$line; \
212             case $$# in \
213                 3) \
214                     echo "int $$2();" >> $@; \
215                     echo "$$2();" >> $@.tmp; \
216                     ;; \
217                 4) \
218                     echo "extern int $$2;" >> $@; \
219                     echo "$$2 = 0;" >> $@.tmp; \
220                     ;; \
221             esac; \
222         done; \
223         echo "" >> $@; \
224         echo "}" >> $@.tmp; \
225         cat $@.tmp >> $@; \
226         $(RM) $@.tmp
227
228 libslapd.a: symdummy.o
229         dlltool --dllname slapd.exe --input-def slapd.def --output-lib $@
230
231 slapd.exp: libslapd.a
232         @echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
233                 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
234         $(LTLINK) -Wl,--base-file,slapd.base -o slapd \
235                 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
236         $(RM) slapd.exe
237         @echo dlltool --dllname slapd.exe --input-def slapd.def \
238                 --base-file slapd.base --output-exp $@; \
239         dlltool --dllname slapd.exe --input-def slapd.def \
240                 --base-file slapd.base --output-exp $@; \
241         echo $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
242                 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS); \
243         $(LTLINK) -Wl,--base-file,slapd.base -o slapd $@ \
244                 $(OBJS) symdummy.o version.o $(LIBS) $(WRAP_LIBS)
245         $(RM) slapd.exe
246         @echo dlltool --dllname slapd.exe --input-def slapd.def \
247                 --base-file slapd.base --output-exp $@; \
248         dlltool --dllname slapd.exe --input-def slapd.def \
249                 --base-file slapd.base --output-exp $@
250
251 slapi/.libs/libslapi.a: FORCE
252         (cd slapi; $(MAKE) $(MFLAGS) all)
253
254 libslapi.a: slapi/.libs/libslapi.a
255         cp slapi/.libs/libslapi.a .
256
257 slapd: $(SLAPD_DEPENDS) @LIBSLAPI@
258         $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) \
259                 $(WRAP_LIBS)
260         rm -f $(SLAPTOOLS)
261         for i in $(SLAPTOOLS); do \
262                 $(LN_S) slapd$(EXEEXT) $$i$(EXEEXT); done
263
264
265 sslapd: version.o
266         $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS)
267
268 $(SLAPD_DYNAMIC_BACKENDS): slapd
269         cd $@; $(MAKE) $(MFLAGS) all
270         @touch $@
271
272 #
273 # In Windows, dynamic backends have to be built after slapd. For this
274 # reason, we only build static backends now and dynamic backends later.
275 #
276 .backend: FORCE
277         @if test -n "$(SLAPD_STATIC_BACKENDS)"; then \
278             echo "building static backends..."; \
279             for i in XX $(SLAPD_STATIC_BACKENDS); do \
280                 if test $$i != XX; then \
281                     echo " "; echo "  cd $$i; $(MAKE) $(MFLAGS) all"; \
282                     ( cd $$i; $(MAKE) $(MFLAGS) all ); \
283                     if test $$? != 0; then exit 1; fi; \
284                 fi; \
285             done; \
286             echo " "; \
287         fi
288
289 libbackends.a: .backend
290         @$(RM) -r tmp
291         @$(MKDIR) tmp
292         @-for i in back-*/*.a; do \
293                 ( \
294                   cd tmp; \
295                   $(AR) x ../$$i; \
296                   pre=`echo $$i | $(SED) -e 's/\/.*$$//' -e 's/back-//'`; \
297                   for j in *.o; do \
298                         mv $$j $${pre}$$j; \
299                   done; \
300                   $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \
301                   $(RM) *.o __.SYMDEF  ________64ELEL_ ; \
302                   echo "added backend library $$i"; \
303                   echo ""; \
304                 ); \
305         done
306         @mv -f tmp/libbackends.a ./libbackends.a
307         @$(RM) -r tmp
308         @if test ! -z "$(RANLIB)" ; then \
309                 $(RANLIB) libbackends.a; \
310         fi
311         @ls -l libbackends.a; echo ""
312
313 liboverlays.a: FORCE
314         @cd overlays; $(MAKE) $(MFLAGS) all
315
316 version.c: Makefile
317         @-$(RM) $@
318         $(MKVERSION) -s -n Versionstr slapd > $@
319
320 version.o: version.c $(OBJS) $(SLAPD_LIBDEPEND) 
321
322 depend-local-srv: FORCE
323         @for i in $(SUBDIRS); do \
324                 if test -d $$i -a -f $$i/Makefile ; then \
325                         echo; echo "  cd $$i; $(MAKE) $(MFLAGS) depend"; \
326                         ( cd $$i; $(MAKE) $(MFLAGS) depend ); \
327                         if test $$? != 0 ; then exit 1; fi ; \
328                 fi; \
329         done
330         @echo ""
331
332 clean-local:
333         rm -f *.exp *.def *.base *.a *.objs symdummy.c
334
335 clean-local-srv: FORCE
336         @for i in $(SUBDIRS); do \
337                 if test -d $$i -a -f $$i/Makefile ; then \
338                         echo; echo "  cd $$i; $(MAKE) $(MFLAGS) clean"; \
339                         ( cd $$i; $(MAKE) $(MFLAGS) clean ); \
340                         if test $$? != 0 ; then exit 1; fi ; \
341                 fi; \
342         done
343         rm -f *.tmp all-cffiles
344
345 veryclean-local-srv: FORCE
346         @for i in $(SUBDIRS); do \
347                 if test -d $$i -a -f $$i/Makefile ; then \
348                         echo; echo "  cd $$i; $(MAKE) $(MFLAGS) clean"; \
349                         ( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \
350                 fi; \
351         done
352
353 install-local-srv: install-slapd install-tools \
354         install-conf install-db-config install-schema install-tools
355
356 install-slapd: FORCE
357         -$(MKDIR) $(DESTDIR)$(libexecdir)
358         -$(MKDIR) $(DESTDIR)$(localstatedir)/run
359         $(LTINSTALL) $(INSTALLFLAGS) -s -m 755 \
360                 slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
361         @for i in $(SUBDIRS); do \
362             if test -d $$i -a -f $$i/Makefile ; then \
363                 echo; echo "  cd $$i; $(MAKE) $(MFLAGS) install"; \
364                 ( cd $$i; $(MAKE) $(MFLAGS) install ); \
365                 if test $$? != 0 ; then exit 1; fi ; \
366             fi; \
367         done
368
369 all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS)
370         @if test $(PLAT) = NT; then \
371             sysconfdir=`cygpath -w $(sysconfdir) | \
372                 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
373             localstatedir=`cygpath -w $(localstatedir) | \
374                 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
375             moduledir=`cygpath -w $(moduledir) | \
376                 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \
377         else \
378             sysconfdir=$(sysconfdir); \
379             localstatedir=$(localstatedir); \
380             moduledir=$(moduledir); \
381         fi; \
382         $(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \
383                 -e "s;%LOCALSTATEDIR%;$$localstatedir;" \
384                 -e "s;%MODULEDIR%;$$moduledir;" \
385                 $(srcdir)/slapd.conf > slapd.conf.tmp ; \
386         touch all-cffiles
387
388 install-schema: FORCE
389         @-$(MKDIR) $(DESTDIR)$(schemadir)
390         i="$(srcdir)/schema/README" ; \
391         SF=`basename $$i` ; \
392         SD="$(DESTDIR)$(schemadir)/$$SF" ; \
393         echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
394         $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD
395         for i in $(srcdir)/schema/*.schema ; do \
396                 SF=`basename $$i` ; \
397                 SD="$(DESTDIR)$(schemadir)/$$SF" ; \
398                 if test ! -f $$SD ; then \
399                         echo "installing $$SF in $(schemadir)" ; \
400                         echo $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
401                         $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD ; \
402                 else \
403                         echo "PRESERVING EXISTING SCHEMA FILE $$SD" ; \
404                 fi ; \
405                 $(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD.default ; \
406         done
407
408 install-conf: FORCE
409         @-$(MKDIR) $(DESTDIR)$(sysconfdir)
410         $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf.default
411         if test ! -f $(DESTDIR)$(sysconfdir)/slapd.conf; then \
412                 echo "installing slapd.conf in $(sysconfdir)"; \
413                 echo "$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \
414                 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \
415         else \
416                 echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.conf" ; \
417         fi
418
419 install-db-config: FORCE
420         @-$(MKDIR) $(DESTDIR)$(localstatedir) $(DESTDIR)$(sysconfdir)
421         @-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data
422         $(INSTALL) $(INSTALLFLAGS) -m 600 $(srcdir)/DB_CONFIG \
423                 $(DESTDIR)$(localstatedir)/openldap-data/DB_CONFIG.example
424         $(INSTALL) $(INSTALLFLAGS) -m 600 $(srcdir)/DB_CONFIG \
425                 $(DESTDIR)$(sysconfdir)/DB_CONFIG.example
426
427 install-tools: FORCE
428         -$(MKDIR) $(DESTDIR)$(sbindir)
429         cd $(DESTDIR)$(sbindir); \
430         rm -f $(SLAPTOOLS); \
431         for i in $(SLAPTOOLS); do \
432                 $(LN_S) $(libexecdir)/slapd $$i; \
433         done
434