From a73a010188802d403c860b902d84276f4908f2bd Mon Sep 17 00:00:00 2001 From: "roberto@centos64" Date: Fri, 23 Sep 2011 08:33:15 +0200 Subject: [PATCH] fixed build system for older gcc releases --- plugins/psgi/psgi_plugin.c | 5 +++- plugins/psgi/uwsgiplugin.py | 8 ++++-- plugins/python/pump_subhandler.c | 4 +++ plugins/python/uwsgi_python.h | 1 + uwsgiconfig.py | 42 ++++++++++++++++++++++++++++---- 5 files changed, 52 insertions(+), 8 deletions(-) diff --git a/plugins/psgi/psgi_plugin.c b/plugins/psgi/psgi_plugin.c index 075246a4..735b7f32 100644 --- a/plugins/psgi/psgi_plugin.c +++ b/plugins/psgi/psgi_plugin.c @@ -280,7 +280,7 @@ int uwsgi_perl_init(){ struct http_status_codes *http_sc; - int argc = 3; + int argc; uperl.embedding[0] = ""; uperl.embedding[1] = "-e"; uperl.embedding[2] = "0"; @@ -298,6 +298,9 @@ int uwsgi_perl_init(){ #else uwsgi_log("initializing Perl environment\n"); #endif + + argc = 3; + PERL_SYS_INIT3(&argc, (char ***) &uperl.embedding, &environ); uperl.main = perl_alloc(); if (!uperl.main) { diff --git a/plugins/psgi/uwsgiplugin.py b/plugins/psgi/uwsgiplugin.py index 91008244..eec359ec 100644 --- a/plugins/psgi/uwsgiplugin.py +++ b/plugins/psgi/uwsgiplugin.py @@ -1,7 +1,11 @@ import os,sys NAME='psgi' -CFLAGS = [os.popen('perl -MExtUtils::Embed -e ccopts').read().rstrip()] -LDFLAGS = [os.popen('perl -MExtUtils::Embed -e ldopts').read().rstrip()] +CFLAGS = os.popen('perl -MExtUtils::Embed -e ccopts').read().rstrip().split() +LDFLAGS = os.popen('perl -MExtUtils::Embed -e ldopts').read().rstrip().split() LIBS = [] GCC_LIST = ['uwsgi_plmodule', 'psgi_loader', 'psgi_response', 'psgi_plugin'] + +for item in LDFLAGS: + if item.endswith('DynaLoader.a'): + GCC_LIST.append(item) diff --git a/plugins/python/pump_subhandler.c b/plugins/python/pump_subhandler.c index f04513a0..97315a8f 100644 --- a/plugins/python/pump_subhandler.c +++ b/plugins/python/pump_subhandler.c @@ -257,7 +257,11 @@ int uwsgi_response_subhandler_pump(struct wsgi_request *wsgi_req) { wsgi_req->headers_size += wsize; PyObject *hhkey, *hhvalue; +#ifdef UWSGI_PYTHON_OLD + int hhpos = 0; +#else Py_ssize_t hhpos = 0; +#endif while (PyDict_Next(headers, &hhpos, &hhkey, &hhvalue)) { if (!PyString_Check(hhkey)) continue; diff --git a/plugins/python/uwsgi_python.h b/plugins/python/uwsgi_python.h index ce5be320..af124f8d 100644 --- a/plugins/python/uwsgi_python.h +++ b/plugins/python/uwsgi_python.h @@ -29,6 +29,7 @@ #if PY_MINOR_VERSION == 4 && PY_MAJOR_VERSION == 2 #define Py_ssize_t ssize_t +#define UWSGI_PYTHON_OLD #endif #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 7 diff --git a/uwsgiconfig.py b/uwsgiconfig.py index 410d76fc..7eb1ce3f 100644 --- a/uwsgiconfig.py +++ b/uwsgiconfig.py @@ -73,6 +73,8 @@ def spcall3(cmd): def add_o(x): if x == 'uwsgi': x = 'main' + elif x.endswith('.a'): + return x x = x + '.o' return x @@ -129,7 +131,8 @@ def build_uwsgi(uc): objfile = file if objfile == 'uwsgi': objfile = 'main' - compile(' '.join(cflags), objfile + '.o', file + '.c') + if not objfile.endswith('.a'): + compile(' '.join(cflags), objfile + '.o', file + '.c') if uc.get('embedded_plugins'): ep = uc.get('embedded_plugins').split(',') @@ -152,10 +155,20 @@ def build_uwsgi(uc): p_cflags = cflags[:] p_cflags += up.CFLAGS + print p_cflags + + try: + p_cflags.remove('-Wdeclaration-after-statement') + except: + pass + for cfile in up.GCC_LIST: - compile(' '.join(p_cflags), - path + '/' + cfile + '.o', path + '/' + cfile + '.c') - gcc_list.append('%s/%s' % (path, cfile)) + if not cfile.endswith('.a'): + compile(' '.join(p_cflags), + path + '/' + cfile + '.o', path + '/' + cfile + '.c') + gcc_list.append('%s/%s' % (path, cfile)) + else: + gcc_list.append(cfile) libs += up.LIBS ldflags += up.LDFLAGS @@ -207,6 +220,18 @@ class uConf(object): print("using profile: %s" % filename) if not os.path.exists(filename): raise Exception("profile not found !!!") + + if os.path.exists('uwsgibuild.lastprofile'): + ulp = open('uwsgibuild.lastprofile','r') + last_profile = ulp.read() + ulp.close() + if last_profile != filename: + os.environ['UWSGI_FORCE_REBUILD'] = '1' + + ulp = open('uwsgibuild.lastprofile','w') + ulp.write(filename) + ulp.close() + self.config.read(filename) self.gcc_list = ['utils', 'protocol', 'socket', 'logging', 'master', 'master_utils', 'emperor', 'notify', 'plugins', 'lock', 'cache', 'queue', 'event', 'signal', 'rpc', 'gateway', 'loop', 'lib/rbtree', 'lib/amqp', 'rb_timers', 'uwsgi'] @@ -742,7 +767,9 @@ def build_plugin(path, uc, cflags, ldflags, libs, name = None): shared_flag = '-dynamiclib -undefined dynamic_lookup' for cfile in up.GCC_LIST: - if not cfile.endswith('.c') and not cfile.endswith('.cc'): + if cfile.endswith('.a'): + gcc_list.append(cfile) + elif not cfile.endswith('.c') and not cfile.endswith('.cc'): gcc_list.append(path + '/' + cfile + '.c') else: gcc_list.append(path + '/' + cfile) @@ -752,6 +779,11 @@ def build_plugin(path, uc, cflags, ldflags, libs, name = None): except: pass + try: + p_cflags.remove('-Wdeclaration-after-statement') + except: + pass + #for ofile in up.OBJ_LIST: # gcc_list.insert(0,ofile)