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