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.59' 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 BoolVariable('with_brotli', 'enable brotli compression', 'no'), 243 PackageVariable('with_dbi', 'enable dbi support', 'no'), 244 BoolVariable('with_fam', 'enable FAM/gamin support', 'no'), 245 BoolVariable('with_gdbm', 'enable gdbm support', 'no'), 246 BoolVariable('with_geoip', 'enable GeoIP support', 'no'), 247 BoolVariable('with_maxminddb', 'enable MaxMind GeoIP2 support', 'no'), 248 BoolVariable('with_krb5', 'enable krb5 auth support', 'no'), 249 BoolVariable('with_ldap', 'enable ldap auth support', 'no'), 250 # with_libev not supported 251 # with_libunwind not supported 252 BoolVariable('with_lua', 'enable lua support for mod_cml', 'no'), 253 BoolVariable('with_memcached', 'enable memcached support', 'no'), 254 PackageVariable('with_mysql', 'enable mysql support', 'no'), 255 BoolVariable('with_openssl', 'enable openssl support', 'no'), 256 PackageVariable('with_gnutls', 'enable GnuTLS support', 'no'), 257 PackageVariable('with_mbedtls', 'enable mbedTLS support', 'no'), 258 PackageVariable('with_nss', 'enable NSS crypto support', 'no'), 259 PackageVariable('with_wolfssl', 'enable wolfSSL support', 'no'), 260 BoolVariable('with_nettle', 'enable Nettle support', 'no'), 261 BoolVariable('with_pam', 'enable PAM auth support', 'no'), 262 PackageVariable('with_pcre', 'enable pcre support', 'yes'), 263 PackageVariable('with_pgsql', 'enable pgsql support', 'no'), 264 PackageVariable('with_sasl', 'enable SASL support', 'no'), 265 BoolVariable('with_sqlite3', 'enable sqlite3 support (required for webdav props)', 'no'), 266 BoolVariable('with_uuid', 'enable uuid support (required for webdav locks)', 'no'), 267 # with_valgrind not supported 268 # with_xattr not supported 269 PackageVariable('with_xml', 'enable xml support (required for webdav props)', 'no'), 270 BoolVariable('with_xxhash', 'build with system-provided xxhash', 'no'), 271 BoolVariable('with_zlib', 'enable deflate/gzip compression', 'no'), 272 273 BoolVariable('with_all', 'enable all with_* features', 'no'), 274) 275 276env = Environment( 277 ENV = dict(os.environ), # make sure we have a dict here so .Clone() works properly 278 variables = vars, 279 CPPPATH = Split('#sconsbuild/build') 280) 281 282env.Help(vars.GenerateHelpText(env)) 283 284if env.subst('${CC}') != '': 285 env['CC'] = env.subst('${CC}') 286 287env['package'] = package 288env['version'] = version 289if env['CC'] == 'gcc': 290 ## we need x-open 6 and bsd 4.3 features 291 env.Append(CCFLAGS = Split('-Wall -O2 -g -W -pedantic -Wunused -Wshadow -std=gnu99')) 292 293env.Append(CPPFLAGS = [ 294 '-D_FILE_OFFSET_BITS=64', 295 '-D_LARGEFILE_SOURCE', 296 '-D_LARGE_FILES', 297 '-D_GNU_SOURCE', 298]) 299 300if env['with_all']: 301 for feature in vars.keys(): 302 # only enable 'with_*' flags 303 if not feature.startswith('with_'): continue 304 # don't overwrite manual arguments 305 if feature in vars.args: continue 306 # now activate 307 env[feature] = True 308 309# cache configure checks 310if 1: 311 autoconf = Autoconf(env) 312 313 if 'CFLAGS' in os.environ: 314 autoconf.env.Append(CCFLAGS = os.environ['CFLAGS']) 315 print(">> Appending custom build flags : " + os.environ['CFLAGS']) 316 317 if 'LDFLAGS' in os.environ: 318 autoconf.env.Append(LINKFLAGS = os.environ['LDFLAGS']) 319 print(">> Appending custom link flags : " + os.environ['LDFLAGS']) 320 321 if 'LIBS' in os.environ: 322 autoconf.env.Append(APPEND_LIBS = os.environ['LIBS']) 323 print(">> Appending custom libraries : " + os.environ['LIBS']) 324 else: 325 autoconf.env.Append(APPEND_LIBS = '') 326 327 autoconf.env.Append( 328 LIBBROTLI = '', 329 LIBBZ2 = '', 330 LIBCRYPT = '', 331 LIBCRYPTO = '', 332 LIBDBI = '', 333 LIBDL = '', 334 LIBGDBM = '', 335 LIBGNUTLS = '', 336 LIBGSSAPI_KRB5 = '', 337 LIBKRB5 = '', 338 LIBLBER = '', 339 LIBLDAP = '', 340 LIBLUA = '', 341 LIBMBEDTLS = '', 342 LIBMBEDX509 = '', 343 LIBMBEDCRYPTO = '', 344 LIBMEMCACHED = '', 345 LIBMYSQL = '', 346 LIBNSS = '', 347 LIBPAM = '', 348 LIBPCRE = '', 349 LIBPGSQL = '', 350 LIBSASL = '', 351 LIBSQLITE3 = '', 352 LIBSSL = '', 353 LIBSSLCRYPTO = '', 354 LIBUUID = '', 355 LIBWOLFSSL = '', 356 LIBX509 = '', 357 LIBXML2 = '', 358 LIBXXHASH = '', 359 LIBZ = '', 360 ) 361 362 autoconf.haveCHeaders([ 363 'arpa/inet.h', 364 'crypt.h', 365 'fcntl.h', 366 'getopt.h', 367 'inttypes.h', 368 'linux/random.h', 369 'poll.h', 370 'pwd.h', 371 'stdint.h', 372 'stdlib.h', 373 'string.h', 374 'strings.h', 375 'sys/devpoll.h', 376 'sys/epoll.h', 377 'sys/filio.h', 378 'sys/inotify.h', 379 'sys/loadavg.h', 380 'sys/poll.h', 381 'sys/port.h', 382 'sys/prctl.h', 383 'sys/sendfile.h', 384 'sys/time.h', 385 'sys/wait.h', 386 'syslog.h', 387 'unistd.h', 388 'winsock2.h', 389 390 # "have" the last header if we include others before? 391 ['sys/types.h', 'sys/time.h', 'sys/resource.h'], 392 ['sys/types.h', 'netinet/in.h'], 393 ['sys/types.h', 'sys/event.h'], 394 ['sys/types.h', 'sys/mman.h'], 395 ['sys/types.h', 'sys/select.h'], 396 ['sys/types.h', 'sys/socket.h'], 397 ['sys/types.h', 'sys/uio.h'], 398 ['sys/types.h', 'sys/un.h'], 399 ]) 400 401 autoconf.haveFuncs([ 402 'arc4random_buf', 403 'chroot', 404 'clock_gettime', 405 'copy_file_range', 406 'dup2', 407 'epoll_ctl', 408 'explicit_bzero', 409 'explicit_memset', 410 'fork', 411 'getcwd', 412 'gethostbyname', 413 'getloadavg', 414 'getopt', 415 'getrlimit', 416 'getuid', 417 'inet_aton', 418 'inet_ntop', 419 'inet_pton', 420 'issetugid', 421 'jrand48', 422 'kqueue', 423 'localtime_r', 424 'lstat', 425 'madvise', 426 'memset_s', 427 'memset', 428 'mmap', 429 'munmap', 430 'pathconf', 431 'pipe2', 432 'poll', 433 'port_create', 434 'posix_fadvise', 435 'prctl', 436 'select', 437 'send_file', 438 'sendfile', 439 'sendfile64', 440 'sigaction', 441 'signal', 442 'socket', 443 'srandom', 444 'stat', 445 'strchr', 446 'strdup', 447 'strerror', 448 'strftime', 449 'strstr', 450 'strtol', 451 'timegm', 452 'writev', 453 ]) 454 autoconf.haveFunc('getentropy', 'sys/random.h') 455 autoconf.haveFunc('getrandom', 'linux/random.h') 456 457 autoconf.haveTypes(Split('pid_t size_t off_t')) 458 459 # have crypt_r/crypt, and is -lcrypt needed? 460 if autoconf.CheckLib('crypt'): 461 autoconf.env.Append( 462 CPPFLAGS = [ '-DHAVE_LIBCRYPT' ], 463 LIBCRYPT = 'crypt', 464 ) 465 with autoconf.restoreEnvLibs(): 466 autoconf.env['LIBS'] = ['crypt'] 467 autoconf.haveFuncs(['crypt', 'crypt_r']) 468 else: 469 autoconf.haveFuncs(['crypt', 'crypt_r']) 470 471 if autoconf.CheckType('socklen_t', '#include <unistd.h>\n#include <sys/socket.h>\n#include <sys/types.h>'): 472 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ]) 473 474 if autoconf.CheckType('struct sockaddr_storage', '#include <sys/socket.h>\n'): 475 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ]) 476 477 if autoconf.CheckLibWithHeader('elftc', 'libelftc.h', 'c', 'elftc_copyfile(0, 1);'): 478 autoconf.env.Append( 479 CPPFLAGS = [ '-DHAVE_ELFTC_COPYFILE' ], 480 LIBS = [ 'elftc' ], 481 ) 482 483 if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);'): 484 autoconf.env.Append( 485 CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ], 486 LIBS = [ 'rt' ], 487 ) 488 489 if autoconf.CheckIPv6(): 490 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_IPV6' ]) 491 492 if autoconf.CheckWeakSymbols(): 493 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_WEAK_SYMBOLS' ]) 494 495 if autoconf.CheckGmtOffInStructTm(): 496 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ]) 497 498 if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'): 499 autoconf.env.Append(LIBDL = 'dl') 500 501 if env['with_bzip2']: 502 if not autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'): 503 fail("Couldn't find bz2") 504 autoconf.env.Append( 505 CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], 506 LIBBZ2 = 'bz2', 507 ) 508 509 if env['with_brotli']: 510 if not autoconf.CheckParseConfigForLib('LIBBROTLI', 'pkg-config --static --cflags --libs libbrotlienc'): 511 fail("Couldn't find libbrotlienc") 512 autoconf.env.Append( 513 CPPFLAGS = [ '-DHAVE_BROTLI_ENCODE_H', '-DHAVE_BROTLI' ], 514 ) 515 516 if env['with_dbi']: 517 if not autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C'): 518 fail("Couldn't find dbi") 519 autoconf.env.Append( 520 CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], 521 LIBDBI = 'dbi', 522 ) 523 524 if env['with_fam'] and not self.CheckCHeader('sys/inotify.h'): 525 if not autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'): 526 fail("Couldn't find fam") 527 autoconf.env.Append( 528 CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], 529 LIBS = [ 'fam' ], 530 ) 531 autoconf.haveFunc('FAMNoExists') 532 533 if env['with_gdbm']: 534 if not autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C'): 535 fail("Couldn't find gdbm") 536 autoconf.env.Append( 537 CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ], 538 LIBGDBM = 'gdbm', 539 ) 540 541 if env['with_geoip']: 542 if not autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C'): 543 fail("Couldn't find geoip") 544 autoconf.env.Append( 545 CPPFLAGS = [ '-DHAVE_GEOIP' ], 546 LIBGEOIP = 'GeoIP', 547 ) 548 549 if env['with_maxminddb']: 550 if not autoconf.CheckLibWithHeader('maxminddb', 'maxminddb.h', 'C'): 551 fail("Couldn't find maxminddb") 552 autoconf.env.Append( 553 CPPFLAGS = [ '-DHAVE_MAXMINDDB' ], 554 LIBMAXMINDDB = 'maxminddb', 555 ) 556 557 if env['with_krb5']: 558 if not autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C'): 559 fail("Couldn't find krb5") 560 if not autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C'): 561 fail("Couldn't find gssapi_krb5") 562 autoconf.env.Append( 563 CPPFLAGS = [ '-DHAVE_KRB5' ], 564 LIBKRB5 = 'krb5', 565 LIBGSSAPI_KRB5 = 'gssapi_krb5', 566 ) 567 568 if env['with_ldap']: 569 if not autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C'): 570 fail("Couldn't find ldap") 571 if not autoconf.CheckLibWithHeader('lber', 'lber.h', 'C'): 572 fail("Couldn't find lber") 573 autoconf.env.Append( 574 CPPFLAGS = [ 575 '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP', 576 '-DHAVE_LBER_H', '-DHAVE_LIBLBER', 577 ], 578 LIBLDAP = 'ldap', 579 LIBLBER = 'lber', 580 ) 581 582 if env['with_lua']: 583 found_lua = False 584 for lua_name in ['lua5.4', 'lua-5.4', 'lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua']: 585 print("Searching for lua: " + lua_name + " >= 5.0") 586 if autoconf.CheckParseConfigForLib('LIBLUA', "pkg-config '" + lua_name + " >= 5.0' --cflags --libs"): 587 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ]) 588 found_lua = True 589 break 590 if not found_lua: 591 fail("Couldn't find any lua implementation") 592 593 if env['with_memcached']: 594 if not autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C'): 595 fail("Couldn't find memcached") 596 autoconf.env.Append( 597 CPPFLAGS = [ '-DUSE_MEMCACHED' ], 598 LIBMEMCACHED = 'memcached', 599 ) 600 601 if env['with_mysql']: 602 mysql_config = autoconf.checkProgram('mysql', 'mysql_config') 603 if not autoconf.CheckParseConfigForLib('LIBMYSQL', mysql_config + ' --cflags --libs'): 604 fail("Couldn't find mysql") 605 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ]) 606 607 if env['with_nss']: 608 nss_config = autoconf.checkProgram('nss', 'nss-config') 609 if not autoconf.CheckParseConfigForLib('LIBNSS', nss_config + ' --cflags --libs'): 610 fail("Couldn't find NSS") 611 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_NSS3_NSS_H' ]) 612 613 if env['with_openssl']: 614 if not autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'): 615 fail("Couldn't find openssl") 616 autoconf.env.Append( 617 CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'], 618 LIBSSL = 'ssl', 619 LIBSSLCRYPTO = 'crypto', 620 LIBCRYPTO = 'crypto', 621 ) 622 623 if env['with_wolfssl']: 624 if type(env['with_wolfssl']) is str: 625 autoconf.env.AppendUnique( 626 CPPPATH = [ env['with_wolfssl'] + '/include', 627 env['with_wolfssl'] + '/include/wolfssl' ], 628 LIBPATH = [ env['with_wolfssl'] + '/lib' ], 629 ) 630 if not autoconf.CheckLibWithHeader('wolfssl', 'wolfssl/ssl.h', 'C'): 631 fail("Couldn't find wolfssl") 632 autoconf.env.Append( 633 CPPFLAGS = [ '-DHAVE_WOLFSSL_SSL_H' ], 634 LIBWOLFSSL= 'wolfssl', 635 LIBCRYPTO = 'wolfssl', 636 ) 637 638 if env['with_mbedtls']: 639 if not autoconf.CheckLibWithHeader('mbedtls', 'mbedtls/ssl.h', 'C'): 640 fail("Couldn't find mbedtls") 641 autoconf.env.Append( 642 CPPFLAGS = [ '-DHAVE_LIBMBEDCRYPTO' ], 643 LIBMBEDTLS = 'mbedtls', 644 LIBMBEDX509 = 'mbedx509', 645 LIBMBEDCRYPTO = 'mbedcrypto', 646 LIBCRYPTO = 'mbedcrypto', 647 ) 648 649 if env['with_nettle']: 650 if not autoconf.CheckLibWithHeader('nettle', 'nettle/nettle-types.h', 'C'): 651 fail("Couldn't find Nettle") 652 autoconf.env.Append( 653 CPPFLAGS = [ '-DHAVE_NETTLE_NETTLE_TYPES_H' ], 654 LIBCRYPTO = 'nettle', 655 ) 656 657 if env['with_gnutls']: 658 if not autoconf.CheckLibWithHeader('gnutls', 'gnutls/crypto.h', 'C'): 659 fail("Couldn't find gnutls") 660 autoconf.env.Append( 661 CPPFLAGS = [ '-DHAVE_GNUTLS_CRYPTO_H' ], 662 LIBGNUTLS = 'gnutls', 663 ) 664 if not autoconf.env.exists('LIBCRYPTO'): 665 autoconf.env.Append( 666 LIBCRYPTO = 'gnutls', 667 ) 668 669 if env['with_pam']: 670 if not autoconf.CheckLibWithHeader('pam', 'security/pam_appl.h', 'C'): 671 fail("Couldn't find pam") 672 autoconf.env.Append( 673 CPPFLAGS = [ '-DHAVE_PAM' ], 674 LIBPAM = 'pam', 675 ) 676 677 if env['with_pcre']: 678 pcre_config = autoconf.checkProgram('pcre', 'pcre-config') 679 if not autoconf.CheckParseConfigForLib('LIBPCRE', pcre_config + ' --cflags --libs'): 680 fail("Couldn't find pcre") 681 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ]) 682 683 if env['with_pgsql']: 684 if not autoconf.CheckParseConfigForLib('LIBPGSQL', 'pkg-config libpq --cflags --libs'): 685 fail("Couldn't find libpq") 686 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ]) 687 688 if env['with_sasl']: 689 if not autoconf.CheckLibWithHeader('sasl2', 'sasl/sasl.h', 'C'): 690 fail("Couldn't find libsasl2") 691 autoconf.env.Append( 692 CPPFLAGS = [ '-DHAVE_SASL' ], 693 LIBSASL = 'sasl2', 694 ) 695 696 if env['with_sqlite3']: 697 if not autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'): 698 fail("Couldn't find sqlite3") 699 autoconf.env.Append( 700 CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], 701 LIBSQLITE3 = 'sqlite3', 702 ) 703 704 if env['with_uuid']: 705 if not autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C'): 706 fail("Couldn't find uuid") 707 autoconf.env.Append( 708 CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], 709 LIBUUID = 'uuid', 710 ) 711 712 if env['with_xml']: 713 xml2_config = autoconf.checkProgram('xml', 'xml2-config') 714 if not autoconf.CheckParseConfigForLib('LIBXML2', xml2_config + ' --cflags --libs'): 715 fail("Couldn't find xml2") 716 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ]) 717 718 if env['with_xxhash']: 719 if not autoconf.CheckLibWithHeader('xxhash', 'xxhash.h', 'C'): 720 fail("Couldn't find xxhash") 721 autoconf.env.Append( 722 CPPFLAGS = [ '-DHAVE_XXHASH_H' ], 723 LIBXXHASH = 'xxhash', 724 ) 725 726 if env['with_zlib']: 727 if not autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'): 728 fail("Couldn't find zlib") 729 autoconf.env.Append( 730 CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], 731 LIBZ = 'z', 732 ) 733 734 env = autoconf.Finish() 735 736if re.compile("cygwin|mingw|midipix").search(env['PLATFORM']): 737 env.Append(COMMON_LIB = 'bin') 738elif re.compile("darwin|aix").search(env['PLATFORM']): 739 env.Append(COMMON_LIB = 'lib') 740else: 741 env.Append(COMMON_LIB = False) 742 743versions = version.split('.') 744version_id = int(versions[0]) << 16 | int(versions[1]) << 8 | int(versions[2]) 745env.Append(CPPFLAGS = [ 746 '-DLIGHTTPD_VERSION_ID=' + hex(version_id), 747 '-DPACKAGE_NAME=\\"' + package + '\\"', 748 '-DPACKAGE_VERSION=\\"' + version + '\\"', 749 '-DLIBRARY_DIR="\\"${libdir}\\""', 750 ] ) 751 752SConscript('src/SConscript', exports = 'env', variant_dir = 'sconsbuild/build', duplicate = 0) 753SConscript('tests/SConscript', exports = 'env', variant_dir = 'sconsbuild/tests') 754