Index: Lib/distutils/tests/test_sysconfig.py =================================================================== --- Lib/distutils/tests/test_sysconfig.py (revision 72223) +++ Lib/distutils/tests/test_sysconfig.py (working copy) @@ -4,6 +4,7 @@ from distutils.ccompiler import get_default_compiler import os +import test import unittest from test.test_support import TESTFN @@ -12,10 +13,13 @@ def setUp(self): self.old_AR = os.environ.get('AR') + self.makefile = None def tearDown(self): if self.old_AR is not None: os.environ['AR'] = self.old_AR + if self.makefile is not None: + os.unlink(self.makefile) def test_get_config_h_filename(self): config_h = sysconfig.get_config_h_filename() @@ -62,8 +66,32 @@ sysconfig.customize_compiler(comp) self.assertEquals(comp.exes['archiver'], 'xxx') + def test_parse_makefile_base(self): + self.makefile = test.test_support.TESTFN + fd = open(self.makefile, 'w') + fd.write(r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=LIB'" '\n') + fd.write('VAR=$OTHER\nOTHER=foo') + fd.close() + d = sysconfig.parse_makefile(self.makefile) + self.assertEquals(d, {'CONFIG_ARGS': "'--arg1=optarg1' 'ENV=LIB'", + 'OTHER': 'foo'}) + def test_parse_makefile_literal_dollar(self): + self.makefile = test.test_support.TESTFN + fd = open(self.makefile, 'w') + fd.write(r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=\$$LIB'" '\n') + fd.write('VAR=$OTHER\nOTHER=foo') + fd.close() + d = sysconfig.parse_makefile(self.makefile) + self.assertEquals(d, {'CONFIG_ARGS': r"'--arg1=optarg1' 'ENV=\$$LIB'", + 'OTHER': 'foo'}) + + def test_suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(SysconfigTestCase)) return suite + + +if __name__ == '__main__': + test.test_support.run_unittest(test_suite()) Index: Lib/distutils/sysconfig.py =================================================================== --- Lib/distutils/sysconfig.py (revision 72223) +++ Lib/distutils/sysconfig.py (working copy) @@ -287,7 +287,8 @@ if m: n, v = m.group(1, 2) v = string.strip(v) - if "$" in v: + tmpv = v.replace("$$", "") # `$$' is a literaly `$' in make + if "$" in tmpv: notdone[n] = v else: try: v = int(v)