From 1bbfefb37c22c959b4e6457c6740e562bf24bb34 Mon Sep 17 00:00:00 2001 From: calvin Date: Fri, 15 Jul 2005 15:16:38 +0000 Subject: [PATCH] fix gcc option detection git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2757 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- ChangeLog | 6 ++++++ setup.py | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index fd6e07b4..ba4fc69d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,12 @@ Type: feature Changed: linkcheck/checker/httpurl.py + * Fix detection code of supported GCC command line options. this + fixes a build error on some Unix systems (eg. FreeBSD). + Type: bugfix + Closes: SF bug #1238906 + Changed: setup.py + 3.0 "The Jacket" (released 8.7.2005) * Catch all check errors, not just the ones inside of URL checking. diff --git a/setup.py b/setup.py index 0472c89e..071f0930 100755 --- a/setup.py +++ b/setup.py @@ -25,6 +25,7 @@ if sys.version_info < (2, 4, 0, 'final', 0): raise SystemExit, "The installation script of this program requires" + \ " Python 2.4.0 or later." import os +import popen2 import platform import stat import re @@ -197,13 +198,21 @@ class MyDistribution (distutils.dist.Distribution, object): def cc_supports_option (cc, option): + """ + Check if the given C compiler supports the given option. + + @return: True if the compiler supports the option, else False + @rtype: bool + """ prog = "int main(){}\n" cc_cmd = "%s -E %s -" % (cc[0], option) - _in, _out = os.popen4(cc_cmd) - _in.write(prog) - _in.close() - while _out.read(): pass - return _out.close() is None + pipe = popen2.Popen4(cc_cmd) + pipe.tochild.write(prog) + pipe.tochild.close() + status = pipe.wait() + if os.WIFEXITED(status): + return os.WEXITSTATUS(status)==0 + return False class MyBuildExt (build_ext, object):