1from __future__ import print_function 2import os 3import re 4import string 5import sys 6from copy import copy 7from stat import * 8 9try: 10 string_types = basestring 11except NameError: 12 string_types = str 13 14package = 'lighttpd' 15version = '1.4.56' 16 17underscorify_reg = re.compile('[^A-Z0-9]') 18def underscorify(id): 19 return underscorify_reg.sub('_', id.upper()) 20 21def fail(*args, **kwargs): 22 print(*args, file=sys.stderr, **kwargs) 23 sys.exit(-1) 24 25class Autoconf: 26 class RestoreEnvLibs: 27 def __init__(self, env): 28 self.env = env 29 self.active = False 30 31 def __enter__(self): 32 if self.active: 33 raise Exception('entered twice') 34 self.active = True 35 if 'LIBS' in self.env: 36 #print("Backup LIBS: " + repr(self.env['LIBS'])) 37 self.empty = False 38 self.backup_libs = copy(self.env['LIBS']) 39 else: 40 #print("No LIBS to backup") 41 self.empty = True 42 43 def __exit__(self, type, value, traceback): 44 if not self.active: 45 raise Exception('exited twice') 46 self.active = False 47 if self.empty: 48 if 'LIBS' in self.env: 49 del self.env['LIBS'] 50 else: 51 #print("Restoring LIBS, now: " + repr(self.env['LIBS'])) 52 self.env['LIBS'] = self.backup_libs 53 #print("Restoring LIBS, to: " + repr(self.env['LIBS'])) 54 55 def __init__(self, env): 56 self.conf = Configure(env, custom_tests = { 57 'CheckGmtOffInStructTm': Autoconf.__checkGmtOffInStructTm, 58 'CheckIPv6': Autoconf.__checkIPv6, 59 'CheckWeakSymbols': Autoconf.__checkWeakSymbols, 60 }) 61 62 def append(self, *args, **kw): 63 return self.conf.env.Append(*args, **kw) 64 65 def Finish(self): 66 return self.conf.Finish() 67 68 @property 69 def env(self): 70 return self.conf.env 71 72 def restoreEnvLibs(self): 73 return Autoconf.RestoreEnvLibs(self.conf.env) 74 75 def CheckType(self, *args, **kw): 76 return self.conf.CheckType(*args, **kw) 77 78 def CheckLib(self, *args, **kw): 79 return self.conf.CheckLib(*args, autoadd = 0, **kw) 80 81 def CheckLibWithHeader(self, *args, **kw): 82 return self.conf.CheckLibWithHeader(*args, autoadd = 0, **kw) 83 84 def CheckGmtOffInStructTm(self): 85 return self.conf.CheckGmtOffInStructTm() 86 87 def CheckIPv6(self): 88 return self.conf.CheckIPv6() 89 90 def CheckWeakSymbols(self): 91 return self.conf.CheckWeakSymbols() 92 93 def CheckCHeader(self, hdr): 94 return self.conf.CheckCHeader(hdr) 95 96 def haveCHeader(self, hdr): 97 if self.CheckCHeader(hdr): 98 # if we have a list of headers define HAVE_ only for last one 99 target = hdr 100 if not isinstance(target, string_types): 101 target = target[-1] 102 self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(target) ]) 103 return True 104 return False 105 106 def haveCHeaders(self, hdrs): 107 for hdr in hdrs: 108 self.haveCHeader(hdr) 109 110 def CheckFunc(self, func, header = None, libs = []): 111 with self.restoreEnvLibs(): 112 self.env.Append(LIBS = libs) 113 return self.conf.CheckFunc(func, header = header) 114 115 def CheckFuncInLib(self, func, lib): 116 return self.CheckFunc(func, libs = [lib]) 117 118 def haveFuncInLib(self, func, lib): 119 if self.CheckFuncInLib(func, lib): 120 self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(func) ]) 121 return True 122 return False 123 124 def haveFunc(self, func, header = None, libs = []): 125 if self.CheckFunc(func, header = header, libs = libs): 126 self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(func) ]) 127 return True 128 return False 129 130 def haveFuncs(self, funcs): 131 for func in funcs: 132 self.haveFunc(func) 133 134 def haveTypes(self, types): 135 for type in types: 136 if self.conf.CheckType(type, '#include <sys/types.h>'): 137 self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(type) ]) 138 139 def CheckParseConfig(self, *args, **kw): 140 try: 141 self.conf.env.ParseConfig(*args, **kw) 142 return True 143 except Exception as e: 144 print(e.message, file=sys.stderr) 145 return False 146 147 def CheckParseConfigForLib(self, lib, *args, **kw): 148 with self.restoreEnvLibs(): 149 self.env['LIBS'] = [] 150 if not self.CheckParseConfig(*args, **kw): 151 return False 152 self.env.Append(**{lib: self.env['LIBS']}) 153 return True 154 155 @staticmethod 156 def __checkGmtOffInStructTm(context): 157 source = """ 158#include <time.h> 159int main() { 160 struct tm a; 161 a.tm_gmtoff = 0; 162 return 0; 163} 164""" 165 context.Message('Checking for tm_gmtoff in struct tm...') 166 result = context.TryLink(source, '.c') 167 context.Result(result) 168 169 return result 170 171 @staticmethod 172 def __checkIPv6(context): 173 source = """ 174#include <sys/types.h> 175#include <sys/socket.h> 176#include <netinet/in.h> 177 178int main() { 179 struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0; 180 return 0; 181} 182""" 183 context.Message('Checking for IPv6 support...') 184 result = context.TryLink(source, '.c') 185 context.Result(result) 186 187 return result 188 189 @staticmethod 190 def __checkWeakSymbols(context): 191 source = """ 192__attribute__((weak)) void __dummy(void *x) { } 193int main() { 194 void *x; 195 __dummy(x); 196} 197""" 198 context.Message('Checking for weak symbol support...') 199 result = context.TryLink(source, '.c') 200 context.Result(result) 201 202 return result 203 204 def checkProgram(self, withname, progname): 205 withname = 'with_' + withname 206 binpath = None 207 208 if self.env[withname] != 1: 209 binpath = self.env[withname] 210 else: 211 prog = self.env.Detect(progname) 212 if prog: 213 binpath = self.env.WhereIs(prog) 214 215 if binpath: 216 mode = os.stat(binpath)[ST_MODE] 217 if S_ISDIR(mode): 218 fail("* error: path `%s' is a directory" % (binpath)) 219 if not S_ISREG(mode): 220 fail("* error: path `%s' is not a file or not exists" % (binpath)) 221 222 if not binpath: 223 fail("* error: can't find program `%s'" % (progname)) 224 225 return binpath 226 227VariantDir('sconsbuild/build', 'src', duplicate = 0) 228VariantDir('sconsbuild/tests', 'tests', duplicate = 0) 229 230vars = Variables() 231vars.AddVariables( 232 ('prefix', 'prefix', '/usr/local'), 233 ('bindir', 'binary directory', '${prefix}/bin'), 234 ('sbindir', 'binary directory', '${prefix}/sbin'), 235 ('libdir', 'library directory', '${prefix}/lib'), 236 PathVariable('CC', 'path to the c-compiler', None), 237 BoolVariable('build_dynamic', 'enable dynamic build', 'yes'), 238 BoolVariable('build_static', 'enable static build', 'no'), 239 BoolVariable('build_fullstatic', 'enable fullstatic build', 'no'), 240 241 BoolVariable('with_bzip2', 'enable bzip2 compression', 'no'), 242 PackageVariable('with_dbi', 'enable dbi support', 'no'), 243 BoolVariable('with_fam', 'enable FAM/gamin support', 'no'), 244 BoolVariable('with_gdbm', 'enable gdbm support', 'no'), 245 BoolVariable('with_geoip', 'enable GeoIP support', 'no'), 246 BoolVariable('with_maxminddb', 'enable MaxMind GeoIP2 support', 'no'), 247 BoolVariable('with_krb5', 'enable krb5 auth support', 'no'), 248 BoolVariable('with_ldap', 'enable ldap auth support', 'no'), 249 # with_libev not supported 250 # with_libunwind not supported 251 BoolVariable('with_lua', 'enable lua support for mod_cml', 'no'), 252 BoolVariable('with_memcached', 'enable memcached support', 'no'), 253 PackageVariable('with_mysql', 'enable mysql support', 'no'), 254 BoolVariable('with_openssl', 'enable openssl support', 'no'), 255 PackageVariable('with_gnutls', 'enable GnuTLS support', 'no'), 256 PackageVariable('with_mbedtls', 'enable mbedTLS support', 'no'), 257 PackageVariable('with_nss', 'enable NSS crypto support', 'no'), 258 PackageVariable('with_wolfssl', 'enable wolfSSL support', 'no'), 259 BoolVariable('with_nettle', 'enable Nettle support', 'no'), 260 BoolVariable('with_pam', 'enable PAM auth support', 'no'), 261 PackageVariable('with_pcre', 'enable pcre support', 'yes'), 262 PackageVariable('with_pgsql', 'enable pgsql support', 'no'), 263 PackageVariable('with_sasl', 'enable SASL support', 'no'), 264 BoolVariable('with_sqlite3', 'enable sqlite3 support (required for webdav props)', 'no'), 265 BoolVariable('with_uuid', 'enable uuid support (required for webdav locks)', 'no'), 266 # with_valgrind not supported 267 # with_xattr not supported 268 PackageVariable('with_xml', 'enable xml support (required for webdav props)', 'no'), 269 BoolVariable('with_zlib', 'enable deflate/gzip compression', 'no'), 270 271 BoolVariable('with_all', 'enable all with_* features', 'no'), 272) 273 274env = Environment( 275 ENV = os.environ, 276 variables = vars, 277 CPPPATH = Split('#sconsbuild/build') 278) 279 280env.Help(vars.GenerateHelpText(env)) 281 282if env.subst('${CC}') is not '': 283 env['CC'] = env.subst('${CC}') 284 285env['package'] = package 286env['version'] = version 287if env['CC'] == 'gcc': 288 ## we need x-open 6 and bsd 4.3 features 289 env.Append(CCFLAGS = Split('-Wall -O2 -g -W -pedantic -Wunused -Wshadow -std=gnu99')) 290 291env.Append(CPPFLAGS = [ 292 '-D_FILE_OFFSET_BITS=64', 293 '-D_LARGEFILE_SOURCE', 294 '-D_LARGE_FILES', 295 '-D_GNU_SOURCE', 296]) 297 298if env['with_all']: 299 for feature in vars.keys(): 300 # only enable 'with_*' flags 301 if not feature.startswith('with_'): continue 302 # don't overwrite manual arguments 303 if feature in vars.args: continue 304 # now activate 305 env[feature] = True 306 307# cache configure checks 308if 1: 309 autoconf = Autoconf(env) 310 311 if 'CFLAGS' in os.environ: 312 autoconf.env.Append(CCFLAGS = os.environ['CFLAGS']) 313 print(">> Appending custom build flags : " + os.environ['CFLAGS']) 314 315 if 'LDFLAGS' in os.environ: 316 autoconf.env.Append(LINKFLAGS = os.environ['LDFLAGS']) 317 print(">> Appending custom link flags : " + os.environ['LDFLAGS']) 318 319 if 'LIBS' in os.environ: 320 autoconf.env.Append(APPEND_LIBS = os.environ['LIBS']) 321 print(">> Appending custom libraries : " + os.environ['LIBS']) 322 else: 323 autoconf.env.Append(APPEND_LIBS = '') 324 325 autoconf.env.Append( 326 LIBBZ2 = '', 327 LIBCRYPT = '', 328 LIBCRYPTO = '', 329 LIBDBI = '', 330 LIBDL = '', 331 LIBFCGI = '', 332 LIBGDBM = '', 333 LIBGNUTLS = '', 334 LIBGSSAPI_KRB5 = '', 335 LIBKRB5 = '', 336 LIBLBER = '', 337 LIBLDAP = '', 338 LIBLUA = '', 339 LIBMEMCACHED = '', 340 LIBMYSQL = '', 341 LIBNSS = '', 342 LIBPAM = '', 343 LIBPCRE = '', 344 LIBPGSQL = '', 345 LIBSASL = '', 346 LIBSQLITE3 = '', 347 LIBSSL = '', 348 LIBUUID = '', 349 LIBX509 = '', 350 LIBXML2 = '', 351 LIBZ = '', 352 ) 353 354 autoconf.haveCHeaders([ 355 'arpa/inet.h', 356 'crypt.h', 357 'fcntl.h', 358 'getopt.h', 359 'inttypes.h', 360 'linux/random.h', 361 'poll.h', 362 'pwd.h', 363 'stdint.h', 364 'stdlib.h', 365 'string.h', 366 'strings.h', 367 'sys/devpoll.h', 368 'sys/epoll.h', 369 'sys/filio.h', 370 'sys/loadavg.h', 371 'sys/poll.h', 372 'sys/port.h', 373 'sys/prctl.h', 374 'sys/sendfile.h', 375 'sys/time.h', 376 'sys/wait.h', 377 'syslog.h', 378 'unistd.h', 379 'winsock2.h', 380 381 # "have" the last header if we include others before? 382 ['sys/types.h', 'sys/time.h', 'sys/resource.h'], 383 ['sys/types.h', 'netinet/in.h'], 384 ['sys/types.h', 'sys/event.h'], 385 ['sys/types.h', 'sys/mman.h'], 386 ['sys/types.h', 'sys/select.h'], 387 ['sys/types.h', 'sys/socket.h'], 388 ['sys/types.h', 'sys/uio.h'], 389 ['sys/types.h', 'sys/un.h'], 390 ]) 391 392 autoconf.haveFuncs([ 393 'arc4random_buf', 394 'chroot', 395 'clock_gettime', 396 'copy_file_range', 397 'dup2', 398 'epoll_ctl', 399 'explicit_bzero', 400 'explicit_memset', 401 'fork', 402 'getcwd', 403 'gethostbyname', 404 'getloadavg', 405 'getopt', 406 'getrlimit', 407 'getuid', 408 'inet_ntoa', 409 'inet_ntop', 410 'inet_pton', 411 'issetugid', 412 'jrand48', 413 'kqueue', 414 'localtime_r', 415 'lstat', 416 'madvise', 417 'memset_s', 418 'memset', 419 'mmap', 420 'munmap', 421 'pathconf', 422 'pipe2', 423 'poll', 424 'port_create', 425 'posix_fadvise', 426 'prctl', 427 'select', 428 'send_file', 429 'sendfile', 430 'sendfile64', 431 'sigaction', 432 'signal', 433 'socket', 434 'srandom', 435 'stat', 436 'strchr', 437 'strdup', 438 'strerror', 439 'strftime', 440 'strstr', 441 'strtol', 442 'writev', 443 ]) 444 autoconf.haveFunc('getentropy', 'sys/random.h') 445 autoconf.haveFunc('getrandom', 'linux/random.h') 446 447 autoconf.haveTypes(Split('pid_t size_t off_t')) 448 449 # have crypt_r/crypt, and is -lcrypt needed? 450 if autoconf.CheckLib('crypt'): 451 autoconf.env.Append( 452 CPPFLAGS = [ '-DHAVE_LIBCRYPT' ], 453 LIBCRYPT = 'crypt', 454 ) 455 with autoconf.restoreEnvLibs(): 456 autoconf.env['LIBS'] = ['crypt'] 457 autoconf.haveFuncs(['crypt', 'crypt_r']) 458 else: 459 autoconf.haveFuncs(['crypt', 'crypt_r']) 460 461 if autoconf.CheckType('socklen_t', '#include <unistd.h>\n#include <sys/socket.h>\n#include <sys/types.h>'): 462 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ]) 463 464 if autoconf.CheckType('struct sockaddr_storage', '#include <sys/socket.h>\n'): 465 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ]) 466 467 if autoconf.CheckLibWithHeader('elftc', 'libelftc.h', 'c', 'elftc_copyfile(0, 1);'): 468 autoconf.env.Append( 469 CPPFLAGS = [ '-DHAVE_ELFTC_COPYFILE' ], 470 LIBS = [ 'elftc' ], 471 ) 472 473 if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);'): 474 autoconf.env.Append( 475 CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ], 476 LIBS = [ 'rt' ], 477 ) 478 479 if autoconf.CheckIPv6(): 480 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_IPV6' ]) 481 482 if autoconf.CheckWeakSymbols(): 483 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_WEAK_SYMBOLS' ]) 484 485 if autoconf.CheckGmtOffInStructTm(): 486 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ]) 487 488 if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'): 489 autoconf.env.Append(LIBDL = 'dl') 490 491 # used in tests if present 492 if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C'): 493 autoconf.env.Append(LIBFCGI = 'fcgi') 494 495 if env['with_bzip2']: 496 if not autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'): 497 fail("Couldn't find bz2") 498 autoconf.env.Append( 499 CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], 500 LIBBZ2 = 'bz2', 501 ) 502 503 if env['with_dbi']: 504 if not autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C'): 505 fail("Couldn't find dbi") 506 autoconf.env.Append( 507 CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], 508 LIBDBI = 'dbi', 509 ) 510 511 if env['with_fam']: 512 if not autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'): 513 fail("Couldn't find fam") 514 autoconf.env.Append( 515 CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], 516 LIBS = [ 'fam' ], 517 ) 518 autoconf.haveFunc('FAMNoExists') 519 520 if env['with_gdbm']: 521 if not autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C'): 522 fail("Couldn't find gdbm") 523 autoconf.env.Append( 524 CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ], 525 LIBGDBM = 'gdbm', 526 ) 527 528 if env['with_geoip']: 529 if not autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C'): 530 fail("Couldn't find geoip") 531 autoconf.env.Append( 532 CPPFLAGS = [ '-DHAVE_GEOIP' ], 533 LIBGEOIP = 'GeoIP', 534 ) 535 536 if env['with_maxminddb']: 537 if not autoconf.CheckLibWithHeader('maxminddb', 'maxminddb.h', 'C'): 538 fail("Couldn't find maxminddb") 539 autoconf.env.Append( 540 CPPFLAGS = [ '-DHAVE_MAXMINDDB' ], 541 LIBMAXMINDDB = 'maxminddb', 542 ) 543 544 if env['with_krb5']: 545 if not autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C'): 546 fail("Couldn't find krb5") 547 if not autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C'): 548 fail("Couldn't find gssapi_krb5") 549 autoconf.env.Append( 550 CPPFLAGS = [ '-DHAVE_KRB5' ], 551 LIBKRB5 = 'krb5', 552 LIBGSSAPI_KRB5 = 'gssapi_krb5', 553 ) 554 555 if env['with_ldap']: 556 if not autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C'): 557 fail("Couldn't find ldap") 558 if not autoconf.CheckLibWithHeader('lber', 'lber.h', 'C'): 559 fail("Couldn't find lber") 560 autoconf.env.Append( 561 CPPFLAGS = [ 562 '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP', 563 '-DHAVE_LBER_H', '-DHAVE_LIBLBER', 564 ], 565 LIBLDAP = 'ldap', 566 LIBLBER = 'lber', 567 ) 568 569 if env['with_lua']: 570 found_lua = False 571 for lua_name in ['lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua']: 572 print("Searching for lua: " + lua_name + " >= 5.0") 573 if autoconf.CheckParseConfigForLib('LIBLUA', "pkg-config '" + lua_name + " >= 5.0' --cflags --libs"): 574 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ]) 575 found_lua = True 576 break 577 if not found_lua: 578 fail("Couldn't find any lua implementation") 579 580 if env['with_memcached']: 581 if not autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C'): 582 fail("Couldn't find memcached") 583 autoconf.env.Append( 584 CPPFLAGS = [ '-DUSE_MEMCACHED' ], 585 LIBMEMCACHED = 'memcached', 586 ) 587 588 if env['with_mysql']: 589 mysql_config = autoconf.checkProgram('mysql', 'mysql_config') 590 if not autoconf.CheckParseConfigForLib('LIBMYSQL', mysql_config + ' --cflags --libs'): 591 fail("Couldn't find mysql") 592 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ]) 593 594 if env['with_nss']: 595 nss_config = autoconf.checkProgram('nss', 'nss-config') 596 if not autoconf.CheckParseConfigForLib('LIBNSS', nss_config + ' --cflags --libs'): 597 fail("Couldn't find NSS") 598 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_NSS3_NSS_H' ]) 599 600 if env['with_openssl']: 601 if not autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'): 602 fail("Couldn't find openssl") 603 autoconf.env.Append( 604 CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'], 605 LIBSSL = 'ssl', 606 LIBCRYPTO = 'crypto', 607 ) 608 609 if env['with_wolfssl']: 610 if type(env['with_wolfssl']) is str: 611 autoconf.env.AppendUnique( 612 CPPPATH = [ env['with_wolfssl'] + '/include', 613 env['with_wolfssl'] + '/include/wolfssl' ], 614 LIBPATH = [ env['with_wolfssl'] + '/lib' ], 615 ) 616 if not autoconf.CheckLibWithHeader('wolfssl', 'wolfssl/ssl.h', 'C'): 617 fail("Couldn't find wolfssl") 618 autoconf.env.Append( 619 CPPFLAGS = [ '-DHAVE_WOLFSSL_SSL_H' ], 620 LIBSSL = '', 621 LIBCRYPTO = 'wolfssl', 622 ) 623 624 if env['with_mbedtls']: 625 if not autoconf.CheckLibWithHeader('mbedtls', 'mbedtls/ssl.h', 'C'): 626 fail("Couldn't find mbedtls") 627 autoconf.env.Append( 628 CPPFLAGS = [ '-DHAVE_LIBMBEDCRYPTO' ], 629 LIBSSL = 'mbedtls', 630 LIBX509 = 'mbedx509', 631 LIBCRYPTO = 'mbedcrypto', 632 ) 633 634 if env['with_nettle']: 635 if not autoconf.CheckLibWithHeader('nettle', 'nettle/nettle-types.h', 'C'): 636 fail("Couldn't find Nettle") 637 autoconf.env.Append( 638 CPPFLAGS = [ '-DHAVE_NETTLE_NETTLE_TYPES_H' ], 639 LIBCRYPTO = 'nettle', 640 ) 641 642 if env['with_gnutls']: 643 if not autoconf.CheckLibWithHeader('gnutls', 'gnutls/crypto.h', 'C'): 644 fail("Couldn't find gnutls") 645 autoconf.env.Append( 646 CPPFLAGS = [ '-DHAVE_GNUTLS_CRYPTO_H' ], 647 LIBGNUTLS = 'gnutls', 648 ) 649 if not autoconf.env.exists('LIBCRYPTO'): 650 autoconf.env.Append( 651 LIBCRYPTO = 'gnutls', 652 ) 653 654 if env['with_pam']: 655 if not autoconf.CheckLibWithHeader('pam', 'security/pam_appl.h', 'C'): 656 fail("Couldn't find pam") 657 autoconf.env.Append( 658 CPPFLAGS = [ '-DHAVE_PAM' ], 659 LIBPAM = 'pam', 660 ) 661 662 if env['with_pcre']: 663 pcre_config = autoconf.checkProgram('pcre', 'pcre-config') 664 if not autoconf.CheckParseConfigForLib('LIBPCRE', pcre_config + ' --cflags --libs'): 665 fail("Couldn't find pcre") 666 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ]) 667 668 if env['with_pgsql']: 669 if not autoconf.CheckParseConfigForLib('LIBPGSQL', 'pkg-config libpq --cflags --libs'): 670 fail("Couldn't find libpq") 671 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ]) 672 673 if env['with_sasl']: 674 if not autoconf.CheckLibWithHeader('sasl2', 'sasl/sasl.h', 'C'): 675 fail("Couldn't find libsasl2") 676 autoconf.env.Append( 677 CPPFLAGS = [ '-DHAVE_SASL' ], 678 LIBSASL = 'sasl2', 679 ) 680 681 if env['with_sqlite3']: 682 if not autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'): 683 fail("Couldn't find sqlite3") 684 autoconf.env.Append( 685 CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], 686 LIBSQLITE3 = 'sqlite3', 687 ) 688 689 if env['with_uuid']: 690 if not autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C'): 691 fail("Couldn't find uuid") 692 autoconf.env.Append( 693 CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], 694 LIBUUID = 'uuid', 695 ) 696 697 if env['with_xml']: 698 xml2_config = autoconf.checkProgram('xml', 'xml2-config') 699 if not autoconf.CheckParseConfigForLib('LIBXML2', xml2_config + ' --cflags --libs'): 700 fail("Couldn't find xml2") 701 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ]) 702 703 if env['with_zlib']: 704 if not autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'): 705 fail("Couldn't find zlib") 706 autoconf.env.Append( 707 CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], 708 LIBZ = 'z', 709 ) 710 711 env = autoconf.Finish() 712 713if re.compile("cygwin|mingw|midipix").search(env['PLATFORM']): 714 env.Append(COMMON_LIB = 'bin') 715elif re.compile("darwin|aix").search(env['PLATFORM']): 716 env.Append(COMMON_LIB = 'lib') 717else: 718 env.Append(COMMON_LIB = False) 719 720versions = version.split('.') 721version_id = int(versions[0]) << 16 | int(versions[1]) << 8 | int(versions[2]) 722env.Append(CPPFLAGS = [ 723 '-DLIGHTTPD_VERSION_ID=' + hex(version_id), 724 '-DPACKAGE_NAME=\\"' + package + '\\"', 725 '-DPACKAGE_VERSION=\\"' + version + '\\"', 726 '-DLIBRARY_DIR="\\"${libdir}\\""', 727 ] ) 728 729SConscript('src/SConscript', exports = 'env', variant_dir = 'sconsbuild/build', duplicate = 0) 730SConscript('tests/SConscript', exports = 'env', variant_dir = 'sconsbuild/tests') 731