build: fixed pc file variable substitution
authorAndrew Tridgell <tridge@samba.org>
Fri, 7 May 2010 09:41:50 +0000 (11:41 +0200)
committerAndrew Tridgell <tridge@samba.org>
Fri, 7 May 2010 13:14:49 +0000 (15:14 +0200)
We should not substitute for the first use of each variable
declaration in the pkgconfig file

buildtools/wafsamba/wafsamba.py

index 2b53a9ceb64bb6383dbfcf13b7dd7ccfb8314638..96e95159b9196661d312c83c2510a3b27ad5c382 100644 (file)
@@ -662,6 +662,7 @@ def subst_at_vars(task):
     # split on the vars
     a = re.split('(@\w+@)', s)
     out = []
+    done_var = {}
     back_sub = [ ('PREFIX', '${prefix}'), ('EXEC_PREFIX', '${exec_prefix}')]
     for v in a:
         if re.match('@\w+@', v):
@@ -676,7 +677,12 @@ def subst_at_vars(task):
             for (b, m) in back_sub:
                 s = task.env[b]
                 if s == v[0:len(s)]:
-                    v = m + v[len(s):]
+                    if not b in done_var:
+                        # we don't want to substitute the first usage
+                        done_var[b] = True
+                    else:
+                        v = m + v[len(s):]
+                    break
         out.append(v)
     contents = ''.join(out)
     f = open(tgt, 'w')