diff --git a/Library/Formula/python.rb b/Library/Formula/python.rb index ec0892e3fe8b..28321e501641 100644 --- a/Library/Formula/python.rb +++ b/Library/Formula/python.rb @@ -110,18 +110,20 @@ def install args << "--without-gcc" if ENV.compiler == :clang + cflags = [] + ldflags = [] + cppflags = [] + unless MacOS::CLT.installed? # Help Python's build system (setuptools/pip) to build things on Xcode-only systems # The setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot) - cflags = "CFLAGS=-isysroot #{MacOS.sdk_path}" - ldflags = "LDFLAGS=-isysroot #{MacOS.sdk_path}" - args << "CPPFLAGS=-I#{MacOS.sdk_path}/usr/include" # find zlib + cflags << "-isysroot #{MacOS.sdk_path}" + ldflags << "-isysroot #{MacOS.sdk_path}" + cppflags << "-I#{MacOS.sdk_path}/usr/include" # find zlib # For the Xlib.h, Python needs this header dir with the system Tk if build.without? "tcl-tk" - cflags += " -I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" + cflags << "-I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" end - args << cflags - args << ldflags end # Avoid linking to libgcc https://code.activestate.com/lists/python-dev/112195/ @@ -157,10 +159,14 @@ def install if build.with? "tcl-tk" tcl_tk = Formula["homebrew/dupes/tcl-tk"].opt_prefix - ENV.append "CPPFLAGS", "-I#{tcl_tk}/include" - ENV.append "LDFLAGS", "-L#{tcl_tk}/lib" + cppflags << "-I#{tcl_tk}/include" + ldflags << "-L#{tcl_tk}/lib" end + args << "CFLAGS=#{cflags.join(' ')}" unless cflags.empty? + args << "LDFLAGS=#{ldflags.join(' ')}" unless ldflags.empty? + args << "CPPFLAGS=#{cppflags.join(' ')}" unless cppflags.empty? + system "./configure", *args # HAVE_POLL is "broken" on OS X. See: diff --git a/Library/Formula/python3.rb b/Library/Formula/python3.rb index 580e1518ddbd..7105647d9216 100644 --- a/Library/Formula/python3.rb +++ b/Library/Formula/python3.rb @@ -109,17 +109,20 @@ def install args << "--without-gcc" if ENV.compiler == :clang + cflags = [] + ldflags = [] + cppflags = [] + unless MacOS::CLT.installed? # Help Python's build system (setuptools/pip) to build things on Xcode-only systems # The setup.py looks at "-isysroot" to get the sysroot (and not at --sysroot) - cflags = "CFLAGS=-isysroot #{MacOS.sdk_path}" - ldflags = "LDFLAGS=-isysroot #{MacOS.sdk_path}" - args << "CPPFLAGS=-I#{MacOS.sdk_path}/usr/include" # find zlib + cflags << "-isysroot #{MacOS.sdk_path}" + ldflags << "-isysroot #{MacOS.sdk_path}" + cppflags << "-I#{MacOS.sdk_path}/usr/include" # find zlib + # For the Xlib.h, Python needs this header dir with the system Tk if build.without? "tcl-tk" - cflags += " -I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" + cflags << "-I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" end - args << cflags - args << ldflags end # Avoid linking to libgcc http://code.activestate.com/lists/python-dev/112195/ args << "MACOSX_DEPLOYMENT_TARGET=#{MacOS.version}" @@ -150,10 +153,14 @@ def install if build.with? "tcl-tk" tcl_tk = Formula["tcl-tk"].opt_prefix - ENV.append "CPPFLAGS", "-I#{tcl_tk}/include" - ENV.append "LDFLAGS", "-L#{tcl_tk}/lib" + cppflags << "-I#{tcl_tk}/include" + ldflags << "-L#{tcl_tk}/lib" end + args << "CFLAGS=#{cflags.join(' ')}" unless cflags.empty? + args << "LDFLAGS=#{ldflags.join(' ')}" unless ldflags.empty? + args << "CPPFLAGS=#{cppflags.join(' ')}" unless cppflags.empty? + system "./configure", *args system "make"