From f0ac801ecdbeadc99294285d19083573370e70bc Mon Sep 17 00:00:00 2001 From: "roberto@silente" Date: Wed, 23 Jun 2010 23:15:47 +0200 Subject: [PATCH] support gcc < 4 --- uwsgiconfig.py | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/uwsgiconfig.py b/uwsgiconfig.py index 894d4f48..6ca5f4b9 100644 --- a/uwsgiconfig.py +++ b/uwsgiconfig.py @@ -63,16 +63,37 @@ GCC = os.environ.get('CC', sysconfig.get_config_var('CC')) if not GCC: GCC = 'gcc' + +def spcall(cmd): + p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) + + if p.wait() == 0: + return p.stdout.read().rstrip().decode() + else: + return None + +def spcall2(cmd): + p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) + + if p.wait() == 0: + return p.stderr.read().rstrip().decode() + else: + return None + +gcc_version = str(spcall2("%s -v" % GCC)).split('\n')[-1].split()[2] + +gcc_major = int(gcc_version.split('.')[0]) + + gcc_list = ['utils', 'pyutils', 'protocol', 'socket', 'logging', 'wsgi_handlers', 'wsgi_headers', 'uwsgi_handlers', 'plugins', 'uwsgi'] -# large file support -try: - cflags = ['-O2', '-fno-strict-aliasing', '-Wall', '-Werror', '-Wextra', '-Wno-unused-parameter', '-Wno-missing-field-initializers', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'] + os.environ.get("CFLAGS", "").split() -except: - print("You need python headers to build uWSGI.") - sys.exit(1) +cflags = ['-O2', '-fno-strict-aliasing', '-Wall', '-Werror', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'] + os.environ.get("CFLAGS", "").split() + +if gcc_major >= 4: + cflags = cflags + [ '-Wextra', '-Wno-unused-parameter', '-Wno-missing-field-initializers' ] cflags = cflags + ['-I' + sysconfig.get_python_inc(), '-I' + sysconfig.get_python_inc(plat_specific=True) ] + ldflags = os.environ.get("LDFLAGS", "").split() libs = ['-lpthread', '-rdynamic'] + sysconfig.get_config_var('LIBS').split() + sysconfig.get_config_var('SYSLIBS').split() if not sysconfig.get_config_var('Py_ENABLE_SHARED'): @@ -90,13 +111,6 @@ def depends_on(what, dep): print("%s needs %s support." % (what, d)) sys.exit(1) -def spcall(cmd): - p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) - - if p.wait() == 0: - return p.stdout.read().rstrip().decode() - else: - return None def add_o(x): if x == 'uwsgi':