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