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.64' 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 OSError: 144 return False 145 except Exception as e: 146 print(e.message, file=sys.stderr) 147 return False 148 149 def CheckParseConfigForLib(self, lib, *args, **kw): 150 with self.restoreEnvLibs(): 151 self.env['LIBS'] = [] 152 if not self.CheckParseConfig(*args, **kw): 153 return False 154 self.env.Append(**{lib: self.env['LIBS']}) 155 return True 156 157 @staticmethod 158 def __checkGmtOffInStructTm(context): 159 source = """ 160#include <time.h> 161int main() { 162 struct tm a; 163 a.tm_gmtoff = 0; 164 return 0; 165} 166""" 167 context.Message('Checking for tm_gmtoff in struct tm...') 168 result = context.TryLink(source, '.c') 169 context.Result(result) 170 171 return result 172 173 @staticmethod 174 def __checkIPv6(context): 175 source = """ 176#include <sys/types.h> 177#include <sys/socket.h> 178#include <netinet/in.h> 179 180int main() { 181 struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0; 182 return 0; 183} 184""" 185 context.Message('Checking for IPv6 support...') 186 result = context.TryLink(source, '.c') 187 context.Result(result) 188 189 return result 190 191 @staticmethod 192 def __checkWeakSymbols(context): 193 source = """ 194__attribute__((weak)) void __dummy(void *x) { } 195int main() { 196 void *x; 197 __dummy(x); 198} 199""" 200 context.Message('Checking for weak symbol support...') 201 result = context.TryLink(source, '.c') 202 context.Result(result) 203 204 return result 205 206 def checkProgram(self, withname, progname): 207 withname = 'with_' + withname 208 binpath = None 209 210 if self.env[withname] != 1: 211 binpath = self.env[withname] 212 else: 213 prog = self.env.Detect(progname) 214 if prog: 215 binpath = self.env.WhereIs(prog) 216 217 if binpath: 218 mode = os.stat(binpath)[ST_MODE] 219 if S_ISDIR(mode): 220 fail("* error: path `%s' is a directory" % (binpath)) 221 if not S_ISREG(mode): 222 fail("* error: path `%s' is not a file or not exists" % (binpath)) 223 224 if not binpath: 225 fail("* error: can't find program `%s'" % (progname)) 226 227 return binpath 228 229VariantDir('sconsbuild/build', 'src', duplicate = 0) 230VariantDir('sconsbuild/tests', 'tests', duplicate = 0) 231 232vars = Variables() 233vars.AddVariables( 234 ('prefix', 'prefix', '/usr/local'), 235 ('bindir', 'binary directory', '${prefix}/bin'), 236 ('sbindir', 'binary directory', '${prefix}/sbin'), 237 ('libdir', 'library directory', '${prefix}/lib'), 238 PathVariable('CC', 'path to the c-compiler', None), 239 BoolVariable('build_dynamic', 'enable dynamic build', 'yes'), 240 BoolVariable('build_static', 'enable static build', 'no'), 241 BoolVariable('build_fullstatic', 'enable fullstatic build', 'no'), 242 243 BoolVariable('with_bzip2', 'enable bzip2 compression', 'no'), 244 BoolVariable('with_brotli', 'enable brotli compression', 'no'), 245 PackageVariable('with_dbi', 'enable dbi support', 'no'), 246 BoolVariable('with_fam', 'enable FAM/gamin 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', '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_pcre2', 'enable pcre2 support', 'yes'), 262 PackageVariable('with_pcre', 'enable pcre support', 'no'), 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 BoolVariable('with_zstd', 'enable zstd compression', 'no'), 273 274 BoolVariable('with_all', 'enable all with_* features', 'no'), 275) 276 277env = Environment( 278 ENV = dict(os.environ), # make sure we have a dict here so .Clone() works properly 279 variables = vars, 280 CPPPATH = Split('#sconsbuild/build') 281) 282 283env.Help(vars.GenerateHelpText(env)) 284 285if env.subst('${CC}') != '': 286 env['CC'] = env.subst('${CC}') 287 288env['package'] = package 289env['version'] = version 290if env['CC'] == 'gcc': 291 ## we need x-open 6 and bsd 4.3 features 292 env.Append(CCFLAGS = Split('-pipe -Wall -O2 -g -W -pedantic -Wunused -Wshadow -std=gnu99')) 293 294env.Append(CPPFLAGS = [ 295 '-D_TIME_BITS=64', 296 '-D_FILE_OFFSET_BITS=64', 297 '-D_LARGEFILE_SOURCE', 298 '-D_LARGE_FILES', 299 '-D_GNU_SOURCE', 300]) 301 302if env['with_all']: 303 for feature in vars.keys(): 304 # only enable 'with_*' flags 305 if not feature.startswith('with_'): continue 306 # don't overwrite manual arguments 307 if feature in vars.args: continue 308 # now activate 309 env[feature] = True 310 311# cache configure checks 312if 1: 313 autoconf = Autoconf(env) 314 315 if 'CFLAGS' in os.environ: 316 autoconf.env.Append(CCFLAGS = os.environ['CFLAGS']) 317 print(">> Appending custom build flags : " + os.environ['CFLAGS']) 318 319 if 'LDFLAGS' in os.environ: 320 autoconf.env.Append(LINKFLAGS = os.environ['LDFLAGS']) 321 print(">> Appending custom link flags : " + os.environ['LDFLAGS']) 322 323 if 'LIBS' in os.environ: 324 autoconf.env.Append(APPEND_LIBS = os.environ['LIBS']) 325 print(">> Appending custom libraries : " + os.environ['LIBS']) 326 else: 327 autoconf.env.Append(APPEND_LIBS = '') 328 329 autoconf.env.Append( 330 LIBBROTLI = '', 331 LIBBZ2 = '', 332 LIBCRYPT = '', 333 LIBCRYPTO = '', 334 LIBDBI = '', 335 LIBDL = '', 336 LIBGNUTLS = '', 337 LIBGSSAPI_KRB5 = '', 338 LIBKRB5 = '', 339 LIBLBER = '', 340 LIBLDAP = '', 341 LIBLUA = '', 342 LIBMBEDTLS = '', 343 LIBMBEDX509 = '', 344 LIBMBEDCRYPTO = '', 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 LIBZSTD = '', 361 ) 362 363 autoconf.haveCHeaders([ 364 'arpa/inet.h', 365 'crypt.h', 366 'dlfcn.h', 367 'fcntl.h', 368 'getopt.h', 369 'inttypes.h', 370 'linux/random.h', 371 'malloc.h', 372 'poll.h', 373 'port.h', 374 'pwd.h', 375 'stdint.h', 376 'stdlib.h', 377 'string.h', 378 'strings.h', 379 'sys/devpoll.h', 380 'sys/epoll.h', 381 'sys/filio.h', 382 'sys/inotify.h', 383 'sys/loadavg.h', 384 'sys/poll.h', 385 'sys/prctl.h', 386 'sys/procctl.h', 387 'sys/sendfile.h', 388 'sys/time.h', 389 'sys/wait.h', 390 'syslog.h', 391 'unistd.h', 392 'winsock2.h', 393 394 # "have" the last header if we include others before? 395 ['sys/types.h', 'sys/time.h', 'sys/resource.h'], 396 ['sys/types.h', 'netinet/in.h'], 397 ['sys/types.h', 'sys/event.h'], 398 ['sys/types.h', 'sys/mman.h'], 399 ['sys/types.h', 'sys/select.h'], 400 ['sys/types.h', 'sys/socket.h'], 401 ['sys/types.h', 'sys/uio.h'], 402 ['sys/types.h', 'sys/un.h'], 403 ]) 404 405 autoconf.haveFuncs([ 406 'arc4random_buf', 407 'chroot', 408 'clock_gettime', 409 'copy_file_range', 410 'dup2', 411 'epoll_ctl', 412 'explicit_bzero', 413 'explicit_memset', 414 'fork', 415 'getcwd', 416 'gethostbyname', 417 'getloadavg', 418 'getopt', 419 'getrlimit', 420 'getuid', 421 'inet_aton', 422 'inet_pton', 423 'issetugid', 424 'jrand48', 425 'kqueue', 426 'localtime_r', 427 'lstat', 428 'madvise', 429 'malloc_trim', 430 'mallopt', 431 'memcpy', 432 'mempcpy', 433 'memset_s', 434 'memset', 435 'mkostemp', 436 'mmap', 437 'munmap', 438 'pipe2', 439 'poll', 440 'port_create', 441 'pread', 442 'preadv', 443 'pwrite', 444 'pwritev', 445 'select', 446 'send_file', 447 'sendfile', 448 'sendfile64', 449 'sigaction', 450 'signal', 451 'splice', 452 'srandom', 453 'stat', 454 'strchr', 455 'strdup', 456 'strerror', 457 'strerror_r', 458 'strftime', 459 'strstr', 460 'strtol', 461 'timegm', 462 'writev', 463 ]) 464 autoconf.haveFunc('getentropy', 'sys/random.h') 465 autoconf.haveFunc('getrandom', 'linux/random.h') 466 467 autoconf.haveTypes(Split('pid_t size_t off_t')) 468 469 # have crypt_r/crypt, and is -lcrypt needed? 470 if autoconf.CheckLib('crypt'): 471 autoconf.env.Append( 472 LIBCRYPT = 'crypt', 473 ) 474 with autoconf.restoreEnvLibs(): 475 autoconf.env['LIBS'] = ['crypt'] 476 autoconf.haveFuncs(['crypt', 'crypt_r']) 477 else: 478 autoconf.haveFuncs(['crypt', 'crypt_r']) 479 480 if autoconf.CheckType('socklen_t', '#include <unistd.h>\n#include <sys/socket.h>\n#include <sys/types.h>'): 481 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ]) 482 483 if autoconf.CheckType('struct sockaddr_storage', '#include <sys/socket.h>\n'): 484 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ]) 485 486 if autoconf.CheckLibWithHeader('elftc', 'libelftc.h', 'c', 'elftc_copyfile(0, 1);'): 487 autoconf.env.Append( 488 CPPFLAGS = [ '-DHAVE_ELFTC_COPYFILE' ], 489 LIBS = [ 'elftc' ], 490 ) 491 492 if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);'): 493 autoconf.env.Append( 494 CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ], 495 LIBS = [ 'rt' ], 496 ) 497 498 if autoconf.CheckIPv6(): 499 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_IPV6' ]) 500 501 if autoconf.CheckWeakSymbols(): 502 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_WEAK_SYMBOLS' ]) 503 504 if autoconf.CheckGmtOffInStructTm(): 505 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ]) 506 507 if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'): 508 autoconf.env.Append(LIBDL = 'dl') 509 510 if env['with_bzip2']: 511 if not autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'): 512 fail("Couldn't find bz2") 513 autoconf.env.Append( 514 CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], 515 LIBBZ2 = 'bz2', 516 ) 517 518 if env['with_brotli']: 519 if not autoconf.CheckParseConfigForLib('LIBBROTLI', 'pkg-config --static --cflags --libs libbrotlienc'): 520 fail("Couldn't find libbrotlienc") 521 autoconf.env.Append( 522 CPPFLAGS = [ '-DHAVE_BROTLI_ENCODE_H', '-DHAVE_BROTLI' ], 523 ) 524 525 if env['with_dbi']: 526 if not autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C'): 527 fail("Couldn't find dbi") 528 autoconf.env.Append( 529 CPPFLAGS = [ '-DHAVE_DBI' ], 530 LIBDBI = 'dbi', 531 ) 532 533 if env['with_fam'] and not autoconf.CheckCHeader('sys/inotify.h'): 534 if not autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'): 535 fail("Couldn't find fam") 536 autoconf.env.Append( 537 CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], 538 LIBS = [ 'fam' ], 539 ) 540 autoconf.haveFunc('FAMNoExists') 541 542 if env['with_maxminddb']: 543 if not autoconf.CheckLibWithHeader('maxminddb', 'maxminddb.h', 'C'): 544 fail("Couldn't find maxminddb") 545 autoconf.env.Append( 546 CPPFLAGS = [ '-DHAVE_MAXMINDDB' ], 547 LIBMAXMINDDB = 'maxminddb', 548 ) 549 550 if env['with_krb5']: 551 if not autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C'): 552 fail("Couldn't find krb5") 553 if not autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C'): 554 fail("Couldn't find gssapi_krb5") 555 autoconf.env.Append( 556 CPPFLAGS = [ '-DHAVE_KRB5' ], 557 LIBKRB5 = 'krb5', 558 LIBGSSAPI_KRB5 = 'gssapi_krb5', 559 ) 560 561 if env['with_ldap']: 562 if not autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C'): 563 fail("Couldn't find ldap") 564 if not autoconf.CheckLibWithHeader('lber', 'lber.h', 'C'): 565 fail("Couldn't find lber") 566 autoconf.env.Append( 567 CPPFLAGS = [ 568 '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP', 569 '-DHAVE_LBER_H', '-DHAVE_LIBLBER', 570 ], 571 LIBLDAP = 'ldap', 572 LIBLBER = 'lber', 573 ) 574 575 if env['with_lua']: 576 found_lua = False 577 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']: 578 print("Searching for lua: " + lua_name + " >= 5.0") 579 if autoconf.CheckParseConfigForLib('LIBLUA', "pkg-config '" + lua_name + " >= 5.0' --cflags --libs"): 580 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ]) 581 found_lua = True 582 break 583 if not found_lua: 584 fail("Couldn't find any lua implementation") 585 586 if env['with_mysql']: 587 mysql_config = autoconf.checkProgram('mysql', 'mysql_config') 588 if not autoconf.CheckParseConfigForLib('LIBMYSQL', mysql_config + ' --cflags --libs'): 589 fail("Couldn't find mysql") 590 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MYSQL' ]) 591 592 if env['with_nss']: 593 nss_config = autoconf.checkProgram('nss', 'nss-config') 594 if not autoconf.CheckParseConfigForLib('LIBNSS', nss_config + ' --cflags --libs'): 595 fail("Couldn't find NSS") 596 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_NSS3_NSS_H' ]) 597 598 if env['with_openssl']: 599 if not autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'): 600 fail("Couldn't find openssl") 601 autoconf.env.Append( 602 CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'], 603 LIBSSL = 'ssl', 604 LIBSSLCRYPTO = 'crypto', 605 LIBCRYPTO = 'crypto', 606 ) 607 608 if env['with_wolfssl']: 609 if type(env['with_wolfssl']) is str: 610 autoconf.env.AppendUnique( 611 CPPPATH = [ env['with_wolfssl'] + '/include', 612 env['with_wolfssl'] + '/include/wolfssl' ], 613 LIBPATH = [ env['with_wolfssl'] + '/lib' ], 614 ) 615 if not autoconf.CheckLibWithHeader('wolfssl', 'wolfssl/ssl.h', 'C'): 616 fail("Couldn't find wolfssl") 617 autoconf.env.Append( 618 CPPFLAGS = [ '-DHAVE_WOLFSSL_SSL_H' ], 619 LIBWOLFSSL= 'wolfssl', 620 LIBCRYPTO = 'wolfssl', 621 ) 622 623 if env['with_mbedtls']: 624 if not autoconf.CheckLibWithHeader('mbedtls', 'mbedtls/ssl.h', 'C'): 625 fail("Couldn't find mbedtls") 626 autoconf.env.Append( 627 CPPFLAGS = [ '-DHAVE_LIBMBEDCRYPTO' ], 628 LIBMBEDTLS = 'mbedtls', 629 LIBMBEDX509 = 'mbedx509', 630 LIBMBEDCRYPTO = 'mbedcrypto', 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_pcre2'] and not env['with_pcre']: 663 pcre2_config = autoconf.checkProgram('pcre2', 'pcre2-config') 664 if not autoconf.CheckParseConfigForLib('LIBPCRE', pcre2_config + ' --cflags --libs8'): 665 fail("Couldn't find pcre2") 666 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PCRE2_H', '-DHAVE_PCRE' ]) 667 elif env['with_pcre']: 668 pcre_config = autoconf.checkProgram('pcre', 'pcre-config') 669 if not autoconf.CheckParseConfigForLib('LIBPCRE', pcre_config + ' --cflags --libs'): 670 fail("Couldn't find pcre") 671 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_PCRE' ]) 672 673 if env['with_pgsql']: 674 if not autoconf.CheckParseConfigForLib('LIBPGSQL', 'pkg-config libpq --cflags --libs'): 675 fail("Couldn't find libpq") 676 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PGSQL' ]) 677 678 if env['with_sasl']: 679 if not autoconf.CheckLibWithHeader('sasl2', 'sasl/sasl.h', 'C'): 680 fail("Couldn't find libsasl2") 681 autoconf.env.Append( 682 CPPFLAGS = [ '-DHAVE_SASL' ], 683 LIBSASL = 'sasl2', 684 ) 685 686 if env['with_sqlite3']: 687 if not autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'): 688 fail("Couldn't find sqlite3") 689 autoconf.env.Append( 690 CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], 691 LIBSQLITE3 = 'sqlite3', 692 ) 693 694 if env['with_uuid']: 695 if not autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C'): 696 fail("Couldn't find uuid") 697 autoconf.env.Append( 698 CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], 699 LIBUUID = 'uuid', 700 ) 701 702 if env['with_xml']: 703 xml2_config = autoconf.checkProgram('xml', 'xml2-config') 704 if not autoconf.CheckParseConfigForLib('LIBXML2', xml2_config + ' --cflags --libs'): 705 fail("Couldn't find xml2") 706 autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ]) 707 708 if env['with_xxhash']: 709 if not autoconf.CheckLibWithHeader('xxhash', 'xxhash.h', 'C'): 710 fail("Couldn't find xxhash") 711 autoconf.env.Append( 712 CPPFLAGS = [ '-DHAVE_XXHASH_H' ], 713 LIBXXHASH = 'xxhash', 714 ) 715 716 if env['with_zlib']: 717 if not autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'): 718 fail("Couldn't find zlib") 719 autoconf.env.Append( 720 CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], 721 LIBZ = 'z', 722 ) 723 724 if env['with_zstd']: 725 if not autoconf.CheckLibWithHeader('zstd', 'zstd.h', 'C'): 726 fail("Couldn't find zstd") 727 autoconf.env.Append( 728 CPPFLAGS = [ '-DHAVE_ZSTD_H', '-DHAVE_ZSTD' ], 729 LIBZSTD = 'zstd', 730 ) 731 732 env = autoconf.Finish() 733 734if re.compile("cygwin|mingw|midipix").search(env['PLATFORM']): 735 env.Append(COMMON_LIB = 'bin') 736elif re.compile("darwin|aix").search(env['PLATFORM']): 737 env.Append(COMMON_LIB = 'lib') 738else: 739 env.Append(COMMON_LIB = False) 740 741versions = version.split('.') 742version_id = int(versions[0]) << 16 | int(versions[1]) << 8 | int(versions[2]) 743env.Append(CPPFLAGS = [ 744 '-DLIGHTTPD_VERSION_ID=' + hex(version_id), 745 '-DPACKAGE_NAME=\\"' + package + '\\"', 746 '-DPACKAGE_VERSION=\\"' + version + '\\"', 747 '-DLIBRARY_DIR="\\"${libdir}\\""', 748 ] ) 749 750SConscript('src/SConscript', exports = 'env', variant_dir = 'sconsbuild/build', duplicate = 0) 751SConscript('tests/SConscript', exports = 'env', variant_dir = 'sconsbuild/tests') 752