[jhbuild/wip/path-env] Revert "environment: don't set ACLOCAL_FLAGS"



commit f109d8c06cb9635194db62cba6e463f2cf5a9db1
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Mar 12 18:20:42 2014 -0400

    Revert "environment: don't set ACLOCAL_FLAGS"
    
    This reverts commit 96077045382fa9c5de0edfa7b9c3cfd459057ce1.
    
    gnome-autogen.sh doesn't grok ACLOCAL_PATH yet.

 jhbuild/environment.py |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/jhbuild/environment.py b/jhbuild/environment.py
index ad6ae84..fc04859 100644
--- a/jhbuild/environment.py
+++ b/jhbuild/environment.py
@@ -27,7 +27,27 @@ from jhbuild.utils.cmds import get_output
 
 def addpath(envvar, path):
     '''Adds a path to an environment variable.'''
-    if envvar in [ 'LDFLAGS', 'CFLAGS', 'CXXFLAGS' ]:
+    # special case ACLOCAL_FLAGS
+    if envvar in [ 'ACLOCAL_FLAGS' ]:
+        if sys.platform.startswith('win'):
+            path = jhbuild.utils.subprocess_win32.fix_path_for_msys(path)
+
+        envval = os.environ.get(envvar, '-I %s' % path)
+        parts = ['-I', path] + envval.split()
+        i = 2
+        while i < len(parts)-1:
+            if parts[i] == '-I':
+                # check if "-I parts[i]" comes earlier
+                for j in range(0, i-1):
+                    if parts[j] == '-I' and parts[j+1] == parts[i+1]:
+                        del parts[i:i+2]
+                        break
+                else:
+                    i += 2
+            else:
+                i += 1
+        envval = ' '.join(parts)
+    elif envvar in [ 'LDFLAGS', 'CFLAGS', 'CXXFLAGS' ]:
         if sys.platform.startswith('win'):
             path = jhbuild.utils.subprocess_win32.fix_path_for_msys(path)
 
@@ -196,6 +216,19 @@ def setup_env(prefix):
     aclocalpath = os.path.join(prefix, 'share', 'aclocal')
     addpath('ACLOCAL_PATH', aclocalpath)
 
+    # ACLOCAL_FLAGS
+    aclocaldir = os.path.join(prefix, 'share', 'aclocal')
+    if not os.path.exists(aclocaldir):
+        try:
+            os.makedirs(aclocaldir)
+        except:
+            raise FatalError(_("Can't create %s directory") % aclocaldir)
+    if os.path.exists('/usr/share/aclocal'):
+        addpath('ACLOCAL_FLAGS', '/usr/share/aclocal')
+        if os.path.exists('/usr/local/share/aclocal'):
+            addpath('ACLOCAL_FLAGS', '/usr/local/share/aclocal')
+    addpath('ACLOCAL_FLAGS', aclocaldir)
+
     # PERL5LIB
     perl5lib = os.path.join(prefix, 'lib', 'perl5')
     addpath('PERL5LIB', perl5lib)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]