Makefile.libsubversion   [plain text]


RBLIBDIR = $(shell ruby -r mkmf -e 'puts Config.expand($$libdir)')

GnuAfterInstall       = perl-bindings python-bindings ruby-bindings \
                        post-install install-plist
Extra_Configure_Flags = --enable-shared --disable-static \
                        --without-berkeley-db \
                        --with-apxs --disable-mod-activation \
                        --with-apr=$(APR_TOOLCHAIN_DIR) \
                        --with-apr-util=$(APR_TOOLCHAIN_DIR) \
                        --with-neon=/usr/local \
                        --with-swig=$(shell test -e /usr/bin/swig && echo /usr || echo /usr/local) \
                        --with-ruby-sitedir=$(RBLIBDIR)/ruby \
                        --without-sasl

include $(MAKEFILEPATH)/CoreOS/ReleaseControl/GNUSource.make

Install_Target  = install
Install_Flags   = DESTDIR=$(DSTROOT)

# multi-version support
VERSIONERDIR := /usr/local/versioner

#-------------------------------------------------------------------------
# Patch subversion's Makefile and Makefile.PL just after running configure
#
# In Makefile, we need to change the include path to the correct version
# of perl and python, and we need to force the libsvn_swig_perl and
# libsvn_swig_py dylibs to be installed in a version-specific place, so
# each version of perl and python has its own dylib.  The install name
# of these dylibs are set to the correct version-specific places, by defining
# a new macro, LINKVERS in Makefile.in, which uses the environment variable
# RPATHVERS (defined in "for" loops below) as the value to libtool's
# -rpath argument.
#
# For Makefile.PL, we need to remove -L/usr/lib, which is always first,
# and will cause the bundles to link against the libsvn_swig_perl dylib
# in /usr/lib, instead of the version-specific place (in the DSTROOT).
# This really only matters during the transition to the version-specific
# place, while the BuildRoot still contains libsvn_swig_perl in /usr/lib
# (it will eventually be cleaned out in a world build).
#-------------------------------------------------------------------------
ConfigStamp2 = $(ConfigStamp)2

configure:: $(ConfigStamp2)

PERLVERS := $(shell perl -MConfig -e 'print $$Config::Config{version}')
PYTHONVERS := $(shell python -c 'import sys; print("%d.%d" % sys.version_info[:2])')
MAKEFILEPL := subversion/bindings/swig/perl/native/Makefile.PL
$(ConfigStamp2): $(ConfigStamp)
	mv '$(BuildDirectory)/Makefile' '$(BuildDirectory)/Makefile.bak'
	sed -e '/^SWIG_PL_INCLUDES/s/$(PERLVERS)/$$(VERSIONER_PERL_VERSION)/g' \
	    -e '/^SWIG_PY_INCLUDES/s/$(PYTHONVERS)/$$(VERSIONER_PYTHON_VERSION)/g' \
	    -e '/^swig_py_libdir/s,$${exec_prefix}/lib,$${RPATHVERS},' \
	    -e '/^swig_pl_libdir/s,$${exec_prefix}/lib,$${RPATHVERS},' \
	    '$(BuildDirectory)/Makefile.bak' > '$(BuildDirectory)/Makefile'
	mv '$(BuildDirectory)/$(MAKEFILEPL)' '$(BuildDirectory)/$(MAKEFILEPL).bak'
	sed 's,-L/usr/lib,,' '$(BuildDirectory)/$(MAKEFILEPL).bak' > '$(BuildDirectory)/$(MAKEFILEPL)'
	$(TOUCH) $(ConfigStamp2)

# Perl multi-version support
PERLVERSIONS := $(VERSIONERDIR)/perl/versions
PERLSUBDEFAULT := $(shell sed -n '/^DEFAULT = /s///p' $(PERLVERSIONS))
PERLDEFAULT := $(shell grep '^$(PERLSUBDEFAULT)' $(PERLVERSIONS))
PERLUNORDEREDVERS := $(shell grep -v '^DEFAULT' $(PERLVERSIONS))
# do default version last
PERLORDEREDVERS := $(filter-out $(PERLDEFAULT),$(PERLUNORDEREDVERS)) $(PERLDEFAULT)
PERLTOPDIR := $(BuildDirectory)/subversion/bindings/swig/perl
PERLTOPDIRORIG := $(PERLTOPDIR).orig

perl-bindings:
	mv $(PERLTOPDIR) $(PERLTOPDIRORIG)
	@set -x && \
	cd $(BuildDirectory) && \
	for vers in $(PERLORDEREDVERS); do \
	    export VERSIONER_PERL_VERSION=$${vers} && \
	    installarchlib=`perl -MConfig -e 'print $$Config::Config{installarchlib}' | sed 's,Perl,Perl/Extras,'` && \
	    installprivlib=`perl -MConfig -e 'print $$Config::Config{installprivlib}' | sed 's,Perl,Perl/Extras,'` && \
	    installbin=$${installprivlib}/bin && \
	    PLARGS="INSTALLDIRS=perl INSTALLARCHLIB='$${installarchlib}' INSTALLPRIVLIB='$${installprivlib}' INSTALLBIN='$${installbin}' INSTALLSCRIPT='$${installbin}'" && \
	    MAKEARGS="$(Extra_Make_Flags) DESTDIR='$(DSTROOT)'" && \
	    export RPATHVERS="$${installarchlib}/lib" && \
	    ditto $(PERLTOPDIRORIG) $(PERLTOPDIR) && \
	    make swig-pl PLARGS="$${PLARGS}" MAKEARGS="$${MAKEARGS}" ARCHFLAGS="$(RC_CFLAGS)" && \
	    make install-swig-pl PLARGS="$${PLARGS}" MAKEARGS="$${MAKEARGS}" DESTDIR="$(DSTROOT)" && \
	    for module in Client Core Delta Fs Ra Repos Wc; do\
		    $(CP) $(DSTROOT)$${installarchlib}/auto/SVN/_$${module}/_$${module}.bundle $(SYMROOT) && \
		    $(STRIP) -x $(DSTROOT)$${installarchlib}/auto/SVN/_$${module}/_$${module}.bundle && \
		    $(CODESIGN) $(DSTROOT)$${installarchlib}/auto/SVN/_$${module}/_$${module}.bundle && \
		    $(RM) $(DSTROOT)$${installarchlib}/auto/SVN/_$${module}/_$${module}.bs || exit 1; \
	    done && \
	    $(RM) $(DSTROOT)$${installarchlib}/perllocal.pod && \
	    mv $(PERLTOPDIR) $(PERLTOPDIR).$${vers} || exit 1; \
	done

# Python multi-version support
PYTHONVERSIONS := $(VERSIONERDIR)/python/versions
PYTHONDEFAULT := $(shell sed -n '/^DEFAULT = /s///p' $(PYTHONVERSIONS))
# ignore 3.0 for now
PYTHONIGNORE := 3.0
PYTHONUNORDEREDVERS := $(filter-out $(PYTHONIGNORE),$(shell grep -v '^DEFAULT' $(PYTHONVERSIONS)))
# do default version last
PYTHONORDEREDVERS := $(filter-out $(PYTHONDEFAULT),$(PYTHONUNORDEREDVERS)) $(PYTHONDEFAULT)
PYTHONTOPDIR := $(BuildDirectory)/subversion/bindings/swig/python
PYTHONTOPDIRORIG := $(PYTHONTOPDIR).orig

python-bindings:
	mv $(PYTHONTOPDIR) $(PYTHONTOPDIRORIG)
	@set -x && \
	cd $(BuildDirectory) && \
	for vers in $(PYTHONORDEREDVERS); do \
	    export VERSIONER_PYTHON_VERSION=$${vers} && \
	    export RPATHVERS=`python -c 'import sys; print sys.prefix'`/Extras/lib && \
	    PYTHONLIBDIR=$${RPATHVERS}/python && \
	    PYDIR=$${PYTHONLIBDIR}/libsvn && \
	    PYDIR_EXTRA=$${PYTHONLIBDIR}/svn && \
	    ditto $(PYTHONTOPDIRORIG) $(PYTHONTOPDIR) && \
	    make $(Extra_Make_Flags) swig-py && \
	    make $(Extra_Make_Flags) install-swig-py swig_pydir="$${PYDIR}" swig_pydir_extra="$${PYDIR_EXTRA}" DESTDIR="$(DSTROOT)" && \
	    for module in client core delta diff fs ra repos wc; do \
		    $(CP) $(DSTROOT)$${PYDIR}/_$${module}.so $(SYMROOT) && \
		    $(STRIP) -x $(DSTROOT)$${PYDIR}/_$${module}.so && \
		    $(CODESIGN) $(DSTROOT)$${PYDIR}/_$${module}.so || exit 1; \
	    done && \
	    mv $(PYTHONTOPDIR) $(PYTHONTOPDIR).$${vers} || exit 1; \
	done

# Ruby stuff
RBARCHDIR = $(shell ruby -r mkmf -e 'puts Config.expand($$archdir)')

ruby-bindings:
	cd $(BuildDirectory) && make $(Extra_Make_Flags) swig-rb
	cd $(BuildDirectory) && make $(Extra_Make_Flags) install-swig-rb DESTDIR=$(DSTROOT)
	@for module in client core delta diff fs ra repos wc; do \
		$(CP) $(DSTROOT)$(RBARCHDIR)/svn/ext/$${module}.bundle $(SYMROOT); \
		$(STRIP) -x $(DSTROOT)$(RBARCHDIR)/svn/ext/$${module}.bundle; \
		$(CODESIGN) $(DSTROOT)$(RBARCHDIR)/svn/ext/$${module}.bundle; \
	done

LIBEXECDIR = $(shell apxs -q LIBEXECDIR)

# Post-install cleanup
post-install:
	[ -n "$(DSTROOT)" ] || exit 1
	rm -rf $(DSTROOT)/usr/bin
	rm -rf $(DSTROOT)/usr/share/man/man1
	rm -rf $(DSTROOT)/usr/share/man/man5
	rm -rf $(DSTROOT)/usr/share/man/man8
	@set -x && \
	for library in `find $(DSTROOT) -type f -name \*.dylib`; do \
		$(CP) $${library} $(SYMROOT) && \
		$(STRIP) -x $${library} && \
		$(CODESIGN) $${library} || exit 1; \
	done
	find $(DSTROOT) -name \*.la -delete
	find $(DSTROOT)/System/Library/Perl -name .packlist -delete
	@for module in authz dav; do \
		$(CP) $(DSTROOT)$(LIBEXECDIR)/mod_$${module}_svn.so $(SYMROOT); \
		$(STRIP) -x $(DSTROOT)$(LIBEXECDIR)/mod_$${module}_svn.so; \
		$(CODESIGN) $(DSTROOT)$(LIBEXECDIR)/mod_$${module}_svn.so; \
	done