From ccba074c1e8a558d371fe2afb79c83260d45c923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 12:06:26 +0200 Subject: [PATCH 01/21] [scons] sort with_* options, document missing options --- SConstruct | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/SConstruct b/SConstruct index ff89aec9..5954c2ea 100644 --- a/SConstruct +++ b/SConstruct @@ -114,26 +114,32 @@ vars.AddVariables( ('bindir', 'binary directory', '${prefix}/bin'), ('sbindir', 'binary directory', '${prefix}/sbin'), ('libdir', 'library directory', '${prefix}/lib'), - PackageVariable('with_mysql', 'enable mysql support', 'no'), - PackageVariable('with_pgsql', 'enable pgsql support', 'no'), - PackageVariable('with_dbi', 'enable dbi support', 'no'), - PackageVariable('with_xml', 'enable xml support', 'no'), - PackageVariable('with_pcre', 'enable pcre support', 'yes'), PathVariable('CC', 'path to the c-compiler', None), BoolVariable('build_dynamic', 'enable dynamic build', 'yes'), BoolVariable('build_static', 'enable static build', 'no'), BoolVariable('build_fullstatic', 'enable fullstatic build', 'no'), - BoolVariable('with_sqlite3', 'enable sqlite3 support', 'no'), - BoolVariable('with_memcached', 'enable memcached support', 'no'), - BoolVariable('with_gdbm', 'enable gdbm support', 'no'), + + BoolVariable('with_bzip2', 'enable bzip2 compression', 'no'), + PackageVariable('with_dbi', 'enable dbi support', 'no'), BoolVariable('with_fam', 'enable FAM/gamin support', 'no'), - BoolVariable('with_openssl', 'enable openssl support', 'no'), + BoolVariable('with_gdbm', 'enable gdbm support', 'no'), + BoolVariable('with_geoip', 'enable GeoIP support', 'no'), BoolVariable('with_gzip', 'enable gzip compression', 'no'), - BoolVariable('with_bzip2', 'enable bzip2 compression', 'no'), - BoolVariable('with_lua', 'enable lua support for mod_cml', 'no'), - BoolVariable('with_ldap', 'enable ldap auth support', 'no'), BoolVariable('with_krb5', 'enable krb5 auth support', 'no'), - BoolVariable('with_geoip', 'enable GeoIP support', 'no') + BoolVariable('with_ldap', 'enable ldap auth support', 'no'), + # with_libev not supported + # with_libunwind not supported + BoolVariable('with_lua', 'enable lua support for mod_cml', 'no'), + BoolVariable('with_memcached', 'enable memcached support', 'no'), + PackageVariable('with_mysql', 'enable mysql support', 'no'), + BoolVariable('with_openssl', 'enable openssl support', 'no'), + PackageVariable('with_pcre', 'enable pcre support', 'yes'), + PackageVariable('with_pgsql', 'enable pgsql support', 'no'), + BoolVariable('with_sqlite3', 'enable sqlite3 support', 'no'), + # with_uuid not supported + # with_valgrind not supported + # with_xattr not supported + PackageVariable('with_xml', 'enable xml support', 'no'), ) env = Environment( From 73ef60a5a122725114fc50ab9f3940de428066dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 12:07:30 +0200 Subject: [PATCH 02/21] [scons] config.py(-sample) not used, remove them --- SConstruct | 2 +- config.py-sample | 15 --------------- 2 files changed, 1 insertion(+), 16 deletions(-) delete mode 100644 config.py-sample diff --git a/SConstruct b/SConstruct index 5954c2ea..0ef9be8c 100644 --- a/SConstruct +++ b/SConstruct @@ -108,7 +108,7 @@ def checkProgram(env, withname, progname): VariantDir('sconsbuild/build', 'src', duplicate = 0) VariantDir('sconsbuild/tests', 'tests', duplicate = 0) -vars = Variables() #('config.py') +vars = Variables() vars.AddVariables( ('prefix', 'prefix', '/usr/local'), ('bindir', 'binary directory', '${prefix}/bin'), diff --git a/config.py-sample b/config.py-sample deleted file mode 100644 index d97ae534..00000000 --- a/config.py-sample +++ /dev/null @@ -1,15 +0,0 @@ -prefix='/home/jan/testbase/lighttpd-scons' -with_mysql='/usr/local/mysql/bin/mysql_config' -with_pcre='yes' -with_openssl='yes' -with_gzip='yes' -with_bzip2='yes' -with_memcache='yes' -with_sqlite3='yes' -with_xml='yes' -# default 'no' -build_static='no' -# default 'no' -build_fullstatic='no' -# default 'yes' -build_dynamic='yes' From fff8e70567467ada18c46c8af6d722236295b75f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 12:09:03 +0200 Subject: [PATCH 03/21] [scons] rename with_gzip to with_zlib --- SConstruct | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index 0ef9be8c..4bb9e380 100644 --- a/SConstruct +++ b/SConstruct @@ -124,7 +124,6 @@ vars.AddVariables( BoolVariable('with_fam', 'enable FAM/gamin support', 'no'), BoolVariable('with_gdbm', 'enable gdbm support', 'no'), BoolVariable('with_geoip', 'enable GeoIP support', 'no'), - BoolVariable('with_gzip', 'enable gzip compression', 'no'), BoolVariable('with_krb5', 'enable krb5 auth support', 'no'), BoolVariable('with_ldap', 'enable ldap auth support', 'no'), # with_libev not supported @@ -140,6 +139,7 @@ vars.AddVariables( # with_valgrind not supported # with_xattr not supported PackageVariable('with_xml', 'enable xml support', 'no'), + BoolVariable('with_zlib', 'enable deflate/gzip compression', 'no'), ) env = Environment( @@ -266,7 +266,7 @@ if 1: if autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'] , LIBSSL = 'ssl', LIBCRYPTO = 'crypto', LIBS = [ 'crypto' ]) - if env['with_gzip']: + if env['with_zlib']: if autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], LIBZ = 'z') From 2506e21b08e271426b9b1959b36537ea4835b2ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 12:10:09 +0200 Subject: [PATCH 04/21] [scons] add with_all option --- SConstruct | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/SConstruct b/SConstruct index 4bb9e380..8acc4085 100644 --- a/SConstruct +++ b/SConstruct @@ -140,6 +140,8 @@ vars.AddVariables( # with_xattr not supported PackageVariable('with_xml', 'enable xml support', 'no'), BoolVariable('with_zlib', 'enable deflate/gzip compression', 'no'), + + BoolVariable('with_all', 'enable all with_* features', 'no'), ) env = Environment( @@ -159,6 +161,15 @@ if env['CC'] == 'gcc': ## we need x-open 6 and bsd 4.3 features env.Append(CCFLAGS = Split('-Wall -O2 -g -W -pedantic -Wunused -Wshadow -std=gnu99')) +if env['with_all']: + for feature in vars.keys(): + # only enable 'with_*' flags + if not feature.startswith('with_'): continue + # don't overwrite manual arguments + if feature in vars.args: continue + # now activate + env[feature] = True + # cache configure checks if 1: autoconf = Configure(env, custom_tests = { From 96e198d6215af3434eeeb1e31c43a7188663e826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 12:21:18 +0200 Subject: [PATCH 05/21] [scons] fix with_pgsql pg_config --includedir --libdir doesn't print the "-I" or "-l" prefixes, so ParseConfig can't parse it. Use pkg-config instead. --- SConstruct | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 8acc4085..a9838786 100644 --- a/SConstruct +++ b/SConstruct @@ -385,14 +385,11 @@ if env['with_mysql']: env['LIBS'] = oldlib if env['with_pgsql']: - pg_config = checkProgram(env, 'pgsql', 'pg_config') oldlib = env['LIBS'] env['LIBS'] = [] - env.ParseConfig(pg_config + ' --includedir --libdir') + env.ParseConfig('pkg-config libpq --cflags --libs') env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ], LIBPGSQL = 'pq') env['LIBS'] = oldlib - #if autoconf.CheckLibWithHeader('pq', 'libpq-fe.h', 'C'): - # env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ], LIBPGSQL = 'pq') if env['with_dbi']: if autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C'): From 21dfe350ae474e4b14b178a6575969f9fd747f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 12:25:45 +0200 Subject: [PATCH 06/21] [scons] sort modules --- src/SConscript | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/SConscript b/src/SConscript index 3665e45d..5c9f9a3f 100644 --- a/src/SConscript +++ b/src/SConscript @@ -93,37 +93,37 @@ mod_ssi_exprparser = Lemon(env, 'mod_ssi_exprparser.y') ## the modules and how they are built modules = { 'mod_access' : { 'src' : [ 'mod_access.c' ] }, + 'mod_accesslog' : { 'src' : [ 'mod_accesslog.c' ] }, 'mod_alias' : { 'src' : [ 'mod_alias.c' ] }, + 'mod_auth' : { 'src' : [ 'mod_auth.c' ] }, + 'mod_authn_file' : { 'src' : [ 'mod_authn_file.c' ], 'lib' : [ env['LIBCRYPT'], env['LIBCRYPTO'] ] }, 'mod_cgi' : { 'src' : [ 'mod_cgi.c' ] }, - 'mod_fastcgi' : { 'src' : [ 'mod_fastcgi.c' ] }, - 'mod_scgi' : { 'src' : [ 'mod_scgi.c' ] }, - 'mod_extforward' : { 'src' : [ 'mod_extforward.c' ] }, - 'mod_staticfile' : { 'src' : [ 'mod_staticfile.c' ] }, + 'mod_compress' : { 'src' : [ 'mod_compress.c' ], 'lib' : [ env['LIBZ'], env['LIBBZ2'] ] }, + 'mod_deflate' : { 'src' : [ 'mod_deflate.c' ], 'lib' : [ env['LIBZ'], env['LIBBZ2'] ] }, 'mod_dirlisting' : { 'src' : [ 'mod_dirlisting.c' ], 'lib' : [ env['LIBPCRE'] ] }, + 'mod_evasive' : { 'src' : [ 'mod_evasive.c' ] }, + 'mod_evhost' : { 'src' : [ 'mod_evhost.c' ] }, + 'mod_expire' : { 'src' : [ 'mod_expire.c' ] }, + 'mod_extforward' : { 'src' : [ 'mod_extforward.c' ] }, + 'mod_fastcgi' : { 'src' : [ 'mod_fastcgi.c' ] }, + 'mod_flv_streaming' : { 'src' : [ 'mod_flv_streaming.c' ] }, 'mod_indexfile' : { 'src' : [ 'mod_indexfile.c' ] }, - 'mod_setenv' : { 'src' : [ 'mod_setenv.c' ] }, - 'mod_rrdtool' : { 'src' : [ 'mod_rrdtool.c' ] }, - 'mod_usertrack' : { 'src' : [ 'mod_usertrack.c' ] }, 'mod_proxy' : { 'src' : [ 'mod_proxy.c' ] }, - 'mod_userdir' : { 'src' : [ 'mod_userdir.c' ] }, + 'mod_redirect' : { 'src' : [ 'mod_redirect.c' ], 'lib' : [ env['LIBPCRE'] ] }, + 'mod_rewrite' : { 'src' : [ 'mod_rewrite.c' ], 'lib' : [ env['LIBPCRE'] ] }, + 'mod_rrdtool' : { 'src' : [ 'mod_rrdtool.c' ] }, + 'mod_scgi' : { 'src' : [ 'mod_scgi.c' ] }, 'mod_secdownload' : { 'src' : [ 'mod_secdownload.c' ], 'lib' : [ env['LIBCRYPTO'] ] }, - 'mod_accesslog' : { 'src' : [ 'mod_accesslog.c' ] }, + 'mod_setenv' : { 'src' : [ 'mod_setenv.c' ] }, 'mod_simple_vhost' : { 'src' : [ 'mod_simple_vhost.c' ] }, - 'mod_evhost' : { 'src' : [ 'mod_evhost.c' ] }, - 'mod_expire' : { 'src' : [ 'mod_expire.c' ] }, + 'mod_ssi' : { 'src' : [ 'mod_ssi_exprparser.c', 'mod_ssi_expr.c', 'mod_ssi.c' ] }, + 'mod_staticfile' : { 'src' : [ 'mod_staticfile.c' ] }, 'mod_status' : { 'src' : [ 'mod_status.c' ] }, - 'mod_compress' : { 'src' : [ 'mod_compress.c' ], 'lib' : [ env['LIBZ'], env['LIBBZ2'] ] }, - 'mod_deflate' : { 'src' : [ 'mod_deflate.c' ], 'lib' : [ env['LIBZ'], env['LIBBZ2'] ] }, - 'mod_redirect' : { 'src' : [ 'mod_redirect.c' ], 'lib' : [ env['LIBPCRE'] ] }, - 'mod_rewrite' : { 'src' : [ 'mod_rewrite.c' ], 'lib' : [ env['LIBPCRE'] ] }, - 'mod_auth' : { 'src' : [ 'mod_auth.c' ] }, - 'mod_authn_file' : { 'src' : [ 'mod_authn_file.c' ], 'lib' : [ env['LIBCRYPT'], env['LIBCRYPTO'] ] }, - 'mod_webdav' : { 'src' : [ 'mod_webdav.c' ], 'lib' : [ env['LIBXML2'], env['LIBSQLITE3'], env['LIBUUID'] ] }, 'mod_uploadprogress' : { 'src' : [ 'mod_uploadprogress.c' ] }, - 'mod_evasive' : { 'src' : [ 'mod_evasive.c' ] }, - 'mod_ssi' : { 'src' : [ 'mod_ssi_exprparser.c', 'mod_ssi_expr.c', 'mod_ssi.c' ] }, - 'mod_flv_streaming' : { 'src' : [ 'mod_flv_streaming.c' ] }, + 'mod_userdir' : { 'src' : [ 'mod_userdir.c' ] }, + 'mod_usertrack' : { 'src' : [ 'mod_usertrack.c' ] }, 'mod_vhostdb' : { 'src' : [ 'mod_vhostdb.c' ] }, + 'mod_webdav' : { 'src' : [ 'mod_webdav.c' ], 'lib' : [ env['LIBXML2'], env['LIBSQLITE3'], env['LIBUUID'] ] }, 'mod_wstunnel' : { 'src' : [ 'mod_wstunnel.c' ], 'lib' : [ env['LIBCRYPTO'] ] }, } @@ -281,7 +281,7 @@ for module in modules.keys(): libs = [ common_lib ] if modules[module].has_key('lib'): libs += modules[module]['lib'] - instlib += env.SharedLibrary(module, modules[module]['src'], LIBS= GatherLibs(env, libs)) + instlib += env.SharedLibrary(module, modules[module]['src'], LIBS = GatherLibs(env, libs)) env.Alias('modules', instlib) inst = [] From b8989bf2dd0a254c3df706296e51d3fd2f971402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 12:29:18 +0200 Subject: [PATCH 07/21] [scons] fix some lib dependencies - mod_cml: doesn't need pcre - mod_trigger_b4_dl: needs gdbm - lighttpd: needs crypto and pcre --- src/SConscript | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/SConscript b/src/SConscript index 5c9f9a3f..b9c9537a 100644 --- a/src/SConscript +++ b/src/SConscript @@ -141,11 +141,11 @@ if env['with_lua']: modules['mod_magnet'] = { 'src' : [ 'mod_magnet.c', 'mod_magnet_cache.c' ], 'lib' : [ env['LIBLUA'] ] } modules['mod_cml'] = { 'src' : [ 'mod_cml_lua.c', 'mod_cml.c', 'mod_cml_funcs.c' ], - 'lib' : [ env['LIBPCRE'], env['LIBMEMCACHED'], env['LIBLUA'] ] + 'lib' : [ env['LIBMEMCACHED'], env['LIBLUA'] ] } if env['with_pcre'] and (env['with_memcached'] or env['with_gdbm']): - modules['mod_trigger_b4_dl'] = { 'src' : [ 'mod_trigger_b4_dl.c' ], 'lib' : [ env['LIBPCRE'], env['LIBMEMCACHED'] ] } + modules['mod_trigger_b4_dl'] = { 'src' : [ 'mod_trigger_b4_dl.c' ], 'lib' : [ env['LIBPCRE'], env['LIBMEMCACHED'], env['LIBGDBM'] ] } if env['with_mysql']: modules['mod_authn_mysql'] = { 'src' : [ 'mod_authn_mysql.c' ], 'lib' : [ env['LIBCRYPT'], env['LIBMYSQL'] ] } @@ -269,7 +269,15 @@ else: else: bin_linkflags += [ '-Wl,--export-dynamic' ] -instbin = env.Program(bin_targets, src, LINKFLAGS = bin_linkflags, LIBS = GatherLibs(env, env['LIBS'], common_lib, env['LIBDL'])) +instbin = env.Program(bin_targets, src, LINKFLAGS = bin_linkflags, + LIBS = GatherLibs( + env, + common_lib, + env['LIBCRYPTO'], + env['LIBDL'], + env['LIBPCRE'], + ) +) env.Depends(instbin, configparser) if env['COMMON_LIB'] == 'bin': From 68a92f2c3c9a496b2ae1fb19e7443f2232a6bb8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 12:32:23 +0200 Subject: [PATCH 08/21] [scons] don't link pthread twice in --whole-archive workaround --- src/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SConscript b/src/SConscript index b9c9537a..3e0c2e83 100644 --- a/src/SConscript +++ b/src/SConscript @@ -244,6 +244,7 @@ fullstatic_libs = GatherLibs(env, fullstaticlib) fullstatic_linkflags = [staticenv['LINKFLAGS'], '-static'] if (('pthread' in fullstatic_libs) or ('pcre' in fullstatic_libs)) and (platform.system() == 'Linux'): fullstatic_linkflags += ['-Wl,--whole-archive','-lpthread','-Wl,--no-whole-archive'] + fullstatic_libs.remove('pthread') ## includes all modules, linked statically fullstaticbin = staticenv.Program('../fullstatic/build/lighttpd', From 2144cd2e39f4b1cf5104d2710ffab9ed0feb496f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 12:33:01 +0200 Subject: [PATCH 09/21] [scons] link -static-libgcc instead of gcc_s --- src/SConscript | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/SConscript b/src/SConscript index 3e0c2e83..779913b3 100644 --- a/src/SConscript +++ b/src/SConscript @@ -245,6 +245,9 @@ fullstatic_linkflags = [staticenv['LINKFLAGS'], '-static'] if (('pthread' in fullstatic_libs) or ('pcre' in fullstatic_libs)) and (platform.system() == 'Linux'): fullstatic_linkflags += ['-Wl,--whole-archive','-lpthread','-Wl,--no-whole-archive'] fullstatic_libs.remove('pthread') +if 'gcc_s' in fullstatic_libs: + fullstatic_linkflags += ['-static-libgcc'] + fullstatic_libs.remove('gcc_s') ## includes all modules, linked statically fullstaticbin = staticenv.Program('../fullstatic/build/lighttpd', From 2eb7287a9847c5e2159da0823c5565d02d3006ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 12:34:12 +0200 Subject: [PATCH 10/21] [scons] don't screw env[LIBS] - copy() when collecting dependencies for static module linking - copy() when following operations append to it and we don't reset it to an empty list - use autoadd = 0 for many functions to prevent modifying env[LIBS] in the first place - append to env[LIBS] manually to make it explicit (fam and rt) --- SConstruct | 58 +++++++++++++++++++++++++------------------------- src/SConscript | 5 +++-- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/SConstruct b/SConstruct index a9838786..80e0278e 100644 --- a/SConstruct +++ b/SConstruct @@ -1,7 +1,8 @@ import os -import sys import re import string +import sys +from copy import copy from stat import * package = 'lighttpd' @@ -254,74 +255,70 @@ if 1: LIBKRB5 = '', LIBGSSAPI_KRB5 = '', LIBGDBM = '', LIBSSL = '', LIBCRYPTO = '') if env['with_fam']: - if autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], LIBS = 'fam') + if autoconf.CheckLibWithHeader('fam', 'fam.h', 'C', autoadd = 0): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], LIBS = [ 'fam' ]) checkFuncs(autoconf, ['FAMNoExists']); - if autoconf.CheckLib('crypt'): + if autoconf.CheckLib('crypt', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBCRYPT' ], LIBCRYPT = 'crypt') oldlib = env['LIBS'] - env['LIBS'] += ['crypt'] - checkFuncs(autoconf, ['crypt', 'crypt_r']); + env['LIBS'] = ['crypt'] + checkFuncs(autoconf, ['crypt', 'crypt_r']) env['LIBS'] = oldlib else: - checkFuncs(autoconf, ['crypt', 'crypt_r']); + checkFuncs(autoconf, ['crypt', 'crypt_r']) - if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);'): + if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ], LIBS = [ 'rt' ]) - if autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C'): + if autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], LIBUUID = 'uuid') if env['with_openssl']: - if autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'] , LIBSSL = 'ssl', LIBCRYPTO = 'crypto', LIBS = [ 'crypto' ]) + if autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C', autoadd = 0): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'] , LIBSSL = 'ssl', LIBCRYPTO = 'crypto') if env['with_zlib']: - if autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'): + if autoconf.CheckLibWithHeader('z', 'zlib.h', 'C', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], LIBZ = 'z') if env['with_krb5']: - if autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C'): + if autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_KRB5' ], LIBKRB5 = 'krb5') - if autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C'): + if autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C', autoadd = 0): autoconf.env.Append(LIBGSSAPI_KRB5 = 'gssapi_krb5') if env['with_ldap']: - if autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C'): + if autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP' ], LIBLDAP = 'ldap') - if autoconf.CheckLibWithHeader('lber', 'lber.h', 'C'): + if autoconf.CheckLibWithHeader('lber', 'lber.h', 'C', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LBER_H', '-DHAVE_LIBLBER' ], LIBLBER = 'lber') if env['with_bzip2']: - if autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'): + if autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], LIBBZ2 = 'bz2') if env['with_memcached']: - if autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C'): + if autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DUSE_MEMCACHED' ], LIBMEMCACHED = 'memcached') if env['with_gdbm']: - if autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C'): + if autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ], LIBGDBM = 'gdbm') if env['with_sqlite3']: - if autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'): + if autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], LIBSQLITE3 = 'sqlite3') if env['with_geoip']: - if autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C'): + if autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GEOIP' ], LIBGEOIP = 'GeoIP') - ol = env['LIBS'] - if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C'): + if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C', autoadd = 0): autoconf.env.Append(LIBFCGI = 'fcgi') - env['LIBS'] = ol - ol = env['LIBS'] - if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'): + if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C', autoadd = 0): autoconf.env.Append(LIBDL = 'dl') - env['LIBS'] = ol if autoconf.CheckType('socklen_t', '#include \n#include \n#include '): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ]) @@ -342,7 +339,7 @@ if 1: def TryLua(env, name): result = False - oldlibs = env['LIBS'] + oldlibs = copy(env['LIBS']) try: print("Searching for lua: " + name + " >= 5.0") env.ParseConfig("pkg-config '" + name + " >= 5.0' --cflags --libs") @@ -365,8 +362,11 @@ if env['with_lua']: if env['with_pcre']: pcre_config = checkProgram(env, 'pcre', 'pcre-config') + oldlib = env['LIBS'] + env['LIBS'] = [] env.ParseConfig(pcre_config + ' --cflags --libs') - env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ], LIBPCRE = 'pcre') + env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ], LIBPCRE = env['LIBS']) + env['LIBS'] = oldlib if env['with_xml']: xml2_config = checkProgram(env, 'xml', 'xml2-config') diff --git a/src/SConscript b/src/SConscript index 779913b3..4c2ba11a 100644 --- a/src/SConscript +++ b/src/SConscript @@ -1,8 +1,9 @@ +import itertools import os import re import types -import itertools from collections import OrderedDict +from copy import copy # search any file, not just executables def WhereIsFile(file, paths): @@ -166,7 +167,7 @@ staticenv = env.Clone(CPPFLAGS=[ env['CPPFLAGS'], '-DLIGHTTPD_STATIC' ]) ## all the core-sources + the modules staticsrc = src + common_src -staticlib = env['LIBS'] +staticlib = copy(env['LIBS']) staticinit = '' for module in modules.keys(): staticsrc += modules[module]['src'] From a4f7845dbf081399f9f44b9a2cc29e5ff999f19e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 13:20:32 +0200 Subject: [PATCH 11/21] [scons] fix dbi --- SConstruct | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 80e0278e..20987e7e 100644 --- a/SConstruct +++ b/SConstruct @@ -314,6 +314,10 @@ if 1: if autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GEOIP' ], LIBGEOIP = 'GeoIP') + if env['with_dbi']: + if autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C', autoadd = 0): + env.Append(CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], LIBDBI = 'dbi') + if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C', autoadd = 0): autoconf.env.Append(LIBFCGI = 'fcgi') @@ -391,10 +395,6 @@ if env['with_pgsql']: env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ], LIBPGSQL = 'pq') env['LIBS'] = oldlib -if env['with_dbi']: - if autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C'): - env.Append(CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], LIBDBI = 'dbi') - if re.compile("cygwin|mingw|midipix").search(env['PLATFORM']): env.Append(COMMON_LIB = 'bin') elif re.compile("darwin|aix").search(env['PLATFORM']): From 08c8749b481ce3a2e3fb3ac026dea2a3d7d84f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 13:34:37 +0200 Subject: [PATCH 12/21] [scons] add with_uuid option, document webdav relations --- SConstruct | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/SConstruct b/SConstruct index 20987e7e..c6ae4254 100644 --- a/SConstruct +++ b/SConstruct @@ -135,11 +135,11 @@ vars.AddVariables( BoolVariable('with_openssl', 'enable openssl support', 'no'), PackageVariable('with_pcre', 'enable pcre support', 'yes'), PackageVariable('with_pgsql', 'enable pgsql support', 'no'), - BoolVariable('with_sqlite3', 'enable sqlite3 support', 'no'), - # with_uuid not supported + BoolVariable('with_sqlite3', 'enable sqlite3 support (required for webdav props)', 'no'), + BoolVariable('with_uuid', 'enable uuid support (required for webdav locks)', 'no'), # with_valgrind not supported # with_xattr not supported - PackageVariable('with_xml', 'enable xml support', 'no'), + PackageVariable('with_xml', 'enable xml support (required for webdav props)', 'no'), BoolVariable('with_zlib', 'enable deflate/gzip compression', 'no'), BoolVariable('with_all', 'enable all with_* features', 'no'), @@ -271,8 +271,9 @@ if 1: if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ], LIBS = [ 'rt' ]) - if autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], LIBUUID = 'uuid') + if env['with_uuid']: + if autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C', autoadd = 0): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], LIBUUID = 'uuid') if env['with_openssl']: if autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C', autoadd = 0): From 505cc7856dbeae8c8cadf3ff63152f5116ffe78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 13:30:04 +0200 Subject: [PATCH 13/21] [scons] check all features in autoconf block and sort them --- SConstruct | 202 +++++++++++++++++++++++++++-------------------------- 1 file changed, 102 insertions(+), 100 deletions(-) diff --git a/SConstruct b/SConstruct index c6ae4254..afb58776 100644 --- a/SConstruct +++ b/SConstruct @@ -254,11 +254,7 @@ if 1: LIBLDAP = '', LIBLBER = '', LIBLUA = '', LIBDL = '', LIBUUID = '', LIBKRB5 = '', LIBGSSAPI_KRB5 = '', LIBGDBM = '', LIBSSL = '', LIBCRYPTO = '') - if env['with_fam']: - if autoconf.CheckLibWithHeader('fam', 'fam.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], LIBS = [ 'fam' ]) - checkFuncs(autoconf, ['FAMNoExists']); - + # have crypt_r/crypt, and is -lcrypt needed? if autoconf.CheckLib('crypt', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBCRYPT' ], LIBCRYPT = 'crypt') oldlib = env['LIBS'] @@ -268,20 +264,51 @@ if 1: else: checkFuncs(autoconf, ['crypt', 'crypt_r']) + if autoconf.CheckType('socklen_t', '#include \n#include \n#include '): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ]) + + if autoconf.CheckType('struct sockaddr_storage', '#include \n'): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ]) + if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ], LIBS = [ 'rt' ]) - if env['with_uuid']: - if autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], LIBUUID = 'uuid') + if autoconf.CheckIPv6(): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_IPV6' ]) - if env['with_openssl']: - if autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'] , LIBSSL = 'ssl', LIBCRYPTO = 'crypto') + if autoconf.CheckWeakSymbols(): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_WEAK_SYMBOLS' ]) - if env['with_zlib']: - if autoconf.CheckLibWithHeader('z', 'zlib.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], LIBZ = 'z') + if autoconf.CheckGmtOffInStructTm(): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ]) + + if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C', autoadd = 0): + autoconf.env.Append(LIBDL = 'dl') + + # used in tests if present + if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C', autoadd = 0): + autoconf.env.Append(LIBFCGI = 'fcgi') + + if env['with_bzip2']: + if autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C', autoadd = 0): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], LIBBZ2 = 'bz2') + + if env['with_dbi']: + if autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C', autoadd = 0): + env.Append(CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], LIBDBI = 'dbi') + + if env['with_fam']: + if autoconf.CheckLibWithHeader('fam', 'fam.h', 'C', autoadd = 0): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], LIBS = [ 'fam' ]) + checkFuncs(autoconf, ['FAMNoExists']); + + if env['with_gdbm']: + if autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C', autoadd = 0): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ], LIBGDBM = 'gdbm') + + if env['with_geoip']: + if autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C', autoadd = 0): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GEOIP' ], LIBGEOIP = 'GeoIP') if env['with_krb5']: if autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C', autoadd = 0): @@ -295,107 +322,82 @@ if 1: if autoconf.CheckLibWithHeader('lber', 'lber.h', 'C', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LBER_H', '-DHAVE_LIBLBER' ], LIBLBER = 'lber') - if env['with_bzip2']: - if autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], LIBBZ2 = 'bz2') + if env['with_lua']: + def TryLua(env, name): + result = False + oldlibs = copy(env['LIBS']) + try: + print("Searching for lua: " + name + " >= 5.0") + env.ParseConfig("pkg-config '" + name + " >= 5.0' --cflags --libs") + env.Append(LIBLUA = env['LIBS'][len(oldlibs):]) + env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ]) + result = True + except: + pass + env['LIBS'] = oldlibs + return result + + found_lua = False + for lua_name in ['lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua']: + if TryLua(env, lua_name): + found_lua = True + break + if not found_lua: + raise RuntimeError("Couldn't find any lua implementation") if env['with_memcached']: if autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C', autoadd = 0): autoconf.env.Append(CPPFLAGS = [ '-DUSE_MEMCACHED' ], LIBMEMCACHED = 'memcached') - if env['with_gdbm']: - if autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ], LIBGDBM = 'gdbm') - - if env['with_sqlite3']: - if autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], LIBSQLITE3 = 'sqlite3') - - if env['with_geoip']: - if autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GEOIP' ], LIBGEOIP = 'GeoIP') - - if env['with_dbi']: - if autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C', autoadd = 0): - env.Append(CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], LIBDBI = 'dbi') + if env['with_mysql']: + mysql_config = checkProgram(env, 'mysql', 'mysql_config') + oldlib = env['LIBS'] + env['LIBS'] = [] + env.ParseConfig(mysql_config + ' --cflags --libs') + env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ], LIBMYSQL = 'mysqlclient') + env['LIBS'] = oldlib - if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C', autoadd = 0): - autoconf.env.Append(LIBFCGI = 'fcgi') + if env['with_openssl']: + if autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C', autoadd = 0): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'] , LIBSSL = 'ssl', LIBCRYPTO = 'crypto') - if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C', autoadd = 0): - autoconf.env.Append(LIBDL = 'dl') + if env['with_pcre']: + pcre_config = checkProgram(env, 'pcre', 'pcre-config') + oldlib = env['LIBS'] + env['LIBS'] = [] + env.ParseConfig(pcre_config + ' --cflags --libs') + env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ], LIBPCRE = env['LIBS']) + env['LIBS'] = oldlib - if autoconf.CheckType('socklen_t', '#include \n#include \n#include '): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ]) + if env['with_pgsql']: + oldlib = env['LIBS'] + env['LIBS'] = [] + env.ParseConfig('pkg-config libpq --cflags --libs') + env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ], LIBPGSQL = 'pq') + env['LIBS'] = oldlib - if autoconf.CheckType('struct sockaddr_storage', '#include \n'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ]) + if env['with_sqlite3']: + if autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C', autoadd = 0): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], LIBSQLITE3 = 'sqlite3') - if autoconf.CheckGmtOffInStructTm(): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ]) + if env['with_uuid']: + if autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C', autoadd = 0): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], LIBUUID = 'uuid') - if autoconf.CheckIPv6(): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_IPV6' ]) + if env['with_xml']: + xml2_config = checkProgram(env, 'xml', 'xml2-config') + oldlib = env['LIBS'] + env['LIBS'] = [] + env.ParseConfig(xml2_config + ' --cflags --libs') + env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ], LIBXML2 = env['LIBS']) + env['LIBS'] = oldlib - if autoconf.CheckWeakSymbols(): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_WEAK_SYMBOLS' ]) + if env['with_zlib']: + if autoconf.CheckLibWithHeader('z', 'zlib.h', 'C', autoadd = 0): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], LIBZ = 'z') env = autoconf.Finish() -def TryLua(env, name): - result = False - oldlibs = copy(env['LIBS']) - try: - print("Searching for lua: " + name + " >= 5.0") - env.ParseConfig("pkg-config '" + name + " >= 5.0' --cflags --libs") - env.Append(LIBLUA = env['LIBS'][len(oldlibs):]) - env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ]) - result = True - except: - pass - env['LIBS'] = oldlibs - return result - -if env['with_lua']: - found_lua = False - for lua_name in ['lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua']: - if TryLua(env, lua_name): - found_lua = True - break - if not found_lua: - raise RuntimeError("Couldn't find any lua implementation") - -if env['with_pcre']: - pcre_config = checkProgram(env, 'pcre', 'pcre-config') - oldlib = env['LIBS'] - env['LIBS'] = [] - env.ParseConfig(pcre_config + ' --cflags --libs') - env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ], LIBPCRE = env['LIBS']) - env['LIBS'] = oldlib - -if env['with_xml']: - xml2_config = checkProgram(env, 'xml', 'xml2-config') - oldlib = env['LIBS'] - env['LIBS'] = [] - env.ParseConfig(xml2_config + ' --cflags --libs') - env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ], LIBXML2 = env['LIBS']) - env['LIBS'] = oldlib - -if env['with_mysql']: - mysql_config = checkProgram(env, 'mysql', 'mysql_config') - oldlib = env['LIBS'] - env['LIBS'] = [] - env.ParseConfig(mysql_config + ' --cflags --libs') - env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ], LIBMYSQL = 'mysqlclient') - env['LIBS'] = oldlib - -if env['with_pgsql']: - oldlib = env['LIBS'] - env['LIBS'] = [] - env.ParseConfig('pkg-config libpq --cflags --libs') - env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ], LIBPGSQL = 'pq') - env['LIBS'] = oldlib - if re.compile("cygwin|mingw|midipix").search(env['PLATFORM']): env.Append(COMMON_LIB = 'bin') elif re.compile("darwin|aix").search(env['PLATFORM']): From 66e0cd16b2ff6ea60593bce06dffd4a476d4d234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 16:14:25 +0200 Subject: [PATCH 14/21] [scons] explicit fails when wanted features are missing --- SConstruct | 87 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/SConstruct b/SConstruct index afb58776..2204e86e 100644 --- a/SConstruct +++ b/SConstruct @@ -8,6 +8,10 @@ from stat import * package = 'lighttpd' version = '1.4.48' +def fail(*args, **kwargs): + print(*args, file=sys.stderr, **kwargs) + env.Exit(-1) + def checkCHeaders(autoconf, hdrs): p = re.compile('[^A-Z0-9]') for hdr in hdrs: @@ -94,15 +98,12 @@ def checkProgram(env, withname, progname): if binpath: mode = os.stat(binpath)[ST_MODE] if S_ISDIR(mode): - print >> sys.stderr, "* error: path `%s' is a directory" % (binpath) - env.Exit(-1) + fail("* error: path `%s' is a directory" % (binpath)) if not S_ISREG(mode): - print >> sys.stderr, "* error: path `%s' is not a file or not exists" % (binpath) - env.Exit(-1) + fail("* error: path `%s' is not a file or not exists" % (binpath)) if not binpath: - print >> sys.stderr, "* error: can't find program `%s'" % (progname) - env.Exit(-1) + fail("* error: can't find program `%s'" % (progname)) return binpath @@ -290,37 +291,46 @@ if 1: autoconf.env.Append(LIBFCGI = 'fcgi') if env['with_bzip2']: - if autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], LIBBZ2 = 'bz2') + if not autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C', autoadd = 0): + fail("Couldn't find bz2") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], LIBBZ2 = 'bz2') if env['with_dbi']: - if autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C', autoadd = 0): - env.Append(CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], LIBDBI = 'dbi') + if not autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C', autoadd = 0): + fail("Couldn't find dbi") + env.Append(CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], LIBDBI = 'dbi') if env['with_fam']: - if autoconf.CheckLibWithHeader('fam', 'fam.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], LIBS = [ 'fam' ]) - checkFuncs(autoconf, ['FAMNoExists']); + if not autoconf.CheckLibWithHeader('fam', 'fam.h', 'C', autoadd = 0): + fail("Couldn't find fam") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], LIBS = [ 'fam' ]) + checkFuncs(autoconf, ['FAMNoExists']); if env['with_gdbm']: - if autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ], LIBGDBM = 'gdbm') + if not autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C', autoadd = 0): + fail("Couldn't find gdbm") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ], LIBGDBM = 'gdbm') if env['with_geoip']: - if autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GEOIP' ], LIBGEOIP = 'GeoIP') + if not autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C', autoadd = 0): + fail("Couldn't find geoip") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GEOIP' ], LIBGEOIP = 'GeoIP') if env['with_krb5']: - if autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_KRB5' ], LIBKRB5 = 'krb5') - if autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C', autoadd = 0): - autoconf.env.Append(LIBGSSAPI_KRB5 = 'gssapi_krb5') + if not autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C', autoadd = 0): + fail("Couldn't find krb5") + if not autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C', autoadd = 0): + fail("Couldn't find gssapi_krb5") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_KRB5' ], LIBKRB5 = 'krb5') + autoconf.env.Append(LIBGSSAPI_KRB5 = 'gssapi_krb5') if env['with_ldap']: - if autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP' ], LIBLDAP = 'ldap') - if autoconf.CheckLibWithHeader('lber', 'lber.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LBER_H', '-DHAVE_LIBLBER' ], LIBLBER = 'lber') + if not autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C', autoadd = 0): + fail("Couldn't find ldap") + if not autoconf.CheckLibWithHeader('lber', 'lber.h', 'C', autoadd = 0): + fail("Couldn't find lber") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP' ], LIBLDAP = 'ldap') + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LBER_H', '-DHAVE_LIBLBER' ], LIBLBER = 'lber') if env['with_lua']: def TryLua(env, name): @@ -343,11 +353,12 @@ if 1: found_lua = True break if not found_lua: - raise RuntimeError("Couldn't find any lua implementation") + fail("Couldn't find any lua implementation") if env['with_memcached']: - if autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DUSE_MEMCACHED' ], LIBMEMCACHED = 'memcached') + if not autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C', autoadd = 0): + fail("Couldn't find memcached") + autoconf.env.Append(CPPFLAGS = [ '-DUSE_MEMCACHED' ], LIBMEMCACHED = 'memcached') if env['with_mysql']: mysql_config = checkProgram(env, 'mysql', 'mysql_config') @@ -358,8 +369,9 @@ if 1: env['LIBS'] = oldlib if env['with_openssl']: - if autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'] , LIBSSL = 'ssl', LIBCRYPTO = 'crypto') + if not autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C', autoadd = 0): + fail("Couldn't find openssl") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'] , LIBSSL = 'ssl', LIBCRYPTO = 'crypto') if env['with_pcre']: pcre_config = checkProgram(env, 'pcre', 'pcre-config') @@ -377,12 +389,14 @@ if 1: env['LIBS'] = oldlib if env['with_sqlite3']: - if autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], LIBSQLITE3 = 'sqlite3') + if not autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C', autoadd = 0): + fail("Couldn't find sqlite3") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], LIBSQLITE3 = 'sqlite3') if env['with_uuid']: - if autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], LIBUUID = 'uuid') + if not autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C', autoadd = 0): + fail("Couldn't find uuid") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], LIBUUID = 'uuid') if env['with_xml']: xml2_config = checkProgram(env, 'xml', 'xml2-config') @@ -393,8 +407,9 @@ if 1: env['LIBS'] = oldlib if env['with_zlib']: - if autoconf.CheckLibWithHeader('z', 'zlib.h', 'C', autoadd = 0): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], LIBZ = 'z') + if not autoconf.CheckLibWithHeader('z', 'zlib.h', 'C', autoadd = 0): + fail("Couldn't find zlib") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], LIBZ = 'z') env = autoconf.Finish() From f78749d3c64b7a97df4c2e436e0cb6fecda437d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 16:16:36 +0200 Subject: [PATCH 15/21] [scons] fix warnings with deprecated ldap api --- SConstruct | 1 + 1 file changed, 1 insertion(+) diff --git a/SConstruct b/SConstruct index 2204e86e..1f00eebd 100644 --- a/SConstruct +++ b/SConstruct @@ -329,6 +329,7 @@ if 1: fail("Couldn't find ldap") if not autoconf.CheckLibWithHeader('lber', 'lber.h', 'C', autoadd = 0): fail("Couldn't find lber") + autoconf.env.Append(CPPFLAGS = [ '-DLDAP_DEPRECATED=1' ]) autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP' ], LIBLDAP = 'ldap') autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LBER_H', '-DHAVE_LIBLBER' ], LIBLBER = 'lber') From 706910ac6aac6c1eba856daf4d367d4bc3d0d000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 16:30:33 +0200 Subject: [PATCH 16/21] [scons] add some generic defintions early Also add _GNU_SOURCE. --- SConstruct | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 1f00eebd..4c7732d3 100644 --- a/SConstruct +++ b/SConstruct @@ -163,6 +163,13 @@ if env['CC'] == 'gcc': ## we need x-open 6 and bsd 4.3 features env.Append(CCFLAGS = Split('-Wall -O2 -g -W -pedantic -Wunused -Wshadow -std=gnu99')) +env.Append(CPPFLAGS = [ + '-D_FILE_OFFSET_BITS=64', + '-D_LARGEFILE_SOURCE', + '-D_LARGE_FILES', + '-D_GNU_SOURCE', +]) + if env['with_all']: for feature in vars.keys(): # only enable 'with_*' flags @@ -428,7 +435,6 @@ env.Append(CPPFLAGS = [ '-DPACKAGE_NAME=\\"' + package + '\\"', '-DPACKAGE_VERSION=\\"' + version + '\\"', '-DLIBRARY_DIR="\\"${libdir}\\""', - '-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', '-D_LARGE_FILES' ] ) SConscript('src/SConscript', exports = 'env', variant_dir = 'sconsbuild/build', duplicate = 0) From 42704e312e4792e4da663af9aab01930dd33a96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 20:23:11 +0200 Subject: [PATCH 17/21] [scons] wrap Configure in local Autoconf class --- SConstruct | 439 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 263 insertions(+), 176 deletions(-) diff --git a/SConstruct b/SConstruct index 4c7732d3..006a4995 100644 --- a/SConstruct +++ b/SConstruct @@ -8,38 +8,131 @@ from stat import * package = 'lighttpd' version = '1.4.48' +underscorify_reg = re.compile('[^A-Z0-9]') +def underscorify(id): + return underscorify_reg.sub('_', id.upper()) + def fail(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) env.Exit(-1) -def checkCHeaders(autoconf, hdrs): - p = re.compile('[^A-Z0-9]') - for hdr in hdrs: - if not hdr: - continue - _hdr = Split(hdr) - if autoconf.CheckCHeader(_hdr): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_' + p.sub('_', _hdr[-1].upper()) ]) - -def checkFunc(autoconf, func, header): - p = re.compile('[^A-Z0-9]') - if autoconf.CheckFunc(func, header): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_' + p.sub('_', func.upper()) ]) - -def checkFuncs(autoconf, funcs): - p = re.compile('[^A-Z0-9]') - for func in funcs: - if autoconf.CheckFunc(func): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_' + p.sub('_', func.upper()) ]) - -def checkTypes(autoconf, types): - p = re.compile('[^A-Z0-9]') - for type in types: - if autoconf.CheckType(type, '#include '): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_' + p.sub('_', type.upper()) ]) - -def checkGmtOffInStructTm(context): - source = """ +class Autoconf: + class RestoreEnvLibs: + def __init__(self, env): + self.env = env + self.active = False + + def __enter__(self): + if self.active: + raise Exception('entered twice') + self.active = True + if 'LIBS' in self.env: + #print("Backup LIBS: " + repr(self.env['LIBS'])) + self.empty = False + self.backup_libs = copy(self.env['LIBS']) + else: + #print("No LIBS to backup") + self.empty = True + + def __exit__(self, type, value, traceback): + if not self.active: + raise Exception('exited twice') + self.active = False + if self.empty: + if 'LIBS' in self.env: + del self.env['LIBS'] + else: + #print("Restoring LIBS, now: " + repr(self.env['LIBS'])) + self.env['LIBS'] = self.backup_libs + #print("Restoring LIBS, to: " + repr(self.env['LIBS'])) + + def __init__(self, env): + self.conf = Configure(env, custom_tests = { + 'CheckGmtOffInStructTm': Autoconf.__checkGmtOffInStructTm, + 'CheckIPv6': Autoconf.__checkIPv6, + 'CheckWeakSymbols': Autoconf.__checkWeakSymbols, + }) + + def append(self, *args, **kw): + return self.conf.env.Append(*args, **kw) + + def Finish(self): + return self.conf.Finish() + + @property + def env(self): + return self.conf.env + + def restoreEnvLibs(self): + return Autoconf.RestoreEnvLibs(self.conf.env) + + def CheckType(self, *args, **kw): + return self.conf.CheckType(*args, **kw) + + def CheckLib(self, *args, **kw): + return self.conf.CheckLib(*args, autoadd = 0, **kw) + + def CheckLibWithHeader(self, *args, **kw): + return self.conf.CheckLibWithHeader(*args, autoadd = 0, **kw) + + def CheckGmtOffInStructTm(self): + return self.conf.CheckGmtOffInStructTm() + + def CheckIPv6(self): + return self.conf.CheckIPv6() + + def CheckWeakSymbols(self): + return self.conf.CheckWeakSymbols() + + def CheckCHeader(self, hdr): + return self.conf.CheckCHeader(hdr) + + def haveCHeader(self, hdr): + if self.CheckCHeader(hdr): + # if we have a list of headers define HAVE_ only for last one + target = hdr + if not isinstance(target, basestring): + target = target[-1] + self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(target) ]) + return True + return False + + def haveCHeaders(self, hdrs): + for hdr in hdrs: + self.haveCHeader(hdr) + + def CheckFunc(self, func, header = None, libs = []): + with self.restoreEnvLibs(): + self.env.Append(LIBS = libs) + return self.conf.CheckFunc(func, header = header) + + def CheckFuncInLib(self, func, lib): + return self.CheckFunc(func, libs = [lib]) + + def haveFuncInLib(self, func, lib): + if self.CheckFuncInLib(func, lib): + self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(func) ]) + return True + return False + + def haveFunc(self, func, header = None, libs = []): + if self.CheckFunc(func, header = header, libs = libs): + self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(func) ]) + return True + return False + + def haveFuncs(self, funcs): + for func in funcs: + self.haveFunc(func) + + def haveTypes(self, types): + for type in types: + if self.conf.CheckType(type, '#include '): + self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(type) ]) + + @staticmethod + def __checkGmtOffInStructTm(context): + source = """ #include int main() { struct tm a; @@ -47,14 +140,15 @@ int main() { return 0; } """ - context.Message('Checking for tm_gmtoff in struct tm...') - result = context.TryLink(source, '.c') - context.Result(result) + context.Message('Checking for tm_gmtoff in struct tm...') + result = context.TryLink(source, '.c') + context.Result(result) - return result + return result -def checkIPv6(context): - source = """ + @staticmethod + def __checkIPv6(context): + source = """ #include #include #include @@ -64,48 +158,49 @@ int main() { return 0; } """ - context.Message('Checking for IPv6 support...') - result = context.TryLink(source, '.c') - context.Result(result) + context.Message('Checking for IPv6 support...') + result = context.TryLink(source, '.c') + context.Result(result) - return result + return result -def checkWeakSymbols(context): - source = """ + @staticmethod + def __checkWeakSymbols(context): + source = """ __attribute__((weak)) void __dummy(void *x) { } int main() { void *x; __dummy(x); } """ - context.Message('Checking for weak symbol support...') - result = context.TryLink(source, '.c') - context.Result(result) + context.Message('Checking for weak symbol support...') + result = context.TryLink(source, '.c') + context.Result(result) - return result + return result -def checkProgram(env, withname, progname): - withname = 'with_' + withname - binpath = None + def checkProgram(self, withname, progname): + withname = 'with_' + withname + binpath = None - if env[withname] != 1: - binpath = env[withname] - else: - prog = env.Detect(progname) - if prog: - binpath = env.WhereIs(prog) + if self.env[withname] != 1: + binpath = self.env[withname] + else: + prog = self.env.Detect(progname) + if prog: + binpath = self.env.WhereIs(prog) - if binpath: - mode = os.stat(binpath)[ST_MODE] - if S_ISDIR(mode): - fail("* error: path `%s' is a directory" % (binpath)) - if not S_ISREG(mode): - fail("* error: path `%s' is not a file or not exists" % (binpath)) + if binpath: + mode = os.stat(binpath)[ST_MODE] + if S_ISDIR(mode): + fail("* error: path `%s' is a directory" % (binpath)) + if not S_ISREG(mode): + fail("* error: path `%s' is not a file or not exists" % (binpath)) - if not binpath: - fail("* error: can't find program `%s'" % (progname)) + if not binpath: + fail("* error: can't find program `%s'" % (progname)) - return binpath + return binpath VariantDir('sconsbuild/build', 'src', duplicate = 0) VariantDir('sconsbuild/tests', 'tests', duplicate = 0) @@ -181,11 +276,7 @@ if env['with_all']: # cache configure checks if 1: - autoconf = Configure(env, custom_tests = { - 'CheckGmtOffInStructTm': checkGmtOffInStructTm, - 'CheckIPv6': checkIPv6, - 'CheckWeakSymbols': checkWeakSymbols, - }) + autoconf = Autoconf(env) if 'CFLAGS' in os.environ: autoconf.env.Append(CCFLAGS = os.environ['CFLAGS']) @@ -201,60 +292,62 @@ if 1: else: autoconf.env.Append(APPEND_LIBS = '') - autoconf.headerfile = "foo.h" - checkCHeaders(autoconf, string.split(""" - arpa/inet.h - crypt.h - fcntl.h - getopt.h - inttypes.h - linux/random.h - netinet/in.h - poll.h - pwd.h - stdint.h - stdlib.h - string.h - strings.h - sys/devpoll.h - sys/epoll.h - sys/event.h - sys/filio.h - sys/mman.h - sys/poll.h - sys/port.h - sys/prctl.h - sys/resource.h - sys/select.h - sys/sendfile.h - sys/socket.h - sys/time.h - sys/time.h sys/types.h sys/resource.h - sys/types.h netinet/in.h - sys/types.h sys/event.h - sys/types.h sys/mman.h - sys/types.h sys/select.h - sys/types.h sys/socket.h - sys/types.h sys/uio.h - sys/types.h sys/un.h - sys/uio.h - sys/un.h - sys/wait.h - syslog.h - unistd.h - winsock2.h""", "\n")) - - checkFuncs(autoconf, Split('fork stat lstat strftime dup2 getcwd inet_ntoa inet_ntop memset mmap munmap strchr \ + autoconf.haveCHeaders([ + 'arpa/inet.h', + 'crypt.h', + 'fcntl.h', + 'getopt.h', + 'inttypes.h', + 'linux/random.h', + 'netinet/in.h', + 'poll.h', + 'pwd.h', + 'stdint.h', + 'stdlib.h', + 'string.h', + 'strings.h', + 'sys/devpoll.h', + 'sys/epoll.h', + 'sys/event.h', + 'sys/filio.h', + 'sys/mman.h', + 'sys/poll.h', + 'sys/port.h', + 'sys/prctl.h', + 'sys/resource.h', + 'sys/select.h', + 'sys/sendfile.h', + 'sys/socket.h', + 'sys/time.h', + 'sys/uio.h', + 'sys/un.h', + 'sys/wait.h', + 'syslog.h', + 'unistd.h', + 'winsock2.h', + + # "have" the last header if we include others before? + ['sys/time.h', 'sys/types.h', 'sys/resource.h'], + ['sys/types.h', 'netinet/in.h'], + ['sys/types.h', 'sys/event.h'], + ['sys/types.h', 'sys/mman.h'], + ['sys/types.h', 'sys/select.h'], + ['sys/types.h', 'sys/socket.h'], + ['sys/types.h', 'sys/uio.h'], + ['sys/types.h', 'sys/un.h'], + ]) + + autoconf.haveFuncs(Split('fork stat lstat strftime dup2 getcwd inet_ntoa inet_ntop memset mmap munmap strchr \ strdup strerror strstr strtol sendfile getopt socket \ gethostbyname poll epoll_ctl getrlimit chroot \ getuid select signal pathconf madvise prctl\ writev sigaction sendfile64 send_file kqueue port_create localtime_r posix_fadvise issetugid inet_pton \ memset_s explicit_bzero clock_gettime pipe2 \ arc4random_buf jrand48 srandom getloadavg')) - checkFunc(autoconf, 'getentropy', 'sys/random.h') - checkFunc(autoconf, 'getrandom', 'linux/random.h') + autoconf.haveFunc('getentropy', 'sys/random.h') + autoconf.haveFunc('getrandom', 'linux/random.h') - checkTypes(autoconf, Split('pid_t size_t off_t')) + autoconf.haveTypes(Split('pid_t size_t off_t')) autoconf.env.Append( LIBSQLITE3 = '', LIBXML2 = '', LIBMYSQL = '', LIBZ = '', LIBPGSQL = '', LIBDBI = '', @@ -263,14 +356,13 @@ if 1: LIBKRB5 = '', LIBGSSAPI_KRB5 = '', LIBGDBM = '', LIBSSL = '', LIBCRYPTO = '') # have crypt_r/crypt, and is -lcrypt needed? - if autoconf.CheckLib('crypt', autoadd = 0): + if autoconf.CheckLib('crypt'): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBCRYPT' ], LIBCRYPT = 'crypt') - oldlib = env['LIBS'] - env['LIBS'] = ['crypt'] - checkFuncs(autoconf, ['crypt', 'crypt_r']) - env['LIBS'] = oldlib + with autoconf.restoreEnvLibs(): + autoconf.env['LIBS'] = ['crypt'] + autoconf.haveFuncs(['crypt', 'crypt_r']) else: - checkFuncs(autoconf, ['crypt', 'crypt_r']) + autoconf.haveFuncs(['crypt', 'crypt_r']) if autoconf.CheckType('socklen_t', '#include \n#include \n#include '): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SOCKLEN_T' ]) @@ -278,7 +370,7 @@ if 1: if autoconf.CheckType('struct sockaddr_storage', '#include \n'): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ]) - if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);', autoadd = 0): + if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);'): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ], LIBS = [ 'rt' ]) if autoconf.CheckIPv6(): @@ -290,132 +382,127 @@ if 1: if autoconf.CheckGmtOffInStructTm(): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_TM_GMTOFF' ]) - if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C', autoadd = 0): + if autoconf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'): autoconf.env.Append(LIBDL = 'dl') # used in tests if present - if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C', autoadd = 0): + if autoconf.CheckLibWithHeader('fcgi', 'fastcgi.h', 'C'): autoconf.env.Append(LIBFCGI = 'fcgi') if env['with_bzip2']: - if not autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'): fail("Couldn't find bz2") autoconf.env.Append(CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], LIBBZ2 = 'bz2') if env['with_dbi']: - if not autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C'): fail("Couldn't find dbi") - env.Append(CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], LIBDBI = 'dbi') + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], LIBDBI = 'dbi') if env['with_fam']: - if not autoconf.CheckLibWithHeader('fam', 'fam.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'): fail("Couldn't find fam") autoconf.env.Append(CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], LIBS = [ 'fam' ]) - checkFuncs(autoconf, ['FAMNoExists']); + autoconf.haveFunc('FAMNoExists') if env['with_gdbm']: - if not autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C'): fail("Couldn't find gdbm") autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ], LIBGDBM = 'gdbm') if env['with_geoip']: - if not autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C'): fail("Couldn't find geoip") autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GEOIP' ], LIBGEOIP = 'GeoIP') if env['with_krb5']: - if not autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C'): fail("Couldn't find krb5") - if not autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C'): fail("Couldn't find gssapi_krb5") autoconf.env.Append(CPPFLAGS = [ '-DHAVE_KRB5' ], LIBKRB5 = 'krb5') autoconf.env.Append(LIBGSSAPI_KRB5 = 'gssapi_krb5') if env['with_ldap']: - if not autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C'): fail("Couldn't find ldap") - if not autoconf.CheckLibWithHeader('lber', 'lber.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('lber', 'lber.h', 'C'): fail("Couldn't find lber") autoconf.env.Append(CPPFLAGS = [ '-DLDAP_DEPRECATED=1' ]) autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP' ], LIBLDAP = 'ldap') autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LBER_H', '-DHAVE_LIBLBER' ], LIBLBER = 'lber') if env['with_lua']: - def TryLua(env, name): - result = False - oldlibs = copy(env['LIBS']) - try: - print("Searching for lua: " + name + " >= 5.0") - env.ParseConfig("pkg-config '" + name + " >= 5.0' --cflags --libs") - env.Append(LIBLUA = env['LIBS'][len(oldlibs):]) - env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ]) - result = True - except: - pass - env['LIBS'] = oldlibs - return result + def TryLua(autoconf, name): + with autoconf.restoreEnvLibs(): + autoconf.env['LIBS'] = [] + try: + print("Searching for lua: " + name + " >= 5.0") + autoconf.env.ParseConfig("pkg-config '" + name + " >= 5.0' --cflags --libs") + except Exception as e: + print("Failed: ", e, file = sys.stderr) + return False + autoconf.env.Append(LIBLUA = autoconf.env['LIBS']) + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ]) + return True found_lua = False for lua_name in ['lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua']: - if TryLua(env, lua_name): + if TryLua(autoconf, lua_name): found_lua = True break if not found_lua: fail("Couldn't find any lua implementation") if env['with_memcached']: - if not autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C'): fail("Couldn't find memcached") autoconf.env.Append(CPPFLAGS = [ '-DUSE_MEMCACHED' ], LIBMEMCACHED = 'memcached') if env['with_mysql']: - mysql_config = checkProgram(env, 'mysql', 'mysql_config') - oldlib = env['LIBS'] - env['LIBS'] = [] - env.ParseConfig(mysql_config + ' --cflags --libs') - env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ], LIBMYSQL = 'mysqlclient') - env['LIBS'] = oldlib + mysql_config = autoconf.checkProgram('mysql', 'mysql_config') + with autoconf.restoreEnvLibs(): + autoconf.env['LIBS'] = [] + autoconf.env.ParseConfig(mysql_config + ' --cflags --libs') + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ], LIBMYSQL = 'mysqlclient') if env['with_openssl']: - if not autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'): fail("Couldn't find openssl") autoconf.env.Append(CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'] , LIBSSL = 'ssl', LIBCRYPTO = 'crypto') if env['with_pcre']: - pcre_config = checkProgram(env, 'pcre', 'pcre-config') - oldlib = env['LIBS'] - env['LIBS'] = [] - env.ParseConfig(pcre_config + ' --cflags --libs') - env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ], LIBPCRE = env['LIBS']) - env['LIBS'] = oldlib + pcre_config = autoconf.checkProgram('pcre', 'pcre-config') + with autoconf.restoreEnvLibs(): + autoconf.env['LIBS'] = [] + autoconf.env.ParseConfig(pcre_config + ' --cflags --libs') + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ], LIBPCRE = autoconf.env['LIBS']) if env['with_pgsql']: - oldlib = env['LIBS'] - env['LIBS'] = [] - env.ParseConfig('pkg-config libpq --cflags --libs') - env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ], LIBPGSQL = 'pq') - env['LIBS'] = oldlib + with autoconf.restoreEnvLibs(): + autoconf.env['LIBS'] = [] + autoconf.env.ParseConfig('pkg-config libpq --cflags --libs') + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ], LIBPGSQL = 'pq') if env['with_sqlite3']: - if not autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'): fail("Couldn't find sqlite3") autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], LIBSQLITE3 = 'sqlite3') if env['with_uuid']: - if not autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C'): fail("Couldn't find uuid") autoconf.env.Append(CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], LIBUUID = 'uuid') if env['with_xml']: - xml2_config = checkProgram(env, 'xml', 'xml2-config') - oldlib = env['LIBS'] - env['LIBS'] = [] - env.ParseConfig(xml2_config + ' --cflags --libs') - env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ], LIBXML2 = env['LIBS']) - env['LIBS'] = oldlib + xml2_config = autoconf.checkProgram('xml', 'xml2-config') + with autoconf.restoreEnvLibs(): + autoconf.env['LIBS'] = [] + autoconf.env.ParseConfig(xml2_config + ' --cflags --libs') + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ], LIBXML2 = autoconf.env['LIBS']) if env['with_zlib']: - if not autoconf.CheckLibWithHeader('z', 'zlib.h', 'C', autoadd = 0): + if not autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'): fail("Couldn't find zlib") autoconf.env.Append(CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], LIBZ = 'z') From 7733376b5a7e07511d81b759e8a87759576a211f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 20:45:28 +0200 Subject: [PATCH 18/21] [scons] split function names, break some lines --- SConstruct | 85 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 12 deletions(-) diff --git a/SConstruct b/SConstruct index 006a4995..20552179 100644 --- a/SConstruct +++ b/SConstruct @@ -337,23 +337,84 @@ if 1: ['sys/types.h', 'sys/un.h'], ]) - autoconf.haveFuncs(Split('fork stat lstat strftime dup2 getcwd inet_ntoa inet_ntop memset mmap munmap strchr \ - strdup strerror strstr strtol sendfile getopt socket \ - gethostbyname poll epoll_ctl getrlimit chroot \ - getuid select signal pathconf madvise prctl\ - writev sigaction sendfile64 send_file kqueue port_create localtime_r posix_fadvise issetugid inet_pton \ - memset_s explicit_bzero clock_gettime pipe2 \ - arc4random_buf jrand48 srandom getloadavg')) + autoconf.haveFuncs([ + 'arc4random_buf', + 'chroot', + 'clock_gettime', + 'dup2', + 'epoll_ctl', + 'explicit_bzero', + 'fork', + 'getcwd', + 'gethostbyname', + 'getloadavg', + 'getopt', + 'getrlimit', + 'getuid', + 'inet_ntoa', + 'inet_ntop', + 'inet_pton', + 'issetugid', + 'jrand48', + 'kqueue', + 'localtime_r', + 'lstat', + 'madvise', + 'memset_s', + 'memset', + 'mmap', + 'munmap', + 'pathconf', + 'pipe2', + 'poll', + 'port_create', + 'posix_fadvise', + 'prctl', + 'select', + 'send_file', + 'sendfile', + 'sendfile64', + 'sigaction', + 'signal', + 'socket', + 'srandom', + 'stat', + 'strchr', + 'strdup', + 'strerror', + 'strftime', + 'strstr', + 'strtol', + 'writev', + ]) autoconf.haveFunc('getentropy', 'sys/random.h') autoconf.haveFunc('getrandom', 'linux/random.h') autoconf.haveTypes(Split('pid_t size_t off_t')) - autoconf.env.Append( LIBSQLITE3 = '', LIBXML2 = '', LIBMYSQL = '', LIBZ = '', - LIBPGSQL = '', LIBDBI = '', - LIBBZ2 = '', LIBCRYPT = '', LIBMEMCACHED = '', LIBFCGI = '', LIBPCRE = '', - LIBLDAP = '', LIBLBER = '', LIBLUA = '', LIBDL = '', LIBUUID = '', - LIBKRB5 = '', LIBGSSAPI_KRB5 = '', LIBGDBM = '', LIBSSL = '', LIBCRYPTO = '') + autoconf.env.Append( + LIBBZ2 = '', + LIBCRYPT = '', + LIBCRYPTO = '', + LIBDBI = '', + LIBDL = '', + LIBFCGI = '', + LIBGDBM = '', + LIBGSSAPI_KRB5 = '', + LIBKRB5 = '', + LIBLBER = '', + LIBLDAP = '', + LIBLUA = '', + LIBMEMCACHED = '', + LIBMYSQL = '', + LIBPCRE = '', + LIBPGSQL = '', + LIBSQLITE3 = '', + LIBSSL = '', + LIBUUID = '', + LIBXML2 = '', + LIBZ = '', + ) # have crypt_r/crypt, and is -lcrypt needed? if autoconf.CheckLib('crypt'): From d57029c075e897c1477c0fb3ce13ef68ca1d2fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Tue, 24 Oct 2017 20:51:47 +0200 Subject: [PATCH 19/21] [scons] move LIB* initializing block --- SConstruct | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/SConstruct b/SConstruct index 20552179..3b6b9241 100644 --- a/SConstruct +++ b/SConstruct @@ -292,6 +292,30 @@ if 1: else: autoconf.env.Append(APPEND_LIBS = '') + autoconf.env.Append( + LIBBZ2 = '', + LIBCRYPT = '', + LIBCRYPTO = '', + LIBDBI = '', + LIBDL = '', + LIBFCGI = '', + LIBGDBM = '', + LIBGSSAPI_KRB5 = '', + LIBKRB5 = '', + LIBLBER = '', + LIBLDAP = '', + LIBLUA = '', + LIBMEMCACHED = '', + LIBMYSQL = '', + LIBPCRE = '', + LIBPGSQL = '', + LIBSQLITE3 = '', + LIBSSL = '', + LIBUUID = '', + LIBXML2 = '', + LIBZ = '', + ) + autoconf.haveCHeaders([ 'arpa/inet.h', 'crypt.h', @@ -392,30 +416,6 @@ if 1: autoconf.haveTypes(Split('pid_t size_t off_t')) - autoconf.env.Append( - LIBBZ2 = '', - LIBCRYPT = '', - LIBCRYPTO = '', - LIBDBI = '', - LIBDL = '', - LIBFCGI = '', - LIBGDBM = '', - LIBGSSAPI_KRB5 = '', - LIBKRB5 = '', - LIBLBER = '', - LIBLDAP = '', - LIBLUA = '', - LIBMEMCACHED = '', - LIBMYSQL = '', - LIBPCRE = '', - LIBPGSQL = '', - LIBSQLITE3 = '', - LIBSSL = '', - LIBUUID = '', - LIBXML2 = '', - LIBZ = '', - ) - # have crypt_r/crypt, and is -lcrypt needed? if autoconf.CheckLib('crypt'): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBCRYPT' ], LIBCRYPT = 'crypt') From 2e797996810b71a34105f2cb8602624f830e236d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Wed, 25 Oct 2017 14:33:51 +0200 Subject: [PATCH 20/21] [scons] break some lines in Append(...) calls --- SConstruct | 106 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 83 insertions(+), 23 deletions(-) diff --git a/SConstruct b/SConstruct index 3b6b9241..927af1e2 100644 --- a/SConstruct +++ b/SConstruct @@ -418,7 +418,10 @@ if 1: # have crypt_r/crypt, and is -lcrypt needed? if autoconf.CheckLib('crypt'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBCRYPT' ], LIBCRYPT = 'crypt') + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_LIBCRYPT' ], + LIBCRYPT = 'crypt', + ) with autoconf.restoreEnvLibs(): autoconf.env['LIBS'] = ['crypt'] autoconf.haveFuncs(['crypt', 'crypt_r']) @@ -432,7 +435,10 @@ if 1: autoconf.env.Append(CPPFLAGS = [ '-DHAVE_STRUCT_SOCKADDR_STORAGE' ]) if autoconf.CheckLibWithHeader('rt', 'time.h', 'c', 'clock_gettime(CLOCK_MONOTONIC, (struct timespec*)0);'): - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ], LIBS = [ 'rt' ]) + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_CLOCK_GETTIME' ], + LIBS = [ 'rt' ], + ) if autoconf.CheckIPv6(): autoconf.env.Append(CPPFLAGS = [ '-DHAVE_IPV6' ]) @@ -453,45 +459,69 @@ if 1: if env['with_bzip2']: if not autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'): fail("Couldn't find bz2") - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], LIBBZ2 = 'bz2') + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], + LIBBZ2 = 'bz2', + ) if env['with_dbi']: if not autoconf.CheckLibWithHeader('dbi', 'dbi/dbi.h', 'C'): fail("Couldn't find dbi") - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], LIBDBI = 'dbi') + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_DBI_H', '-DHAVE_LIBDBI' ], + LIBDBI = 'dbi', + ) if env['with_fam']: if not autoconf.CheckLibWithHeader('fam', 'fam.h', 'C'): fail("Couldn't find fam") - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], LIBS = [ 'fam' ]) + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_FAM_H', '-DHAVE_LIBFAM' ], + LIBS = [ 'fam' ], + ) autoconf.haveFunc('FAMNoExists') if env['with_gdbm']: if not autoconf.CheckLibWithHeader('gdbm', 'gdbm.h', 'C'): fail("Couldn't find gdbm") - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ], LIBGDBM = 'gdbm') + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_GDBM_H', '-DHAVE_GDBM' ], + LIBGDBM = 'gdbm', + ) if env['with_geoip']: if not autoconf.CheckLibWithHeader('GeoIP', 'GeoIP.h', 'C'): fail("Couldn't find geoip") - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_GEOIP' ], LIBGEOIP = 'GeoIP') + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_GEOIP' ], + LIBGEOIP = 'GeoIP', + ) if env['with_krb5']: if not autoconf.CheckLibWithHeader('krb5', 'krb5.h', 'C'): fail("Couldn't find krb5") if not autoconf.CheckLibWithHeader('gssapi_krb5', 'gssapi/gssapi_krb5.h', 'C'): fail("Couldn't find gssapi_krb5") - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_KRB5' ], LIBKRB5 = 'krb5') - autoconf.env.Append(LIBGSSAPI_KRB5 = 'gssapi_krb5') + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_KRB5' ], + LIBKRB5 = 'krb5', + LIBGSSAPI_KRB5 = 'gssapi_krb5', + ) if env['with_ldap']: if not autoconf.CheckLibWithHeader('ldap', 'ldap.h', 'C'): fail("Couldn't find ldap") if not autoconf.CheckLibWithHeader('lber', 'lber.h', 'C'): fail("Couldn't find lber") - autoconf.env.Append(CPPFLAGS = [ '-DLDAP_DEPRECATED=1' ]) - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP' ], LIBLDAP = 'ldap') - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LBER_H', '-DHAVE_LIBLBER' ], LIBLBER = 'lber') + autoconf.env.Append( + CPPFLAGS = [ + '-DLDAP_DEPRECATED=1', + '-DHAVE_LDAP_H', '-DHAVE_LIBLDAP', + '-DHAVE_LBER_H', '-DHAVE_LIBLBER', + ], + LIBLDAP = 'ldap', + LIBLBER = 'lber', + ) if env['with_lua']: def TryLua(autoconf, name): @@ -503,8 +533,10 @@ if 1: except Exception as e: print("Failed: ", e, file = sys.stderr) return False - autoconf.env.Append(LIBLUA = autoconf.env['LIBS']) - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ]) + autoconf.env.Append( + LIBLUA = autoconf.env['LIBS'], + CPPFLAGS = [ '-DHAVE_LUA_H' ], + ) return True found_lua = False @@ -518,54 +550,82 @@ if 1: if env['with_memcached']: if not autoconf.CheckLibWithHeader('memcached', 'libmemcached/memcached.h', 'C'): fail("Couldn't find memcached") - autoconf.env.Append(CPPFLAGS = [ '-DUSE_MEMCACHED' ], LIBMEMCACHED = 'memcached') + autoconf.env.Append( + CPPFLAGS = [ '-DUSE_MEMCACHED' ], + LIBMEMCACHED = 'memcached', + ) if env['with_mysql']: mysql_config = autoconf.checkProgram('mysql', 'mysql_config') with autoconf.restoreEnvLibs(): autoconf.env['LIBS'] = [] autoconf.env.ParseConfig(mysql_config + ' --cflags --libs') - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ], LIBMYSQL = 'mysqlclient') + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ], + LIBMYSQL = 'mysqlclient', + ) if env['with_openssl']: if not autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'): fail("Couldn't find openssl") - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'] , LIBSSL = 'ssl', LIBCRYPTO = 'crypto') + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'], + LIBSSL = 'ssl', + LIBCRYPTO = 'crypto', + ) if env['with_pcre']: pcre_config = autoconf.checkProgram('pcre', 'pcre-config') with autoconf.restoreEnvLibs(): autoconf.env['LIBS'] = [] autoconf.env.ParseConfig(pcre_config + ' --cflags --libs') - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ], LIBPCRE = autoconf.env['LIBS']) + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ], + LIBPCRE = autoconf.env['LIBS'], + ) if env['with_pgsql']: with autoconf.restoreEnvLibs(): autoconf.env['LIBS'] = [] autoconf.env.ParseConfig('pkg-config libpq --cflags --libs') - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ], LIBPGSQL = 'pq') + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ], + LIBPGSQL = 'pq', + ) if env['with_sqlite3']: if not autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'): fail("Couldn't find sqlite3") - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], LIBSQLITE3 = 'sqlite3') + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], + LIBSQLITE3 = 'sqlite3', + ) if env['with_uuid']: if not autoconf.CheckLibWithHeader('uuid', 'uuid/uuid.h', 'C'): fail("Couldn't find uuid") - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], LIBUUID = 'uuid') + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_UUID_UUID_H', '-DHAVE_LIBUUID' ], + LIBUUID = 'uuid', + ) if env['with_xml']: xml2_config = autoconf.checkProgram('xml', 'xml2-config') with autoconf.restoreEnvLibs(): autoconf.env['LIBS'] = [] autoconf.env.ParseConfig(xml2_config + ' --cflags --libs') - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ], LIBXML2 = autoconf.env['LIBS']) + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ], + LIBXML2 = autoconf.env['LIBS'], + ) if env['with_zlib']: if not autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'): fail("Couldn't find zlib") - autoconf.env.Append(CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], LIBZ = 'z') + autoconf.env.Append( + CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], + LIBZ = 'z', + ) env = autoconf.Finish() From 3ba68b25d4a5033d10efbb576db2326df970995d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Wed, 25 Oct 2017 14:48:01 +0200 Subject: [PATCH 21/21] [scons] parse config programs output in a generic way --- SConstruct | 75 ++++++++++++++++++++++-------------------------------- 1 file changed, 31 insertions(+), 44 deletions(-) diff --git a/SConstruct b/SConstruct index 927af1e2..dfb2e496 100644 --- a/SConstruct +++ b/SConstruct @@ -130,6 +130,22 @@ class Autoconf: if self.conf.CheckType(type, '#include '): self.conf.env.Append(CPPFLAGS = [ '-DHAVE_' + underscorify(type) ]) + def CheckParseConfig(self, *args, **kw): + try: + self.conf.env.ParseConfig(*args, **kw) + return True + except Exception as e: + print(e.message, file=sys.stderr) + return False + + def CheckParseConfigForLib(self, lib, *args, **kw): + with self.restoreEnvLibs(): + self.env['LIBS'] = [] + if not self.CheckParseConfig(*args, **kw): + return False + self.env.Append(**{lib: self.env['LIBS']}) + return True + @staticmethod def __checkGmtOffInStructTm(context): source = """ @@ -524,24 +540,11 @@ if 1: ) if env['with_lua']: - def TryLua(autoconf, name): - with autoconf.restoreEnvLibs(): - autoconf.env['LIBS'] = [] - try: - print("Searching for lua: " + name + " >= 5.0") - autoconf.env.ParseConfig("pkg-config '" + name + " >= 5.0' --cflags --libs") - except Exception as e: - print("Failed: ", e, file = sys.stderr) - return False - autoconf.env.Append( - LIBLUA = autoconf.env['LIBS'], - CPPFLAGS = [ '-DHAVE_LUA_H' ], - ) - return True - found_lua = False for lua_name in ['lua5.3', 'lua-5.3', 'lua5.2', 'lua-5.2', 'lua5.1', 'lua-5.1', 'lua']: - if TryLua(autoconf, lua_name): + print("Searching for lua: " + lua_name + " >= 5.0") + if autoconf.CheckParseConfigForLib('LIBLUA', "pkg-config '" + lua_name + " >= 5.0' --cflags --libs"): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LUA_H' ]) found_lua = True break if not found_lua: @@ -557,13 +560,9 @@ if 1: if env['with_mysql']: mysql_config = autoconf.checkProgram('mysql', 'mysql_config') - with autoconf.restoreEnvLibs(): - autoconf.env['LIBS'] = [] - autoconf.env.ParseConfig(mysql_config + ' --cflags --libs') - autoconf.env.Append( - CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ], - LIBMYSQL = 'mysqlclient', - ) + if not autoconf.CheckParseConfigForLib('LIBMYSQL', mysql_config + ' --cflags --libs'): + fail("Couldn't find mysql") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MYSQL_H', '-DHAVE_LIBMYSQL' ]) if env['with_openssl']: if not autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'): @@ -576,22 +575,14 @@ if 1: if env['with_pcre']: pcre_config = autoconf.checkProgram('pcre', 'pcre-config') - with autoconf.restoreEnvLibs(): - autoconf.env['LIBS'] = [] - autoconf.env.ParseConfig(pcre_config + ' --cflags --libs') - autoconf.env.Append( - CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ], - LIBPCRE = autoconf.env['LIBS'], - ) + if not autoconf.CheckParseConfigForLib('LIBPCRE', pcre_config + ' --cflags --libs'): + fail("Couldn't find pcre") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ]) if env['with_pgsql']: - with autoconf.restoreEnvLibs(): - autoconf.env['LIBS'] = [] - autoconf.env.ParseConfig('pkg-config libpq --cflags --libs') - autoconf.env.Append( - CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ], - LIBPGSQL = 'pq', - ) + if not autoconf.CheckParseConfigForLib('LIBPGSQL', 'pkg-config libpq --cflags --libs'): + fail("Couldn't find libpq") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_PGSQL_H', '-DHAVE_LIBPGSQL' ]) if env['with_sqlite3']: if not autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'): @@ -611,13 +602,9 @@ if 1: if env['with_xml']: xml2_config = autoconf.checkProgram('xml', 'xml2-config') - with autoconf.restoreEnvLibs(): - autoconf.env['LIBS'] = [] - autoconf.env.ParseConfig(xml2_config + ' --cflags --libs') - autoconf.env.Append( - CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ], - LIBXML2 = autoconf.env['LIBS'], - ) + if not autoconf.CheckParseConfigForLib('LIBXML2', xml2_config + ' --cflags --libs'): + fail("Couldn't find xml2") + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ]) if env['with_zlib']: if not autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'):