Skip to content

Commit

Permalink
subversion: make perl/ruby/python bindings build.
Browse files Browse the repository at this point in the history
Need to filter out CPPFLAGS that confuse swig, see Homebrew#23993.
  • Loading branch information
andrewdotn committed Jan 26, 2014
1 parent 1fd87b5 commit bc9f1ef
Showing 1 changed file with 108 additions and 1 deletion.
109 changes: 108 additions & 1 deletion Library/Formula/subversion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ class Subversion < Formula
# If building bindings, allow non-system interpreters
env :userpaths if build.include? 'perl' or build.include? 'ruby'

# Prevent '-arch ppc' from being pulled in from Perl's $Config{ccflags}
# 1. Prevent '-arch ppc' from being pulled in from Perl's $Config{ccflags}
# 2. Backport r1535610 to help fix #23993.
# See http://subversion.tigris.org/issues/show_bug.cgi?id=4465
# 3. Fix #23993 by stripping flags swig can't handle from SWIG_CPPFLAGS
def patches
{ :p0 => DATA }
end
Expand Down Expand Up @@ -149,6 +152,11 @@ def install
system "make tools"
system "make install-tools"

# Swig don't understand "-isystem" flags added by Homebrew, so
# filter them out.
#inreplace buildpath/"build-outputs.mk", /SWIG_CPPFLAGS/,
# "$(filter-out -F/% -isystem/%,$(SWIG_CPPFLAGS))"

if build.with? 'python'
system "make swig-py"
system "make install-swig-py"
Expand Down Expand Up @@ -235,6 +243,9 @@ def caveats
end

__END__

Patch 1

--- subversion/bindings/swig/perl/native/Makefile.PL.in~ 2013-06-20 18:58:55.000000000 +0200
+++ subversion/bindings/swig/perl/native/Makefile.PL.in 2013-06-20 19:00:49.000000000 +0200
@@ -69,10 +69,15 @@
Expand All @@ -255,3 +266,99 @@ def caveats
" -I$swig_srcdir/perl/libsvn_swig_perl",
" -I$svnlib_srcdir/include",

Patch 2

$ svn log -v -r1535610 --diff http://svn.apache.org/repos/asf/subversion/trunk
------------------------------------------------------------------------
r1535610 | breser | 2013-10-24 20:22:50 -0600 (Thu, 24 Oct 2013) | 20 lines
Changed paths:
M /subversion/trunk/Makefile.in
M /subversion/trunk/build.conf
M /subversion/trunk/configure.ac

Filter out -no-cpp-precomp from flags passed to SWIG.

This is necessary since APR for whatever reason leaks the fact that it uses
-no-cpp-precomp on OS X into apr-1-config. Unfortunately, a lot of versions
of APR have this in the wild so we just have to deal with it. If you use clang
directly you don't see this because we already filter it out of CPPFLAGS.

* Makefile.in
(SWIG_CPPFLAGS): New variable, deliberately pulling in EXTRA_CPPFLAGS and
not EXTRA_SIWG_CPPFLAGS because it would be harmful to split those
(e.g. users wanting to enable a feature that adds an API).

* build.conf
(swig-python-opts, swig-perl-opts, swig-ruby-opts): Use SWIG_CPPFLAGS
instead of CPPFLAGS.

* configure.acc
(SWIG_CPPFLAGS): Add the variable and copy it from the normal CPPFLAGS
while filtering out the -no-cpp-precomp.


Index: Makefile.in
===================================================================
--- Makefile.in (revision 1535609)
+++ Makefile.in (revision 1535610)
@@ -181,6 +181,7 @@
CPPFLAGS = @CPPFLAGS@ $(EXTRA_CPPFLAGS)
LDFLAGS = @LDFLAGS@ $(EXTRA_LDFLAGS)
SWIG_LDFLAGS = @SWIG_LDFLAGS@ $(EXTRA_SWIG_LDFLAGS)
+SWIG_CPPFLAGS = @SWIG_CPPFLAGS@ $(EXTRA_CPPFLAGS)

COMPILE = $(CC) $(CMODEFLAGS) $(CPPFLAGS) $(CMAINTAINERFLAGS) $(CFLAGS) $(INCLUDES)
COMPILE_NOWARN = $(CC) $(CMODEFLAGS) $(CPPFLAGS) $(CNOWARNFLAGS) $(CFLAGS) $(INCLUDES)
Index: build.conf
===================================================================
--- build.conf (revision 1535609)
+++ build.conf (revision 1535610)
@@ -88,9 +88,9 @@

bdb-test-scripts =

-swig-python-opts = $(CPPFLAGS) -python -classic
-swig-perl-opts = $(CPPFLAGS) -perl -nopm -noproxy
-swig-ruby-opts = $(CPPFLAGS) -ruby
+swig-python-opts = $(SWIG_CPPFLAGS) -python -classic
+swig-perl-opts = $(SWIG_CPPFLAGS) -perl -nopm -noproxy
+swig-ruby-opts = $(SWIG_CPPFLAGS) -ruby
swig-languages = python perl ruby
swig-dirs =
subversion/bindings/swig/python
Index: configure.ac
===================================================================
--- configure.ac (revision 1535609)
+++ configure.ac (revision 1535610)
@@ -1490,6 +1490,11 @@
SVN_STRIP_FLAG(CPPFLAGS, [-no-cpp-precomp ])
fi

+# Need to strip '-no-cpp-precomp' from CPPFLAGS for SWIG as well.
+SWIG_CPPFLAGS="$CPPFLAGS"
+SVN_STRIP_FLAG(SWIG_CPPFLAGS, [-no-cpp-precomp ])
+AC_SUBST([SWIG_CPPFLAGS])
+
dnl Since this is used only on Unix-y systems, define the path separator as '/'
AC_DEFINE_UNQUOTED(SVN_PATH_LOCAL_SEPARATOR, '/',
[Defined to be the path separator used on your local filesystem])

------------------------------------------------------------------------

Patch 3

diff -u configure.ac configure.ac
--- configure.ac (working copy)
+++ configure.ac (working copy)
@@ -1446,6 +1446,10 @@
# Need to strip '-no-cpp-precomp' from CPPFLAGS for SWIG as well.
SWIG_CPPFLAGS="$CPPFLAGS"
SVN_STRIP_FLAG(SWIG_CPPFLAGS, [-no-cpp-precomp ])
+# Swig don't understand "-F" and "-isystem" flags added by Homebrew,
+# so filter them out.
+SVN_STRIP_FLAG(SWIG_CPPFLAGS, [-F\/[[^ ]]* ])
+SVN_STRIP_FLAG(SWIG_CPPFLAGS, [-isystem\/[[^ ]]* ])
AC_SUBST([SWIG_CPPFLAGS])

dnl Since this is used only on Unix-y systems, define the path separator as '/'

2 comments on commit bc9f1ef

@brainy
Copy link

@brainy brainy commented on bc9f1ef Jan 26, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me. Only one nit: would be nice to adjust the patches from trunk so that they apply cleanly to Subversion 1.8.x, without the fuzz and offset.

==> Patching
patching file subversion/bindings/swig/perl/native/Makefile.PL.in
patching file Makefile.in
Hunk #1 succeeded at 177 with fuzz 1 (offset -4 lines).
patching file build.conf
Hunk #1 succeeded at 71 (offset -17 lines).
patching file configure.ac
Hunk #1 succeeded at 1443 (offset -47 lines).
patching file configure.ac

@andrewdotn
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here’s a patch for the patch if you want to make the patch apply cleanly:

diff --git a/Library/Formula/subversion.rb b/Library/Formula/subversion.rb
index d643d10..abb232d 100644
--- a/Library/Formula/subversion.rb
+++ b/Library/Formula/subversion.rb
@@ -264,6 +264,7 @@ Patch 1
 Patch 2

 $  svn log -v -r1535610 --diff http://svn.apache.org/repos/asf/subversion/trunk
+   (then manually rebasing patch to tags/1.8.5)
 ------------------------------------------------------------------------
 r1535610 | breser | 2013-10-24 20:22:50 -0600 (Thu, 24 Oct 2013) | 20 lines
 Changed paths:
@@ -294,21 +295,21 @@ directly you don't see this because we already filter it out of CPPFLAGS.

 Index: Makefile.in
 ===================================================================
---- Makefile.in    (revision 1535609)
-+++ Makefile.in    (revision 1535610)
-@@ -181,6 +181,7 @@
+--- Makefile.in    (revision 1561509)
++++ Makefile.in    (working copy)
+@@ -177,6 +177,7 @@
  CPPFLAGS = @CPPFLAGS@ $(EXTRA_CPPFLAGS)
  LDFLAGS = @LDFLAGS@ $(EXTRA_LDFLAGS)
  SWIG_LDFLAGS = @SWIG_LDFLAGS@ $(EXTRA_SWIG_LDFLAGS)
 +SWIG_CPPFLAGS = @SWIG_CPPFLAGS@ $(EXTRA_CPPFLAGS)

  COMPILE = $(CC) $(CMODEFLAGS) $(CPPFLAGS) $(CMAINTAINERFLAGS) $(CFLAGS) $(INCLUDES)
- COMPILE_NOWARN = $(CC) $(CMODEFLAGS) $(CPPFLAGS) $(CNOWARNFLAGS) $(CFLAGS) $(INCLUDES)
+ COMPILE_CXX = $(CXX) $(CXXMODEFLAGS) $(CPPFLAGS) $(CXXMAINTAINERFLAGS) $(CXXFLAGS) $(INCLUDES)
 Index: build.conf
 ===================================================================
---- build.conf (revision 1535609)
-+++ build.conf (revision 1535610)
-@@ -88,9 +88,9 @@
+--- build.conf (revision 1561509)
++++ build.conf (working copy)
+@@ -71,9 +71,9 @@

  bdb-test-scripts =

@@ -323,9 +324,9 @@ Index: build.conf
          subversion/bindings/swig/python
 Index: configure.ac
 ===================================================================
---- configure.ac   (revision 1535609)
-+++ configure.ac   (revision 1535610)
-@@ -1490,6 +1490,11 @@
+--- configure.ac   (revision 1561509)
++++ configure.ac   (working copy)
+@@ -1443,6 +1443,11 @@
    SVN_STRIP_FLAG(CPPFLAGS, [-no-cpp-precomp ])
  fi

Please sign in to comment.