From e373b36d00fbfec2a9120cc61eacb70e4ff8e1fc Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 9 Dec 2014 09:32:05 +0100 Subject: [PATCH] setup: Honor CFLAGS set as environment variable Distributions normally have their preferred set of CFLAGS so the binaries are optimized and include debug symbols to create a debuginfo package. For this we need to be able to set the CFLAGS via the commandline and the setup.py should forward them to the compiler. Signed-off-by: Andreas Schneider --- setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 434dff5f..7dbf0217 100755 --- a/setup.py +++ b/setup.py @@ -6,6 +6,7 @@ import os import sys import subprocess import logging +import shlex from setuptools import setup, find_packages @@ -27,7 +28,10 @@ def compile_client(): else: from distutils.ccompiler import new_compiler compiler = new_compiler().compiler - subprocess.check_call(compiler + ['-O3', 'client/powerline.c', '-o', 'scripts/powerline']) + cflags = os.environ.get('CFLAGS', '-O3') + # A normal split would do a split on each space which might be incorrect. The + # shlex will not split if a space occurs in an arguments value. + subprocess.check_call(compiler + shlex.split(cflags) + ['client/powerline.c', '-o', 'scripts/powerline']) try: compile_client()