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