1## Makefile.in for slapd 2# OpenLDAP: pkg/ldap/servers/slapd/Makefile.in,v 1.186.2.9 2010/04/13 20:23:09 kurt Exp 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 1998-2010 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 16SLAPTOOLS=slapadd slapcat slapdn slapindex slappasswd slaptest slapauth slapacl slapschema 17PROGRAMS=slapd $(SLAPTOOLS) 18XPROGRAMS=sslapd libbackends.a .backend liboverlays.a 19XSRCS=version.c 20 21SUBDIRS=back-* shell-backends slapi overlays 22 23NT_SRCS = nt_svc.c 24NT_OBJS = nt_svc.o ../../libraries/liblutil/slapdmsg.res 25 26SRCS = 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 \ 42 $(@PLAT@_SRCS) 43 44OBJS = 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 \ 60 $(@PLAT@_OBJS) 61 62LDAP_INCDIR= ../../include -I$(srcdir) -I$(srcdir)/slapi -I. 63LDAP_LIBDIR= ../../libraries 64 65SLAP_DIR= 66SLAPD_STATIC_DEPENDS=@SLAPD_NO_STATIC@ libbackends.a liboverlays.a 67SLAPD_STATIC_BACKENDS=@SLAPD_STATIC_BACKENDS@ 68SLAPD_DYNAMIC_BACKENDS=@SLAPD_DYNAMIC_BACKENDS@ 69 70SLAPI_LIBS=@LIBSLAPI@ @SLAPI_LIBS@ 71 72XDEFS = $(MODULES_CPPFLAGS) 73XLDFLAGS = $(MODULES_LDFLAGS) 74 75XLIBS = $(SLAPD_STATIC_DEPENDS) $(SLAPD_L) $(MODULES_LIBS) 76XXLIBS = $(SLAPD_LIBS) $(SECURITY_LIBS) $(LUTIL_LIBS) 77XXXLIBS = $(LTHREAD_LIBS) $(SLAPI_LIBS) 78 79BUILD_OPT = "--enable-slapd" 80BUILD_SRV = @BUILD_SLAPD@ 81 82all-local-srv: all-cffiles 83 84NT_SLAPD_DEPENDS = slapd.exp 85NT_SLAPD_OBJECTS = slapd.exp symdummy.o $(OBJS) version.o 86 87UNIX_SLAPD_DEPENDS = $(SLAPD_STATIC_DEPENDS) version.o $(SLAPD_L) 88UNIX_SLAPD_OBJECTS = $(OBJS) version.o 89 90SLAPD_DEPENDS = $(@PLAT@_SLAPD_DEPENDS) 91SLAPD_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# 157slapd.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]*//' $@.tmp | sort >> $@ 214 $(RM) $@.tmp 215 216symdummy.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 239libslapd.a: symdummy.o 240 dlltool --dllname slapd.exe --input-def slapd.def --output-lib $@ 241 242slapd.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 262slapi/.libs/libslapi.a: FORCE 263 (cd slapi; $(MAKE) $(MFLAGS) all) 264 265libslapi.a: slapi/.libs/libslapi.a 266 cp slapi/.libs/libslapi.a . 267 268slapd: $(SLAPD_DEPENDS) @LIBSLAPI@ 269 $(LTLINK) -o $@ $(SLAPD_OBJECTS) $(LIBS) \ 270 $(WRAP_LIBS) 271 $(RM) $(SLAPTOOLS) 272 for i in $(SLAPTOOLS); do \ 273 $(LN_S) slapd$(EXEEXT) $$i$(EXEEXT); done 274 275 276sslapd: version.o 277 $(LTLINK) -static -o $@ $(OBJS) version.o $(LIBS) $(WRAP_LIBS) 278 279dummy $(SLAPD_DYNAMIC_BACKENDS): slapd 280 cd $@; $(MAKE) $(MFLAGS) all 281 @touch $@ 282 283dynamic_overlays: slapd 284 cd overlays; $(MAKE) $(MFLAGS) dynamic 285 286# 287# In Windows, dynamic backends have to be built after slapd. For this 288# reason, we only build static backends now and dynamic backends later. 289# 290.backend: FORCE 291 @if test -n "$(SLAPD_STATIC_BACKENDS)"; then \ 292 echo "building static backends..."; \ 293 for i in XX $(SLAPD_STATIC_BACKENDS); do \ 294 if test $$i != XX; then \ 295 echo " "; echo " cd $$i; $(MAKE) $(MFLAGS) all"; \ 296 ( cd $$i; $(MAKE) $(MFLAGS) all ); \ 297 if test $$? != 0; then exit 1; fi; \ 298 fi; \ 299 done; \ 300 echo " "; \ 301 fi 302 303libbackends.a: .backend 304 @$(RM) -r tmp 305 @$(MKDIR) tmp 306 @-for i in back-*/*.a; do \ 307 ( \ 308 cd tmp; \ 309 $(AR) x ../$$i; \ 310 pre=`echo $$i | $(SED) -e 's/\/.*$$//' -e 's/back-//'`; \ 311 for j in *.o; do \ 312 mv $$j $${pre}$$j; \ 313 done; \ 314 $(AR) ruv libbackends.a *.o 2>&1 | grep -v truncated; \ 315 $(RM) *.o __.SYMDEF ________64ELEL_ ; \ 316 echo "added backend library $$i"; \ 317 echo ""; \ 318 ); \ 319 done 320 @mv -f tmp/libbackends.a ./libbackends.a 321 @$(RM) -r tmp 322 @if test ! -z "$(RANLIB)" ; then \ 323 $(RANLIB) libbackends.a; \ 324 fi 325 @ls -l libbackends.a; echo "" 326 327liboverlays.a: FORCE 328 cd overlays; $(MAKE) $(MFLAGS) static 329 330version.c: Makefile 331 @-$(RM) $@ 332 $(MKVERSION) -s -n Versionstr slapd > $@ 333 334version.o: version.c $(OBJS) $(SLAPD_LIBDEPEND) 335 336backends.o: backends.c $(srcdir)/slap.h 337 338depend-local-srv: FORCE 339 @for i in $(SUBDIRS); do \ 340 if test -d $$i && test -f $$i/Makefile ; then \ 341 echo; echo " cd $$i; $(MAKE) $(MFLAGS) depend"; \ 342 ( cd $$i; $(MAKE) $(MFLAGS) depend ); \ 343 if test $$? != 0 ; then exit 1; fi ; \ 344 fi; \ 345 done 346 @echo "" 347 348clean-local: 349 $(RM) *.exp *.def *.base *.a *.objs symdummy.c 350 351veryclean-local: 352 $(RM) backends.c 353 354clean-local-srv: FORCE 355 @for i in $(SUBDIRS); do \ 356 if test -d $$i && test -f $$i/Makefile ; then \ 357 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \ 358 ( cd $$i; $(MAKE) $(MFLAGS) clean ); \ 359 if test $$? != 0 ; then exit 1; fi ; \ 360 fi; \ 361 done 362 $(RM) *.tmp all-cffiles 363 364veryclean-local-srv: FORCE 365 @for i in $(SUBDIRS); do \ 366 if test -d $$i && test -f $$i/Makefile ; then \ 367 echo; echo " cd $$i; $(MAKE) $(MFLAGS) clean"; \ 368 ( cd $$i; $(MAKE) $(MFLAGS) veryclean ); \ 369 fi; \ 370 done 371 372install-local-srv: install-slapd install-tools \ 373 install-conf install-db-config install-schema install-tools 374 375install-slapd: FORCE 376 -$(MKDIR) $(DESTDIR)$(libexecdir) 377 -$(MKDIR) $(DESTDIR)$(localstatedir)/run 378 $(LTINSTALL) $(INSTALLFLAGS) $(STRIP) -m 755 \ 379 slapd$(EXEEXT) $(DESTDIR)$(libexecdir) 380 @for i in $(SUBDIRS); do \ 381 if test -d $$i && test -f $$i/Makefile ; then \ 382 echo; echo " cd $$i; $(MAKE) $(MFLAGS) install"; \ 383 ( cd $$i; $(MAKE) $(MFLAGS) install ); \ 384 if test $$? != 0 ; then exit 1; fi ; \ 385 fi; \ 386 done 387 388all-cffiles: slapd $(SLAPD_DYNAMIC_BACKENDS) dynamic_overlays 389 @if test $(PLAT) = NT; then \ 390 sysconfdir=`cygpath -w $(sysconfdir) | \ 391 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \ 392 localstatedir=`cygpath -w $(localstatedir) | \ 393 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \ 394 moduledir=`cygpath -w $(moduledir) | \ 395 $(SED) -e 's/\\\\/\\\\\\\\\\\\\\\\/g'`; \ 396 else \ 397 sysconfdir=$(sysconfdir); \ 398 localstatedir=$(localstatedir); \ 399 moduledir=$(moduledir); \ 400 fi; \ 401 $(SED) -e "s;%SYSCONFDIR%;$$sysconfdir;" \ 402 -e "s;%LOCALSTATEDIR%;$$localstatedir;" \ 403 -e "s;%MODULEDIR%;$$moduledir;" \ 404 $(srcdir)/slapd.conf > slapd.conf.tmp ; \ 405 touch all-cffiles 406 407install-schema: FORCE 408 @if test -d $(DESTDIR)$(schemadir) ; then \ 409 echo "MOVING EXISTING SCHEMA DIR to $(DESTDIR)$(schemadir).$$$$" ; \ 410 mv $(DESTDIR)$(schemadir) $(DESTDIR)$(schemadir).$$$$ ; \ 411 fi 412 $(MKDIR) $(DESTDIR)$(schemadir) 413 @SD=$(DESTDIR)$(schemadir) ; \ 414 files=`cd $(srcdir)/schema ; echo README *.ldif *.schema` ; \ 415 for i in $$files ; do \ 416 echo $(INSTALL) $(INSTALLFLAGS) -m 444 schema/$$i $$SD/$$i ; \ 417 $(INSTALL) $(INSTALLFLAGS) -m 444 $(srcdir)/schema/$$i $$SD/$$i ; \ 418 done 419 420install-conf: FORCE 421 @-$(MKDIR) $(DESTDIR)$(sysconfdir) 422 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf.default 423 if test ! -f $(DESTDIR)$(sysconfdir)/slapd.conf; then \ 424 echo "installing slapd.conf in $(sysconfdir)"; \ 425 echo "$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \ 426 $(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \ 427 else \ 428 echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.conf" ; \ 429 fi 430 431install-db-config: FORCE 432 @-$(MKDIR) $(DESTDIR)$(localstatedir) $(DESTDIR)$(sysconfdir) 433 @-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data 434 $(INSTALL) $(INSTALLFLAGS) -m 600 $(srcdir)/DB_CONFIG \ 435 $(DESTDIR)$(localstatedir)/openldap-data/DB_CONFIG.example 436 $(INSTALL) $(INSTALLFLAGS) -m 600 $(srcdir)/DB_CONFIG \ 437 $(DESTDIR)$(sysconfdir)/DB_CONFIG.example 438 439install-tools: FORCE 440 -$(MKDIR) $(DESTDIR)$(sbindir) 441 for i in $(SLAPTOOLS); do \ 442 $(RM) $(DESTDIR)$(sbindir)/$$i$(EXEEXT); \ 443 $(LN_S) -f $(DESTDIR)$(libexecdir)/slapd$(EXEEXT) $(DESTDIR)$(sbindir)/$$i$(EXEEXT); \ 444 done 445 446