2008-03-12 21:27:08 +01:00
|
|
|
# $NetBSD: rubygem.mk,v 1.7 2008/03/12 20:27:08 jlam Exp $
|
2008-03-11 21:12:17 +01:00
|
|
|
#
|
|
|
|
# This Makefile fragment is intended to be included by packages that build
|
|
|
|
# and install Ruby gems.
|
|
|
|
#
|
2008-03-12 05:06:15 +01:00
|
|
|
# Package-settable variables:
|
2008-03-11 21:12:17 +01:00
|
|
|
#
|
2008-03-12 05:06:15 +01:00
|
|
|
# GEM_NAME
|
|
|
|
# The name of the gem to install. The default value is ${DISTNAME}.
|
2008-03-11 21:12:17 +01:00
|
|
|
#
|
2008-03-12 05:06:15 +01:00
|
|
|
# GEMFILE
|
|
|
|
# The complete filename of the gem to install. It defaults to
|
|
|
|
# ${DISTNAME}.gem.
|
2008-03-11 21:12:17 +01:00
|
|
|
#
|
2008-03-12 05:06:15 +01:00
|
|
|
# Variables defined in this file:
|
2008-03-11 21:12:17 +01:00
|
|
|
#
|
2008-03-12 05:06:15 +01:00
|
|
|
# GEM_DOCDIR
|
|
|
|
# The path to the directory in the local gem repository that holds
|
|
|
|
# the documentation for the installed gem.
|
2008-03-11 21:12:17 +01:00
|
|
|
#
|
2008-03-12 05:06:15 +01:00
|
|
|
# GEM_HOME
|
|
|
|
# The path to the local gem repository.
|
2008-03-11 21:12:17 +01:00
|
|
|
#
|
2008-03-12 05:06:15 +01:00
|
|
|
# GEM_LIBDIR
|
|
|
|
# The path to the directory in the local gem repository that holds
|
|
|
|
# the contents of the installed gem.
|
2008-03-11 21:12:17 +01:00
|
|
|
#
|
2008-03-12 05:06:15 +01:00
|
|
|
# RAKE
|
|
|
|
# The path to the ``rake'' binary.
|
|
|
|
#
|
|
|
|
# RUBYGEM_PKGPREFIX
|
|
|
|
# The recommended prefix for the PKGNAME.
|
|
|
|
#
|
|
|
|
# RUBYGEM
|
|
|
|
# The path to the rubygems ``gem'' script.
|
2008-03-11 21:12:17 +01:00
|
|
|
#
|
|
|
|
|
2008-03-12 17:59:13 +01:00
|
|
|
# By default, assume that gems are capable of user-destdir installation.
|
|
|
|
PKG_DESTDIR_SUPPORT?= user-destdir
|
|
|
|
|
2008-03-11 21:12:17 +01:00
|
|
|
# Include this early in case some of its target are needed
|
|
|
|
.include "../../lang/ruby/modules.mk"
|
|
|
|
|
2008-03-12 05:06:15 +01:00
|
|
|
# Build and run-time dependencies.
|
2008-03-11 23:11:32 +01:00
|
|
|
#
|
|
|
|
# We need rubygems>=1.0.1nb1 to actually build the package, but the
|
|
|
|
# resulting installed gem can run with older versions of rubygems.
|
|
|
|
#
|
2008-03-12 05:06:15 +01:00
|
|
|
BUILD_DEPENDS+= rake-[0-9]*:../../devel/rake
|
2008-03-11 23:11:32 +01:00
|
|
|
BUILD_DEPENDS+= rubygems>=1.0.1nb1:../../misc/rubygems
|
|
|
|
DEPENDS+= rubygems>=0.8.7:../../misc/rubygems
|
|
|
|
|
|
|
|
# GEMFILE holds the filename of the Gem to install
|
|
|
|
.if defined(DISTFILES)
|
|
|
|
GEMFILE?= ${DISTFILES}
|
|
|
|
.else
|
|
|
|
GEMFILE?= ${DISTNAME}${EXTRACT_SUFX}
|
|
|
|
.endif
|
2008-03-11 21:12:17 +01:00
|
|
|
|
2008-03-12 05:06:15 +01:00
|
|
|
CATEGORIES+= ruby
|
|
|
|
MASTER_SITES?= http://gems.rubyforge.org/gems/
|
|
|
|
|
2008-03-11 21:12:17 +01:00
|
|
|
EXTRACT_SUFX?= .gem
|
|
|
|
EXTRACT_ONLY?= # empty
|
|
|
|
|
|
|
|
# Base directory for Gems
|
2008-03-11 23:11:32 +01:00
|
|
|
GEM_HOME= ${PREFIX}/lib/ruby/gems/${RUBY_VER_DIR}
|
2008-03-11 21:12:17 +01:00
|
|
|
|
|
|
|
# Directory for the Gem to install
|
|
|
|
GEM_NAME?= ${DISTNAME}
|
2008-03-11 23:11:32 +01:00
|
|
|
GEM_LIBDIR= ${GEM_HOME}/gems/${GEM_NAME}
|
|
|
|
GEM_DOCDIR= ${GEM_HOME}/doc/${GEM_NAME}
|
2008-03-11 21:12:17 +01:00
|
|
|
|
2008-03-11 23:11:32 +01:00
|
|
|
RUBYGEM_PKGPREFIX= ${RUBY_PKGPREFIX}-gem
|
2008-03-11 21:12:17 +01:00
|
|
|
|
|
|
|
# RUBYGEM holds the path to RubyGems' gem command
|
2008-03-11 23:11:32 +01:00
|
|
|
EVAL_PREFIX+= RUBYGEM_PREFIX=rubygems
|
2008-03-12 05:06:15 +01:00
|
|
|
EVAL_PREFIX+= RAKE_PREFIX=rake
|
|
|
|
RAKE= ${RAKE_PREFIX}/bin/rake
|
2008-03-11 21:12:17 +01:00
|
|
|
RUBYGEM= ${RUBYGEM_PREFIX}/bin/gem
|
|
|
|
|
|
|
|
# PLIST support
|
2008-03-11 23:11:32 +01:00
|
|
|
PLIST_SUBST+= GEM_HOME=${GEM_HOME:S|^${PREFIX}/||}
|
|
|
|
PLIST_SUBST+= GEM_LIBDIR=${GEM_LIBDIR:S|^${PREFIX}/||}
|
|
|
|
PLIST_SUBST+= GEM_DOCDIR=${GEM_DOCDIR:S|^${PREFIX}/||}
|
2008-03-11 21:12:17 +01:00
|
|
|
|
|
|
|
# print-PLIST support
|
2008-03-11 23:11:32 +01:00
|
|
|
PRINT_PLIST_AWK+= /^(@dirrm )?${GEM_LIBDIR:S|${PREFIX}/||:S|/|\\/|g}/ \
|
|
|
|
{ gsub(/${GEM_LIBDIR:S|${PREFIX}/||:S|/|\\/|g}/, "$${GEM_LIBDIR}"); print; next; }
|
|
|
|
PRINT_PLIST_AWK+= /^(@dirrm )?${GEM_DOCDIR:S|${PREFIX}/||:S|/|\\/|g}/ \
|
2008-03-12 19:53:35 +01:00
|
|
|
{ next; }
|
2008-03-11 23:11:32 +01:00
|
|
|
PRINT_PLIST_AWK+= /^@dirrm ${GEM_HOME:S|${PREFIX}/||:S|/|\\/|g}(\/(gems|cache|doc|specifications))?$$/ \
|
2008-03-11 21:12:17 +01:00
|
|
|
{ next; }
|
2008-03-12 21:27:08 +01:00
|
|
|
PRINT_PLIST_AWK+= /^@dirrm lib\/ruby\/gems$$/ { next; }
|
2008-03-11 23:11:32 +01:00
|
|
|
PRINT_PLIST_AWK+= /^(@dirrm )?${GEM_HOME:S|${PREFIX}/||:S|/|\\/|g}/ \
|
|
|
|
{ gsub(/${GEM_HOME:S|${PREFIX}/||:S|/|\\/|g}/, "$${GEM_HOME}"); print; next; }
|
2008-03-11 21:12:17 +01:00
|
|
|
|
2008-03-12 05:06:15 +01:00
|
|
|
###
|
|
|
|
### do-gem-extract
|
|
|
|
###
|
|
|
|
### The do-gem-extract target extracts a standard gem file. A standard
|
|
|
|
### gem file contains:
|
|
|
|
###
|
|
|
|
### data.tar.gz contains the actual files to build, install, etc.
|
|
|
|
### metadata.gz YAML specification file
|
|
|
|
###
|
|
|
|
.PHONY: do-gem-extract
|
|
|
|
do-extract: do-gem-extract
|
|
|
|
do-gem-extract:
|
2008-03-12 17:59:13 +01:00
|
|
|
${RUN} cd ${WRKDIR} && \
|
|
|
|
${EXTRACTOR} -f tar ${_DISTDIR:Q}/${GEMFILE:Q} data.tar.gz
|
2008-03-12 05:06:15 +01:00
|
|
|
${RUN} mkdir ${WRKSRC}
|
2008-03-12 17:59:13 +01:00
|
|
|
${RUN} cd ${WRKSRC} && \
|
|
|
|
${EXTRACTOR} -f tar ${WRKDIR:Q}/data.tar.gz
|
|
|
|
${RUN} rm -f ${WRKDIR:Q}/data.tar.gz
|
2008-03-11 21:12:17 +01:00
|
|
|
|
2008-03-12 05:06:15 +01:00
|
|
|
###
|
|
|
|
### do-gem-build
|
|
|
|
###
|
|
|
|
### The do-gem-build target builds a new local gem from the extracted
|
|
|
|
### gem's contents. The new gem as created as ${WRKSRC}/pkg/${GEMFILE}.
|
|
|
|
###
|
|
|
|
.PHONY: do-gem-build
|
|
|
|
do-build: do-gem-build
|
|
|
|
do-gem-build:
|
|
|
|
${RUN} cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${RAKE} gem
|
|
|
|
|
|
|
|
###
|
|
|
|
### do-gem-install
|
|
|
|
###
|
|
|
|
### The do-gem-install target installs the local gem in ${WRKDIR} into
|
2008-03-12 17:59:13 +01:00
|
|
|
### the gem repository. We this this as a staged installation
|
|
|
|
### (independent of PKG_DESTDIR_SUPPORT) because it can potentially
|
|
|
|
### build software and we want that to happen within ${WRKDIR}.
|
2008-03-12 05:06:15 +01:00
|
|
|
###
|
2008-03-12 17:59:13 +01:00
|
|
|
_RUBYGEM_BUILDROOT= ${WRKDIR}/.inst
|
|
|
|
_RUBYGEM_OPTIONS= --no-update-sources # don't cache the gem index
|
|
|
|
_RUBYGEM_OPTIONS+= --install-dir ${GEM_HOME}
|
|
|
|
_RUBYGEM_OPTIONS+= --build-root ${_RUBYGEM_BUILDROOT}
|
|
|
|
_RUBYGEM_OPTIONS+= --local ${WRKSRC}/pkg/${GEMFILE}
|
|
|
|
_RUBYGEM_OPTIONS+= -- --build-args ${CONFIGURE_ARGS}
|
|
|
|
|
|
|
|
GENERATE_PLIST+= ${RUBYGEM_GENERATE_PLIST}
|
|
|
|
RUBYGEM_GENERATE_PLIST= \
|
|
|
|
${ECHO} "@comment The following lines are automatically generated." && \
|
|
|
|
( cd ${_RUBYGEM_BUILDROOT}${PREFIX} && \
|
|
|
|
${FIND} ${GEM_DOCDIR:S|${PREFIX}/||} \! -type d -print | \
|
|
|
|
${SORT} && \
|
|
|
|
${FIND} ${GEM_DOCDIR:S|${PREFIX}/||} -type d -print | \
|
|
|
|
${SORT} -r | ${SED} -e "s,^,@dirrm ," );
|
|
|
|
|
|
|
|
|
2008-03-12 05:06:15 +01:00
|
|
|
.PHONY: do-gem-install
|
2008-03-11 21:12:17 +01:00
|
|
|
do-install: do-gem-install
|
2008-03-12 05:06:15 +01:00
|
|
|
do-gem-install:
|
2008-03-12 17:59:13 +01:00
|
|
|
@${STEP_MSG} "Installing gem into buildroot"
|
|
|
|
${RUN} ${SETENV} ${INSTALL_ENV} ${MAKE_ENV} \
|
|
|
|
${RUBYGEM} install ${_RUBYGEM_OPTIONS}
|
2008-03-12 21:08:22 +01:00
|
|
|
${RUN} if [ -d ${_RUBYGEM_BUILDROOT}${GEM_LIBDIR}/ext ]; then \
|
|
|
|
cd ${_RUBYGEM_BUILDROOT}${GEM_LIBDIR}/ext && ls | \
|
|
|
|
while read file; do \
|
|
|
|
if [ ! -f ${WRKSRC}/ext/$$file ]; then \
|
|
|
|
echo "rm "${GEM_LIBDIR:T}"/ext/$$file"; \
|
|
|
|
rm -f $$file; \
|
|
|
|
fi; \
|
|
|
|
done; \
|
|
|
|
fi
|
2008-03-12 17:59:13 +01:00
|
|
|
@${STEP_MSG} "Copying files into installation directory"
|
|
|
|
${RUN} cd ${_RUBYGEM_BUILDROOT}${PREFIX} && \
|
|
|
|
pax -rwpe . ${DESTDIR}${PREFIX}
|