From e95ea21b1ec593382d41663910c316bb5432b9a3 Mon Sep 17 00:00:00 2001 From: Jan Kneschke Date: Sat, 24 Sep 2005 12:07:57 +0000 Subject: [PATCH] added a alternative to automake and friends by using scons The main reason is improved built-speed git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@734 152afb58-edef-0310-8abb-c4023f1b3aa9 --- SConstruct | 143 +++++++++++++++++++++++++++++++++++++++++++++++ config.py-sample | 9 +++ src/SConscript | 70 +++++++++++++++++++++++ tests/SConscript | 39 +++++++++++++ 4 files changed, 261 insertions(+) create mode 100644 SConstruct create mode 100644 config.py-sample create mode 100644 src/SConscript create mode 100644 tests/SConscript diff --git a/SConstruct b/SConstruct new file mode 100644 index 00000000..c130ea76 --- /dev/null +++ b/SConstruct @@ -0,0 +1,143 @@ +import os +import re + +package = 'lighttpd' +version = '1.4.4' + + +def checkCHeaders(autoconf, hdrs): + p = re.compile('[^A-Z0-9]') + for hdr in hdrs: + if autoconf.CheckCHeader(hdr): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_' + p.sub('_', hdr.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()) ]) + + +BuildDir('build', 'src', duplicate = 0) + +opts = Options('config.py') +opts.AddOptions( + ('prefix', 'prefix', '/usr/local'), + ('bindir', 'binary directory', '${prefix}/bin'), + ('libdir', 'library directory', '${prefix}/lib'), + PackageOption('with_mysql', 'enable mysql support', 'no'), + PackageOption('with_xml', 'enable xml support', 'no'), + PackageOption('with_pcre', 'enable pcre support', 'yes'), + BoolOption('with_sqlite3', 'enable sqlite3 support', 'no'), + BoolOption('with_memcache', 'enable memcache support', 'no'), + BoolOption('with_fam', 'enable FAM/gamin support', 'no'), + BoolOption('with_openssl', 'enable memcache support', 'no'), + BoolOption('with_gzip', 'enable gzip compression', 'no'), + BoolOption('with_bzip2', 'enable bzip2 compression', 'no')) + +env = Environment( + env = os.environ, + options = opts, + CCFLAGS = Split('-Wall -O2 -g -pedantic -Wunused -Wshadow -Isrc/'), + LIBS = [ 'dl' ] +) + +env['package'] = package +env['version'] = version + +# cache configure checks +if 1: + autoconf = Configure(env) + checkCHeaders(autoconf, Split('arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h \ + sys/socket.h sys/time.h unistd.h sys/sendfile.h sys/uio.h \ + getopt.h sys/epoll.h sys/select.h poll.h sys/poll.h sys/devpoll.h sys/filio.h \ + sys/mman.h sys/event.h sys/port.h winsock2.h pwd.h sys/syslimits.h \ + sys/resource.h sys/un.h syslog.h stdint.h inttypes.h sys/wait.h')) + + checkFuncs(autoconf, Split('fork stat lstat strftime dup2 getcwd inet_ntoa inet_ntop memset mmap munmap strchr \ + strdup strerror strstr strtol sendfile getopt socket \ + gethostbyname poll sigtimedwait epoll_ctl getrlimit chroot \ + getuid select signal pathconf\ + writev sigaction sendfile64 send_file kqueue port_create localtime_r')) + + checkTypes(autoconf, Split('pid_t size_t off_t')) + + autoconf.env.Append( LIBSQLITE3 = '', LIBXML2 = '', LIBMYSQL = '') + + 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('crypt', 'crypt.h', 'C'): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_CRYPT_H', '-DHAVE_LIBCRYPT' ], LIBCRYPT = 'crypt') + + if env['with_openssl']: + if autoconf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C'): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_OPENSSL_SSL_H', '-DHAVE_LIBSSL'] , LIBS = [ 'ssl', 'crypto' ]) + + if env['with_gzip']: + if autoconf.CheckLibWithHeader('z', 'zlib.h', 'C'): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_ZLIB_H', '-DHAVE_LIBZ' ], LIBZ = 'z') + + if env['with_bzip2']: + if autoconf.CheckLibWithHeader('bz2', 'bzlib.h', 'C'): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_BZLIB_H', '-DHAVE_LIBBZ2' ], LIBBZ2 = 'bz2') + + if env['with_memcache']: + if autoconf.CheckLibWithHeader('memcache', 'memcache.h', 'C'): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_MEMCACHE_H', '-DHAVE_LIBMEMCACHE' ], LIBMEMCACHE = 'memcache') + + if env['with_sqlite3']: + if autoconf.CheckLibWithHeader('sqlite3', 'sqlite3.h', 'C'): + autoconf.env.Append(CPPFLAGS = [ '-DHAVE_SQLITE3_H', '-DHAVE_LIBSQLITE3' ], LIBSQLITE3 = 'sqlite3') + + 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' ]) + + + env = autoconf.Finish() + +if env['with_pcre']: + if env['with_pcre'] != 1: + pcre_config = env['with_pcre'] + elif env.Detect('pcre-config'): + pcre_config = env.WhereIs('pcre-config') + env.ParseConfig(pcre_config + ' --cflags --libs') + env.Append(CPPFLAGS = [ '-DHAVE_PCRE_H', '-DHAVE_LIBPCRE' ], LIBPCRE = 'pcre') + +if env['with_xml']: + if env['with_xml'] != 1: + xml2_config = env['with_xml'] + elif env.Detect('xml2-config'): + xml2_config = env.WhereIs('xml2-config') + env.ParseConfig(xml2_config + ' --cflags --libs') + env.Append(CPPFLAGS = [ '-DHAVE_LIBXML_H', '-DHAVE_LIBXML2' ], LIBXML2 = 'xml2') + +if env['with_mysql']: + if env['with_mysql'] != 1: + mysql_config = env['with_mysql'] + else: + mysql_config = env.WhereIs('mysql_config') + + env.ParseConfig(mysql_config + ' --cflags --libs') + env.Append(CPPFLAGS = [ '-DHAVE_MYSQL' ], LIBMYSQL = 'mysqlclient') + +env.Append(CPPFLAGS = [ + '-DLIGHTTPD_VERSION_ID=' + str(1 << 16 | 4 << 8 | 4), + '-DPACKAGE_NAME=\\"' + package + '\\"', + '-DPACKAGE_VERSION=\\"' + version + '\\"', + '-DLIBRARY_DIR="\\"${libdir}\\""', + '-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES' + ] ) + +SConscript( 'src/SConscript', 'env', build_dir = 'build', duplicate = 0) +SConscript( 'tests/SConscript', 'env' ) diff --git a/config.py-sample b/config.py-sample new file mode 100644 index 00000000..158bd90b --- /dev/null +++ b/config.py-sample @@ -0,0 +1,9 @@ +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_xml2='yes' diff --git a/src/SConscript b/src/SConscript new file mode 100644 index 00000000..c2a6b2d9 --- /dev/null +++ b/src/SConscript @@ -0,0 +1,70 @@ +Import('env') + +src = Split("buffer.c log.c \ + keyvalue.c chunk.c \ + http_chunk.c stream.c fdevent.c \ + stat_cache.c plugin.c joblist.c etag.c array.c \ + data_string.c data_count.c data_array.c \ + data_integer.c md5.c data_fastcgi.c \ + fdevent_select.c fdevent_linux_rtsig.c \ + fdevent_poll.c fdevent_linux_sysepoll.c \ + fdevent_solaris_devpoll.c fdevent_freebsd_kqueue.c \ + data_config.c bitset.c \ + inet_ntop_cache.c crc32.c \ + connections-glue.c \ + configfile-glue.c \ + http-header-glue.c \ + splaytree.c server.c response.c connections.c network.c \ + network_write.c network_linux_sendfile.c \ + network_freebsd_sendfile.c network_writev.c \ + network_solaris_sendfilev.c network_openssl.c \ + configfile.c configparser.c request.c proc_open.c") + +lemon = env.Program('lemon', 'lemon.c') + +configparser = env.Command('configparser.c', 'configparser.y', '(cd build; ../' + lemon[0].path + ' -q ../$SOURCE ../src/lempar.c; cd ..)') +env.Depends(configparser, lemon) + +instbin = env.Program('lighttpd', src, LINKFLAGS = [ '-Wl,--export-dynamic' ]) + +env['SHLIBPREFIX'] = '' +instlib = [] +instlib += env.SharedLibrary('mod_access', [ 'mod_access.c' ], LIBS='') +instlib += env.SharedLibrary('mod_alias', [ 'mod_alias.c' ], LIBS='') +instlib += env.SharedLibrary('mod_cgi', [ 'mod_cgi.c' ], LIBS='') +instlib += env.SharedLibrary('mod_fastcgi', [ 'mod_fastcgi.c' ], LIBS='') +instlib += env.SharedLibrary('mod_scgi', [ 'mod_scgi.c' ], LIBS='') +instlib += env.SharedLibrary('mod_staticfile', [ 'mod_staticfile.c' ], LIBS='') +instlib += env.SharedLibrary('mod_dirlisting', [ 'mod_dirlisting.c' ], LIBS= [ env['LIBPCRE'] ]) +instlib += env.SharedLibrary('mod_indexfile', [ 'mod_indexfile.c' ], LIBS='') +instlib += env.SharedLibrary('mod_setenv', [ 'mod_setenv.c' ], LIBS='') +instlib += env.SharedLibrary('mod_rrdtool', [ 'mod_rrdtool.c' ], LIBS='') +instlib += env.SharedLibrary('mod_usertrack', [ 'mod_usertrack.c' ], LIBS='') +instlib += env.SharedLibrary('mod_proxy', [ 'mod_proxy.c' ], LIBS='') +instlib += env.SharedLibrary('mod_userdir', [ 'mod_userdir.c' ], LIBS='') +instlib += env.SharedLibrary('mod_ssi', [ 'mod_ssi.c' ], LIBS='') +instlib += env.SharedLibrary('mod_secdownload', [ 'mod_secure_download.c' ], LIBS='') +instlib += env.SharedLibrary('mod_access', [ 'mod_access.c' ], LIBS='') +instlib += env.SharedLibrary('mod_accesslog', [ 'mod_accesslog.c' ], LIBS='') +instlib += env.SharedLibrary('mod_simple_vhost', [ 'mod_simple_vhost.c' ], LIBS='') +instlib += env.SharedLibrary('mod_evhost', [ 'mod_evhost.c' ], LIBS='') +instlib += env.SharedLibrary('mod_expire', [ 'mod_expire.c' ], LIBS='') +instlib += env.SharedLibrary('mod_status', [ 'mod_status.c' ], LIBS='') +instlib += env.SharedLibrary('mod_compress', [ 'mod_compress.c' ], LIBS= [ env['LIBZ'], env['LIBBZ2'] ] ) +instlib += env.SharedLibrary('mod_redirect', [ 'mod_redirect.c' ], LIBS = [ env['LIBPCRE'] ] ) +instlib += env.SharedLibrary('mod_rewrite', [ 'mod_rewrite.c' ], LIBS= [ env['LIBPCRE'] ]) +instlib += env.SharedLibrary('mod_auth', [ Split('mod_auth.c http_auth_digest.c http_auth.c') ], LIBS= [ env['LIBCRYPT'] ]) +instlib += env.SharedLibrary('mod_webdav', [ 'mod_webdav.c' ], LIBS= [ env['LIBXML2'], env['LIBSQLITE3'] ]) +instlib += env.SharedLibrary('mod_mysql_vhost', [ 'mod_mysql_vhost.c' ], LIBS= [ env['LIBMYSQL'] ]) +instlib += env.SharedLibrary('mod_trigger_b4_dl', [ 'mod_trigger_b4_dl.c' ], LIBS= [ env['LIBPCRE'] ]) +instlib += env.SharedLibrary('mod_cml', [ 'mod_cml.c' ], LIBS= [ env['LIBPCRE'] ]) + +inst = [] +inst += env.Install('${bindir}', instbin) +inst += env.Install('${libdir}', instlib) + +env.Alias('install', inst) + +pkgdir = '.' +tarname = env['package'] + '-' + env['version'] + diff --git a/tests/SConscript b/tests/SConscript new file mode 100644 index 00000000..6d69c6f2 --- /dev/null +++ b/tests/SConscript @@ -0,0 +1,39 @@ +Import('env') + +tests = Split('prepare.sh \ + run-tests.pl \ + cleanup.sh') + +extra_dist = Split('fastcgi-10.conf \ + fastcgi-auth.conf \ + fastcgi-responder.conf \ + fastcgi-13.conf \ + bug-06.conf \ + bug-12.conf \ + core-var-include.t \ + var-include.conf \ + var-include-sub.conf \ + condition.conf \ + core-condition.t \ + core-request.t \ + core-response.t \ + core-keepalive.t \ + core.t \ + mod-access.t \ + mod-auth.t \ + mod-cgi.t \ + mod-compress.t \ + mod-fastcgi.t \ + mod-redirect.t \ + mod-userdir.t \ + mod-rewrite.t \ + request.t \ + mod-ssi.t \ + LightyTest.pm \ + mod-setenv.t') + +t = env.Command('foo1', 'prepare.sh', '(cd ./tests/; ./prepare.sh; cd ..)') +t += env.Command('foo2', 'run-tests.pl', '( cd ./tests/; SHELL=/bin/sh ./run-tests.pl; cd ..)') +t += env.Command('foo3', 'cleanup.sh', '(cd ./tests/; ./cleanup.sh; cd ..)') + +env.Alias('check', t )