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