2
0
Fork 0

added build date info to wscript and -v option

personal/stbuehler/wip
Thomas Porzelt 2008-07-18 00:30:02 +02:00
parent 607e1897ef
commit aa297fe7b2
3 changed files with 77 additions and 58 deletions

View File

@ -204,7 +204,7 @@
%% write data;
GList *config_parser_data;
static GList *config_parser_data;
void config_parser_init() {
config_parser_data = NULL;

View File

@ -4,11 +4,15 @@
#include "config_parser.h"
static gchar *config_path = NULL;
static gboolean luaconfig = FALSE;
static gboolean test_config = FALSE;
static gboolean show_version = FALSE;
static GOptionEntry entries[] = {
{ "config", 'c', 0, G_OPTION_ARG_FILENAME, &config_path, "filename/path of the config", "PATH"},
{ "config", 'c', 0, G_OPTION_ARG_FILENAME, &config_path, "filename/path of the config", "PATH" },
{ "lua", 'l', 0, G_OPTION_ARG_NONE, &luaconfig, "use the lua config frontend", NULL },
{ "test", 't', 0, G_OPTION_ARG_NONE, &test_config, "test config and exit", NULL },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, "show version and exit", NULL },
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
@ -23,12 +27,19 @@ int main(int argc, char *argv[]) {
/* parse commandline options */
context = g_option_context_new("- fast and lightweight webserver");
g_option_context_add_main_entries(context, entries, NULL);
if (!g_option_context_parse(context, &argc, &argv, &error))
{
if (!g_option_context_parse(context, &argc, &argv, &error)) {
g_printerr("failed to parse command line arguments: %s\n", error->message);
return 1;
}
if (show_version)
{
g_print("%s-%s - a fast and lightweight webserver\n", PACKAGE_NAME, PACKAGE_VERSION);
g_print("Build date: %s\n", PACKAGE_BUILD_DATE);
return 0;
}
srv = server_new();
/* if no path is specified for the config, read lighttpd.conf from current directory */
@ -37,13 +48,19 @@ int main(int argc, char *argv[]) {
g_print("config path: %s\n", config_path);
config_parser_init();
if (!config_parser_file(srv, config_path))
{
return 1;
if (!luaconfig) {
/* standard config frontend */
config_parser_init();
if (!config_parser_file(srv, config_path))
{
return 1;
}
}
else {
/* lua config frontend */
}
/* if config should only be tested, die here */
/* if config should only be tested, don't go over */
if (test_config)
return 0;

100
wscript
View File

@ -2,6 +2,7 @@
# encoding: utf-8
import Options, types, sys, Runner
from time import gmtime, strftime, timezone
# the following two variables are used by the target "waf dist"
VERSION='2.0-pre'
@ -13,10 +14,10 @@ blddir = 'build'
def set_options(opt):
# the gcc module provides a --debug-level option
opt.tool_options('compiler_cc')
opt.tool_options('ragel', tdir = '.')
#opt.add_option('--with-xattr', action='store_true', help='xattr-support for the stat-cache [default: off]', dest='xattr', default = False)
#opt.add_option('--with-mysql', action='store_true', help='with mysql-support for the mod_sql_vhost [default: off]', dest = 'mysql', default = False)
#opt.add_option('--with-postgresql', action='store_true', help='with postgress-support for the mod_sql_vhost [default: off]', dest = 'postgresql', default = False)
@ -42,7 +43,7 @@ class typesize_enumerator(enumerator_base):
def __init__(self, conf):
enumerator_base.__init__(self, conf)
self.typename = ''
self.headers = []
self.include_paths = []
@ -52,7 +53,7 @@ class typesize_enumerator(enumerator_base):
self.flags = ''
self.define = ''
self.uselib = ''
def error(self):
errmsg = 'test program would not run'
if self.message: errmsg += '\n%s' % self.message
@ -68,20 +69,20 @@ class typesize_enumerator(enumerator_base):
def run_test(self):
code = ''
code = []
code.append('#include <stdio.h>\n')
for header in self.headers:
code.append('#include <%s>\n' % header)
code.append('int main(){printf("%%zu\\n", sizeof(%s));\nreturn 0;\n}\n' % self.typename)
oldlibpath = self.env['LIBPATH']
oldlib = self.env['LIB']
self.env['LIB'] = self.libs
self.env['LIBPATH'] = self.lib_paths
obj = check_data()
obj.code = "\n".join(code)
obj.env = self.env
@ -89,7 +90,7 @@ class typesize_enumerator(enumerator_base):
obj.includes = self.include_paths
obj.force_compiler = 1 # getattr(self, 'force_compiler', None)
obj.execute = 1
ret = self.conf.run_check(obj)
tsize = ''
if ret != False: tsize = ret['result']
@ -192,30 +193,31 @@ def PKGCONFIG(conf, name, uselib = None, define = '', version = '', mandatory =
def configure(conf):
opts = Options.options
conf.check_tool('compiler_cc')
conf.check_tool('ragel', tooldir = '.')
if not opts.libdir:
opts.libdir = opts.prefix + "/lib/lighttpd" + opts.append
conf.sub_config('src')
if opts.all:
# for o in "xattr mysql postgresql openssl pcre webdavprops sqlite3 bzip zlib ldap libfcgi lua glib".split(" "):
for o in "lua".split(" "):
setattr(opts, o, True)
#if opts.webdavprops:
#opts.sqlite3 = True
#opts.xml = opts.uuid = True
#else:
#opts.xml = opts.uuid = False
conf.define("LIGHTTPD_VERSION_ID", 20000)
conf.define("PACKAGE_NAME", APPNAME)
conf.define("PACKAGE_VERSION", VERSION)
conf.define("PACKAGE_BUILD_DATE", strftime("%b %d %Y %H:%M:%S UTC", gmtime()));
conf.define("LIBRARY_DIR", opts.libdir)
common_ccflags = [
'-std=gnu99', '-Wall', '-g', '-Wshadow', '-W', '-pedantic',
]
@ -231,12 +233,12 @@ def configure(conf):
conf.env['LINKFLAGS_lighty'] += [ '-export-dynamic' ]
conf.env['LINKFLAGS_lightymod'] += [ '-module', '-export-dynamic', '-avoid-version', '-W,l-no-undefined' ]
conf.env['LINKFLAGS_thread'] += [ '-pthread' ]
if sys.platform == 'linux':
conf.env['LIB_lighty'] += ['rt']
CHECK_LIBRARY_EXISTS(conf, "ev", "ev_loop", "HAVE_LIBEV", uselib = 'ev')
CHECK_INCLUDE_FILES(conf, "sys/devpoll.h", "HAVE_SYS_DEVPOLL_H")
CHECK_INCLUDE_FILES(conf, "sys/epoll.h", "HAVE_SYS_EPOLL_H")
CHECK_INCLUDE_FILES(conf, "sys/event.h", "HAVE_SYS_EVENT_H")
@ -256,34 +258,34 @@ def configure(conf):
CHECK_INCLUDE_FILES(conf, "time.h", "HAVE_TIME_H")
CHECK_INCLUDE_FILES(conf, "unistd.h", "HAVE_UNISTD_H")
CHECK_INCLUDE_FILES(conf, "pthread.h", "HAVE_PTHREAD_H")
CHECK_INCLUDE_FILES(conf, "getopt.h", "HAVE_GETOPT_H")
CHECK_INCLUDE_FILES(conf, "inttypes.h", "HAVE_INTTYPES_H")
CHECK_INCLUDE_FILES(conf, "poll.h", "HAVE_POLL_H")
CHECK_INCLUDE_FILES(conf, "pwd.h", "HAVE_PWD_H")
CHECK_INCLUDE_FILES(conf, "stddef.h", "HAVE_STDDEF_H")
CHECK_INCLUDE_FILES(conf, "stdint.h", "HAVE_STDINT_H")
CHECK_INCLUDE_FILES(conf, "syslog.h", "HAVE_SYSLOG_H")
CHECK_INCLUDE_FILES(conf, "aio.h", "HAVE_AIO_H")
CHECK_INCLUDE_FILES(conf, "sys/inotify.h", "HAVE_SYS_INOTIFY_H")
if conf.is_defined("HAVE_SYS_INOTIFY_H"):
CHECK_FUNCTION_EXISTS(conf, "inotify_init", "HAVE_INOTIFY_INIT")
headers = [];
if conf.is_defined("HAVE_SYS_TYPES_H"): headers.append('sys/types.h')
if conf.is_defined("HAVE_STDINT_H"): headers.append('stdint.h')
if conf.is_defined("HAVE_STDDEF_H"): headers.append('stddef.h')
if conf.is_defined("HAVE_INTTYPES_H"): headers.append('inttypes.h')
CHECK_TYPE_SIZE(conf, "socklen_t", "HAVE_SOCKLEN_T", headers + ['sys/socket.h'], ['lighty'])
CHECK_TYPE_SIZE(conf, "long", "SIZEOF_LONG", headers)
CHECK_TYPE_SIZE(conf, "off_t", "SIZEOF_OFF_T", headers)
CHECK_FUNCTION_EXISTS(conf, "chroot", "HAVE_CHROOT")
CHECK_FUNCTION_EXISTS(conf, "crypt", "HAVE_CRYPT")
CHECK_FUNCTION_EXISTS(conf, "epoll_ctl", "HAVE_EPOLL_CTL")
@ -318,13 +320,13 @@ def configure(conf):
CHECK_FUNCTION_EXISTS(conf, "inet_aton", "HAVE_INET_ATON")
CHECK_FUNCTION_EXISTS(conf, "inet_atop", "HAVE_IPV6")
CHECK_FUNCTION_EXISTS(conf, "strtoll", "HAVE_STRTOLL")
CHECK_INCLUDE_FILES(conf, "tap.h", "HAVE_LIBTAP_H", uselib = 'tap')
CHECK_LIBRARY_EXISTS(conf, "tap", "plan_tests", "HAVE_LIBTAP", uselib = 'tap', mandatory = 0)
#if opts.xattr:
#CHECK_INCLUDE_FILES(conf, "attr/attributes.h", "HAVE_ATTR_ATTRIBUTES_H")
#if opts.mysql:
#if not CONFIGTOOL(conf, 'mysql_config', uselib = 'mysql'):
#CHECK_INCLUDE_FILES(conf, "mysql.h", "HAVE_MYSQL_H", uselib = 'mysql', path = ['/usr/include/mysql'], mandatory = 1)
@ -332,7 +334,7 @@ def configure(conf):
#else:
#conf.define("HAVE_MYSQL_H", 1)
#conf.define("HAVE_LIBMYSQL", 1)
#if opts.postgresql:
#if not CONFIGTOOL(conf, 'pg_config', uselib = 'postgresql'):
#CHECK_INCLUDE_FILES(conf, "libpq-fe.h", "HAVE_LIBPQ_FE_H", uselib = 'postgresql', path = ['/usr/include/pgsql'], mandatory = 1)
@ -340,58 +342,58 @@ def configure(conf):
#else:
#conf.define("HAVE_LIBPQ_FE_H", 1)
#conf.define("HAVE_LIBPQ", 1)
if opts.openssl:
CHECK_INCLUDE_FILES(conf, "openssl/ssl.h", "HAVE_OPENSSL_SSL_H", uselib = 'openssl', mandatory = 1)
CHECK_LIBRARY_EXISTS(conf, "crypto", "BIO_f_base64", "HAVE_LIBCRYPTO", uselib = 'openssl')
CHECK_LIBRARY_EXISTS(conf, "ssl", "SSL_new", "HAVE_LIBSSL", uselib = 'openssl')
conf.define("OPENSSL_NO_KRB5", 1)
#if opts.bzip:
#CHECK_INCLUDE_FILES(conf, "bzlib.h", "HAVE_BZLIB_H", uselib = 'bzip', mandatory = 1)
#CHECK_LIBRARY_EXISTS(conf, "bz2", "BZ2_bzCompressInit", "HAVE_LIBBZ2", uselib = 'bzip')
#if opts.ldap:
#CHECK_INCLUDE_FILES(conf, "ldap.h", "HAVE_LDAP_H", uselib = 'ldap', mandatory = 1)
#CHECK_LIBRARY_EXISTS(conf, "ldap", "ldap_open", "HAVE_LIBLDAP", uselib = 'ldap')
#if opts.libaio:
#CHECK_INCLUDE_FILES(conf, "libaio.h", "HAVE_LIBAIO_H", uselib = 'libaio', mandatory = 1)
#CHECK_LIBRARY_EXISTS(conf, "aio", "io_getevents", "HAVE_LIBAIO", uselib = 'libaio')
#if opts.xml:
#if CONFIGTOOL(conf, 'xml2-config', uselib = 'xml'):
#CHECK_INCLUDE_FILES(conf, "libxml/tree.h", "HAVE_LIBXML_H", mandatory = 1, uselib='xml', use = ['xml'])
#else:
#CHECK_INCLUDE_FILES(conf, "libxml.h", "HAVE_LIBXML_H", mandatory = 1, uselib='xml', use = ['xml'])
#CHECK_LIBRARY_EXISTS(conf, "xml2", "xmlParseChunk", "HAVE_LIBXML", uselib='xml', use = ['xml'])
#if opts.pcre:
#CONFIGTOOL(conf, 'pcre-config', uselib = 'pcre')
#CHECK_INCLUDE_FILES(conf, "pcre.h", "HAVE_PCRE_H", mandatory = 1, uselib = 'pcre', use = ['pcre'])
#CHECK_LIBRARY_EXISTS(conf, "pcre", "pcre_exec", "HAVE_LIBPCRE", uselib = 'pcre', use = ['pcre'])
#if opts.sqlite3:
#CHECK_INCLUDE_FILES(conf, "sqlite3.h", "HAVE_SQLITE3_H", uselib = 'sqlite3', mandatory = 1)
#CHECK_LIBRARY_EXISTS(conf, "sqlite3", "sqlite3_reset", "HAVE_SQLITE3", uselib = 'sqlite3')
PKGCONFIG(conf, "glib-2.0", uselib = 'glib', mandatory = 1)
incdir = conf.env['CPPPATH_glib'][0]
conf.env['CPPPATH_glib'] += [ incdir+'/glib-2.0/', incdir + '/glib-2.0/include/' ]
CHECK_INCLUDE_FILES(conf, "glib.h", "HAVE_GLIB_H", uselib = 'glib', use = ['glib'], mandatory = 1)
#if opts.libfcgi:
#CHECK_INCLUDE_FILES(conf, "fastcgi.h", "HAVE_FASTCGI_H", uselib = 'libfcgi')
#if not conf.is_defined("HAVE_FASTCGI_H"):
#CHECK_INCLUDE_FILES(conf, "fastcgi/fastcgi.h", "HAVE_FASTCGI_FASTCGI_H", uselib = 'libfcgi', mandatory = 1)
#CHECK_LIBRARY_EXISTS(conf, "fcgi", "FCGI_Accept", "HAVE_LIBFCGI", uselib = 'libfcgi')
#if opts.uuid:
#CHECK_INCLUDE_FILES(conf, "uuid/uuid.h", "HAVE_UUID_H")
#CHECK_LIBRARY_EXISTS(conf, "uuid", "uuid_generate", "HAVE_LIBUUID")
#if not conf.is_defined("HAVE_LIBUUID"):
#CHECK_FUNCTION_EXISTS(conf, "uuid_generate", "HAVE_LIBUUID")
#if opts.zlib:
#CHECK_INCLUDE_FILES(conf, "zlib.h", "HAVE_ZLIB_H", uselib = 'zlib', mandatory = 1)
#if sys.platform != "win32":
@ -400,7 +402,7 @@ def configure(conf):
#(CHECK_LIBRARY_EXISTS(conf, "z", "deflate", "HAVE_LIBZ", mandatory = 0, uselib = 'zlib') or
#CHECK_LIBRARY_EXISTS(conf, "zlib", "deflate", "HAVE_LIBZ", mandatory = 0, uselib = 'zlib') or
#CHECK_LIBRARY_EXISTS(conf, "zdll", "deflate", "HAVE_LIBZ", mandatory = 1, uselib = 'zlib'))
if opts.lua:
if not PKGCONFIG(conf, "lua5.1", uselib = 'lua', mandatory = 0):
conf.env['LIB_lua'] = [ 'm' ]
@ -409,16 +411,16 @@ def configure(conf):
else:
conf.define("HAVE_LUA_H", 1)
conf.define("HAVE_LIBLUA", 1)
if not opts.buildstatic:
CHECK_INCLUDE_FILES(conf, "dlfcn.h", "HAVE_DLFCN_H", uselib = 'dl')
if conf.is_defined("HAVE_DLFCN_H"):
CHECK_LIBRARY_EXISTS(conf, "dl", "dlopen", "HAVE_LIBDL", uselib = 'dl')
CHECK_INCLUDE_FILES(conf, "crypt.h", "HAVE_CRYPT_H", uselib = 'crypt')
if conf.is_defined("HAVE_CRYPT_H"):
CHECK_LIBRARY_EXISTS(conf, "crypt", "crypt", "HAVE_LIBCRYPT", uselib = 'crypt')
conf.write_config_header('src/config.h')
def build(bld):
@ -443,10 +445,10 @@ class TestObject:
self.env = 0
self.label = label
self.filename = filename
def abspath(self, env):
return self.filename
def bldpath(self, env):
return self.label