changeset 5:f1194791e5e1

pkg-config is now used to dynamically fetch required cairo paths as necessary.
author Atul Varma <varmaa@toolness.com>
date Sun, 24 Feb 2008 09:30:58 -0600
parents 3f48710a9ba1
children 853d8676221f
files src/SConscript
diffstat 1 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/SConscript	Sun Feb 24 08:52:33 2008 -0600
+++ b/src/SConscript	Sun Feb 24 09:30:58 2008 -0600
@@ -12,6 +12,7 @@
 
 import os
 import sys
+import subprocess
 
 
 # ----------------------------------------------------------------------------
@@ -25,11 +26,24 @@
 # Build Actions
 # ----------------------------------------------------------------------------
 
+def getOutput( params ):
+    popen = subprocess.Popen( params,
+                              stdout=subprocess.PIPE,
+                              stderr=subprocess.PIPE )
+    output, errors = popen.communicate()
+    if popen.returncode != 0:
+        sys.stderr.write( "Running '%s' failed.\n" % " ".join(params) )
+        sys.stderr.write( "Output was:\n%s\n(end of output)\n" % errors )
+        raise SystemError()
+    return output
+
+cairoLibFlags = getOutput( ["pkg-config", "cairo", "--libs"] )
+cairoIncludeFlags = getOutput( ["pkg-config", "cairo", "--cflags"] )
+
 env.Append(
-    # TODO: Use pkg-config or something to get these paths.
-    CPPPATH=["/opt/local/include/cairo",
-             os.path.join( sys.prefix, "include/pycairo" )],
-    LIBPATH=["/opt/local/lib"],
+    CPPPATH=[os.path.join( sys.prefix, "include/pycairo" )],
+    CCFLAGS=cairoIncludeFlags.split(),
+    LINKFLAGS=cairoLibFlags,
     LIBS=["python", "cairo"],
     FRAMEWORKS=["AppKit"],
     )