Tweak biology/seqan version 1.3.1_3
[dports.git] / Mk / bsd.ruby.mk
1 #
2 # bsd.ruby.mk - Utility definitions for Ruby related ports.
3 #
4 # Created by: Akinori MUSHA <knu@FreeBSD.org>
5 #
6 # $FreeBSD$
7 #
8
9 .if !defined(Ruby_Include)
10
11 Ruby_Include=                   bsd.ruby.mk
12 Ruby_Include_MAINTAINER=        ruby@FreeBSD.org
13
14 #
15 # [variables that a user may define]
16 #
17 # RUBY_VER              - (See below)
18 # RUBY_DEFAULT_VER      - Set to (e.g.) "2.0" if you want to refer to "ruby20"
19 #                         just as "ruby".
20 # RUBY_ARCH             - (See below)
21 # RUBY_RD_HTML          - Define if you want HTML files generated from RD files.
22 #
23 #
24 # [variables that each port can define]
25 #
26 # RUBY                  - Set to full path of ruby.  If you set this, the values
27 #                         of the following variables are automatically obtained
28 #                         from the ruby executable: RUBY_VER, RUBY_VERSION,
29 #                         RUBY_NAME, RUBY_ARCH, RUBY_LIBDIR, RUBY_ARCHLIBDIR,
30 #                         RUBY_SITELIBDIR, and RUBY_SITEARCHLIBDIR.
31 # RUBY_VER              - Set to the alternative short version of ruby in the
32 #                         form of `x.y' (see below for current value).
33 # USE_RUBY              - Says that the port uses ruby for building and running.
34 # RUBY_NO_BUILD_DEPENDS - Says that the port should not build-depend on ruby.
35 # RUBY_NO_RUN_DEPENDS   - Says that the port should not run-depend on ruby.
36 # USE_LIBRUBY           - Says that the port uses libruby.
37 # USE_RUBY_EXTCONF      - Says that the port uses extconf.rb to configure.
38 #                         Implies USE_RUBY.
39 # RUBY_EXTCONF          - Set to the alternative name of extconf.rb
40 #                         (default: extconf.rb).
41 # RUBY_EXTCONF_SUBDIRS  - Set to list of subdirectories, if multiple modules
42 #                         are included.
43 # USE_RUBY_SETUP        - Says that the port uses setup.rb to configure and
44 #                         build.
45 # RUBY_SETUP            - Set to the alternative name of setup.rb
46 #                         (default: setup.rb).
47 # USE_RUBY_RDTOOL       - Says that the port uses rdtool to generate documents.
48 # USE_RUBY_RDOC         - Says that the port uses rdoc to generate documents.
49 # RUBY_REQUIRE          - Set to a Ruby expression to evaluate before building
50 #                         the port.  The constant "Ruby" is set to the integer
51 #                         version number of ruby, and the result of the
52 #                         expression will be set to RUBY_PROVIDED, which is
53 #                         left undefined if the result is nil, false or a
54 #                         zero-length string.  Implies USE_RUBY.
55 # RUBY_SHEBANG_FILES    - Specify the files which shebang lines you want to fix.
56 # RUBY_RD_FILES         - Specify the RD files which you want to generate HTML
57 #                         documents from. If this is defined and not empty,
58 #                         USE_RUBY_RDTOOL is implied and RUBY_RD_HTML_FILES is
59 #                         defined.
60 # USE_RUBYGEMS          - Says that the port uses rubygems packaging system.
61 # RUBYGEM_AUTOPLIST     - Generate packing list for rubygems based port
62 #                         automatically.
63 #
64 #
65 # [variables that each port should not (re)define]
66 #
67 # RUBY_PKGNAMEPREFIX    - Common PKGNAMEPREFIX for ruby ports
68 #                         (default: ruby${RUBY_SUFFIX}-)
69 # RUBY_RELVERSION       - Full version of ruby without preview/beta suffix in
70 #                         the form of `x.y.z' (see below for current value).
71 # RUBY_RELVERSION_CODE  - Integer version of RUBY_RELVERSION in the form of
72 #                         `xyz'.
73 # RUBY_VERSION          - Composite version of RUBY_RELVERSION and
74 #                         RUBY_PATCHLEVEL in the form of `x.y.z.p'.
75 #                         (default: ${RUBY_RELVERSION}.${RUBY_PATCHLEVEL})
76 # RUBY_VERSION_CODE     - Composite integer version of RUBY_VERSION in the form
77 #                         of `xyzp'.
78 # RUBY_PORTVERSION      - PORTVERSION for the standard ruby ports (ruby,
79 #                         ruby-gdbm, etc.).
80 # RUBY_PORTREVISION     - PORTREVISION for the standard ruby ports.
81 # RUBY_PORTEPOCH        - PORTEPOCH for the standard ruby ports.
82 # RUBY_DISTNAME         - DISTNAME for the standard ruby ports, i.e. the
83 #                         basename of the ruby distribution tarball.
84 # RUBY_DISTVERSION      - The version number part of RUBY_DISTNAME.
85 # RUBY_PATCHFILES       - PATCHFILES for the standard ruby ports, i.e. the
86 #                         basename of the ruby distribution tarball.
87 # RUBY_WRKSRC           - WRKSRC for the ruby port.
88 # MASTER_SITE_SUBDIR_RUBY       - MASTER_SITE_SUBDIR for the ruby distfiles.
89 #
90 # RUBY_SHLIBVER         - Major version of libruby (see below for current
91 #                         value).
92 # RUBY_ARCH             - Set to target architecture name.
93 #                         (e.g. i386-freebsd7)
94 # RUBY_SUFFIX           - Suffix for ruby binaries and directories
95 #                         (${RUBY_VER:S/.//}).
96 # RUBY_WITHOUT_SUFFIX   - Always ${LOCALBASE}/bin/ruby.
97 # RUBY_WITH_SUFFIX      - Always ${RUBY_WITHOUT_SUFFIX}${RUBY_SUFFIX}.
98 # RUBY_NAME             - Ruby's name with trailing suffix.
99 #
100 # RUBY_MODNAME          - Set to the module name (default: ${PORTNAME}).
101 #
102 # RUBY_RD2              - Full path of rd2 executable.
103 # RUBY_RDOC             - Full path of rdoc executable.
104 #
105 # RUBY_BASE_PORT        - Port path of base ruby without PORTSDIR, without
106 #                         suffix except version.
107 # RUBY_PORT             - Port path of ruby without PORTSDIR.
108 # RUBY_RDTOOL_PORT      - Port path of rdtool without PORTSDIR.
109 # RUBY_RDOC_PORT        - Port path of rdoc without PORTSDIR.
110 #
111 # DEPEND_LIBRUBY        - LIB_DEPENDS entry for libruby.
112 # DEPEND_RUBY           - BUILD_DEPENDS/RUN_DEPENDS entry for ruby.
113 # DEPEND_RUBY_RDTOOL    - BUILD_DEPENDS entry for rdtool.
114 # DEPEND_RUBY_RDOC      - BUILD_DEPENDS entry for rdoc.
115 #
116 # RUBY_LIBDIR           - Installation path for architecture independent
117 #                         libraries.
118 # RUBY_ARCHLIBDIR       - Installation path for architecture dependent
119 #                         libraries.
120 # RUBY_SITELIBDIR       - Installation path for site architecture independent
121 #                         libraries.
122 # RUBY_SITEARCHLIBDIR   - Installation path for site architecture dependent
123 #                         libraries.
124 # RUBY_DOCDIR           - Installation path for documents.
125 # RUBY_EXAMPLESDIR      - Installation path for examples.
126 # RUBY_RIDIR            - Installation path for site architecture independent ri
127 #                         documents.
128 # RUBY_SITERIDIR        - Installation path for site architecture dependent ri
129 #                         documents.
130 # RUBY_MODDOCDIR        - Installation path for the module's documents.
131 # RUBY_MODEXAMPLESDIR   - Installation path for the module's examples.
132 # RUBY_ELISPDIR         - Installation path for emacs lisp files.
133 #
134
135 .include "${PORTSDIR}/Mk/bsd.default-versions.mk"
136
137 .if defined(RUBY_DEFAULT_VER)
138 WARNING+=       "RUBY_DEFAULT_VER is defined, consider using DEFAULT_VERSIONS=ruby=${RUBY_DEFAULT_VER} instead"
139 .endif
140
141 RUBY_DEFAULT_VER?=      ${RUBY_DEFAULT}
142
143 RUBY_VER?=              ${RUBY_DEFAULT_VER}
144
145 .if defined(RUBY)
146 .if !exists(${RUBY})
147 IGNORE= cannot install: you set the variable RUBY to "${RUBY}", but it does not seem to exist.  Please specify an already installed ruby executable.
148 .endif
149
150 _RUBY_TEST!=            ${RUBY} -e 'begin; require "rbconfig"; puts "ok" ; rescue LoadError; puts "error"; end'
151 .if !empty(_RUBY_TEST) && ${_RUBY_TEST} != "ok"
152 IGNORE= cannot install: you set the variable RUBY to "${RUBY}", but it failed to include rbconfig.  Please specify a properly installed ruby executable.
153 .endif
154
155 _RUBY_CONFIG=           ${RUBY} -r rbconfig -e 'C = RbConfig::CONFIG' -e
156
157 RUBY_VERSION!=          ${_RUBY_CONFIG} 'puts C["ruby_version"]'
158 RUBY_SUFFIX?=           # empty
159
160 RUBY_ARCH!=             ${_RUBY_CONFIG} 'puts C["target"]'
161 RUBY_NAME!=             ${_RUBY_CONFIG} 'puts C["ruby_install_name"]'
162
163 _RUBY_SYSLIBDIR!=       ${_RUBY_CONFIG} 'puts C["libdir"]'
164 _RUBY_SITEDIR!=         ${_RUBY_CONFIG} 'puts C["sitedir"]'
165 _RUBY_VENDORDIR!=       ${_RUBY_CONFIG} 'puts C["vendordir"]'
166 .else
167 RUBY?=                  ${LOCALBASE}/bin/${RUBY_NAME}
168
169 .if defined(RUBY_VER)
170 . if ${RUBY_VER} == 2.0
171 #
172 # Ruby 2.0
173 #
174 RUBY_RELVERSION=        2.0.0
175 RUBY_PORTREVISION=      0
176 RUBY_PORTEPOCH=         1
177 RUBY_PATCHLEVEL=        643
178 RUBY20=                 ""      # PLIST_SUB helpers
179
180 . elif ${RUBY_VER} == 2.1
181 #
182 # Ruby 2.1
183 #
184 RUBY_RELVERSION=        2.1.5
185 RUBY_PORTREVISION=      2
186 RUBY_PORTEPOCH=         1
187 RUBY_PATCHLEVEL=        0
188 RUBY21=                 ""      # PLIST_SUB helpers
189
190 . elif ${RUBY_VER} == 2.2
191 #
192 # Ruby 2.2
193 #
194 RUBY_RELVERSION=        2.2.1
195 RUBY_PORTREVISION=      0
196 RUBY_PORTEPOCH=         1
197 RUBY_PATCHLEVEL=        0
198 RUBY22=                 ""      # PLIST_SUB helpers
199
200 . else
201 #
202 # Other versions
203 #
204 IGNORE= Only ruby 2.0, 2.1 and 2.2 are supported
205 . endif
206 .endif # defined(RUBY_VER)
207
208 RUBY20?=                "@comment "
209 RUBY21?=                "@comment "
210 RUBY22?=                "@comment "
211
212 .if ${RUBY_PATCHLEVEL} == 0
213 RUBY_VERSION?=          ${RUBY_RELVERSION}
214 RUBY_DISTVERSION?=      ${RUBY_RELVERSION}
215 .else
216 RUBY_VERSION?=          ${RUBY_RELVERSION}.${RUBY_PATCHLEVEL}
217 RUBY_DISTVERSION?=      ${RUBY_RELVERSION}-p${RUBY_PATCHLEVEL}
218 .endif
219
220 RUBY_WRKSRC=            ${WRKDIR}/ruby-${RUBY_DISTVERSION}
221
222 RUBY_CONFIGURE_ARGS+=   --with-rubyhdrdir="${PREFIX}/include/ruby-${RUBY_VER}/" \
223                         --with-rubylibprefix="${PREFIX}/lib/ruby" \
224                         --docdir="${RUBY_DOCDIR}" \
225                         --with-soname=ruby${RUBY_SUFFIX}
226
227 CONFIGURE_TARGET?=      ${ARCH}-portbld-${OPSYS:tl}${OSREL:C/\..*//}
228
229 RUBY_ARCH?=             ${ARCH}-${OPSYS:tl}${OSREL:C/\..*//}
230 RUBY_NAME?=             ruby${RUBY_SUFFIX}
231
232 _RUBY_SYSLIBDIR?=       ${PREFIX}/lib
233 _RUBY_SITEDIR?=         ${_RUBY_SYSLIBDIR}/ruby/site_ruby
234 _RUBY_VENDORDIR?=       ${_RUBY_SYSLIBDIR}/ruby/vendor_ruby
235 .endif
236 #      defined(RUBY)
237
238 .if defined(LANG) && !empty(LANG)
239 GEM_ENV+=               LANG=${LANG}
240 .else
241 GEM_ENV+=               LANG=en_US.UTF-8
242 .endif
243
244 .if defined(LC_ALL) && !empty(LC_ALL)
245 GEM_ENV+=               LC_ALL=${LC_ALL}
246 .else
247 GEM_ENV+=               LC_ALL=en_US.UTF-8
248 .endif
249
250 .if defined(LC_CTYPE) && !empty(LC_CTYPE)
251 GEM_ENV+=               LC_CTYPE=${LC_CTYPE}
252 .else
253 GEM_ENV+=               LC_CTYPE=UTF-8
254 .endif
255
256 RUBY_DEFAULT_SUFFIX?=   ${RUBY_DEFAULT_VER:S/.//}
257
258 RUBY_DISTVERSION?=      ${RUBY_VERSION}
259 RUBY_PORTVERSION?=      ${RUBY_VERSION}
260 MASTER_SITE_SUBDIR_RUBY?=       ${RUBY_VER}
261 RUBY_DISTNAME?=         ruby-${RUBY_DISTVERSION}
262
263 RUBY_WRKSRC?=           ${WRKDIR}/${RUBY_DISTNAME}
264
265 RUBY_RELVERSION_CODE?=  ${RUBY_RELVERSION:S/.//g}
266 RUBY_VERSION_CODE?=     ${RUBY_VERSION:S/.//g}
267 RUBY_VER=               ${RUBY_VERSION:C/([[:digit:]]+\.[[:digit:]]+).*/\1/}
268 RUBY_SUFFIX=            ${RUBY_VER:S/.//}
269
270 RUBY_WITHOUT_SUFFIX?=   ${LOCALBASE}/bin/ruby
271 RUBY_WITH_SUFFIX?=      ${RUBY_WITHOUT_SUFFIX}${RUBY_SUFFIX}
272
273 RUBY_PKGNAMEPREFIX?=    ruby${RUBY_SUFFIX}-
274 RUBY_SHLIBVER?=         ${RUBY_VER:S/.//}
275
276 RUBY_CONFIGURE_ARGS+=   --program-prefix=""
277
278 DEPENDS_ARGS+=          RUBY_VER="${RUBY_VER}"
279
280 RUBY_CONFIGURE_ARGS+=   --program-suffix="${RUBY_SUFFIX}"
281
282 RUBY_MODNAME?=          ${PORTNAME}
283
284 # Commands
285 RUBY_RD2?=              ${LOCALBASE}/bin/rd2
286 RUBY_RDOC?=             ${LOCALBASE}/bin/rdoc${RUBY_VER:S/.//}
287
288 # Ports
289 RUBY_BASE_PORT?=        lang/ruby${RUBY_VER:S/.//}
290 RUBY_PORT?=             ${RUBY_BASE_PORT}
291 RUBY_RDTOOL_PORT?=      textproc/ruby-rdtool
292
293 # Depends
294 DEPEND_LIBRUBY?=        lib${RUBY_NAME}.so.${RUBY_SHLIBVER}:${PORTSDIR}/${RUBY_PORT}
295 DEPEND_RUBY?=           ${RUBY}:${PORTSDIR}/${RUBY_PORT}
296 DEPEND_RUBY_RDTOOL?=    ${RUBY_RD2}:${PORTSDIR}/${RUBY_RDTOOL_PORT}
297
298 # Directories
299 RUBY_LIBDIR?=           ${_RUBY_SYSLIBDIR}/ruby/${RUBY_VER}
300 RUBY_ARCHLIBDIR?=       ${RUBY_LIBDIR}/${RUBY_ARCH}
301 RUBY_SITELIBDIR?=       ${_RUBY_SITEDIR}/${RUBY_VER}
302 RUBY_SITEARCHLIBDIR?=   ${RUBY_SITELIBDIR}/${RUBY_ARCH}
303 RUBY_VENDORLIBDIR?=     ${_RUBY_VENDORDIR}/${RUBY_VER}
304 RUBY_VENDORARCHLIBDIR?= ${RUBY_VENDORLIBDIR}/${RUBY_ARCH}
305 RUBY_DOCDIR?=           ${PREFIX}/share/doc/${RUBY_NAME}
306 RUBY_EXAMPLESDIR?=      ${PREFIX}/share/examples/${RUBY_NAME}
307 RUBY_RIDIR?=            ${PREFIX}/share/ri/${RUBY_VER}/system
308 RUBY_SITERIDIR?=        ${PREFIX}/share/ri/${RUBY_VER}/site
309 RUBY_MODDOCDIR?=        ${RUBY_DOCDIR}/${RUBY_MODNAME}
310 RUBY_MODEXAMPLESDIR?=   ${RUBY_EXAMPLESDIR}/${RUBY_MODNAME}
311 RUBY_ELISPDIR?=         ${PREFIX}/lib/ruby/elisp
312
313 # PLIST
314 PLIST_RUBY_DIRS=        RUBY_LIBDIR="${RUBY_LIBDIR}" \
315                         RUBY_ARCHLIBDIR="${RUBY_ARCHLIBDIR}" \
316                         RUBY_SITELIBDIR="${RUBY_SITELIBDIR}" \
317                         RUBY_SITEARCHLIBDIR="${RUBY_SITEARCHLIBDIR}" \
318                         RUBY_VENDORLIBDIR="${RUBY_VENDORLIBDIR}" \
319                         RUBY_VENDORARCHLIBDIR="${RUBY_VENDORARCHLIBDIR}" \
320                         RUBY_MODDOCDIR="${RUBY_MODDOCDIR}" \
321                         RUBY_MODEXAMPLESDIR="${RUBY_MODEXAMPLESDIR}" \
322                         RUBY_DOCDIR="${RUBY_DOCDIR}" \
323                         RUBY_EXAMPLESDIR="${RUBY_EXAMPLESDIR}" \
324                         RUBY_RIDIR="${RUBY_RIDIR}" \
325                         RUBY_SITERIDIR="${RUBY_SITERIDIR}" \
326                         RUBY_ELISPDIR="${RUBY_ELISPDIR}"
327
328 PLIST_SUB+=             ${PLIST_RUBY_DIRS:C,DIR="(${LOCALBASE}|${PREFIX})/,DIR=",} \
329                         RUBY_VERSION="${RUBY_VERSION}" \
330                         RUBY_VER="${RUBY_VER}" \
331                         RUBY_SHLIBVER="${RUBY_SHLIBVER}" \
332                         RUBY_ARCH="${RUBY_ARCH}" \
333                         RUBY_SUFFIX="${RUBY_SUFFIX}" \
334                         RUBY_NAME="${RUBY_NAME}" \
335                         RUBY_DEFAULT_SUFFIX="${RUBY_DEFAULT_SUFFIX}" \
336                         RUBY20=${RUBY20} \
337                         RUBY21=${RUBY21} \
338                         RUBY22=${RUBY22}
339
340 .if defined(USE_RUBY_RDOC)
341 MAKE_ENV+=      RUBY_RDOC=${RUBY_RDOC}
342 .endif
343
344 # require check
345 .if defined(RUBY_REQUIRE)
346 USE_RUBY=               yes
347
348 .if exists(${RUBY})
349 RUBY_PROVIDED!=         ${RUBY} -e '\
350         Ruby = ${RUBY_RELVERSION_CODE}; \
351         value = begin; ${RUBY_REQUIRE}; end and puts value'
352 .else
353 RUBY_PROVIDED=          "should be"     # the latest version is going to be installed
354 .endif
355
356 .if empty(RUBY_PROVIDED)
357 .undef RUBY_PROVIDED
358 .endif
359 .endif
360
361 # fix shebang lines
362 .if defined(RUBY_SHEBANG_FILES) && !empty(RUBY_SHEBANG_FILES)
363 USE_RUBY=               yes
364
365 post-patch:     ruby-shebang-patch
366
367 ruby-shebang-patch:
368         @cd ${WRKSRC}; for f in ${RUBY_SHEBANG_FILES}; do \
369         ${ECHO_MSG} "===>  Fixing the #! line of $$f"; \
370         TMPFILE=`mktemp -t rubyshebang`; \
371         cp $$f $$TMPFILE; \
372         ${AWK} 'BEGIN {flag = 0;}                                                               \
373                 {                                                                               \
374                         if (flag == 0) {                                                        \
375                                 if ($$0 ~ /^#!/) {                                              \
376                                         sub(/#!(.*\/)?(env[[:space:]]+)?ruby/, "#!${RUBY}", $$0);\
377                                         print $$0;                                              \
378                                 }                                                               \
379                                 else {                                                          \
380                                         print "#!${RUBY}";                                      \
381                                         print $$0;                                              \
382                                 }                                                               \
383                                 flag = 1;                                                       \
384                         } else {                                                                \
385                                 print $$0;                                                      \
386                         }                                                                       \
387                 }' $$TMPFILE > $$f; \
388         rm -f $$TMPFILE; \
389         done
390 .endif
391
392 .if ${PORT_OPTIONS:MDEBUG}
393 RUBY_FLAGS+=    -d
394 .endif
395
396 #
397 # RubyGems support
398 #
399 .if defined(USE_RUBYGEMS)
400
401 BUILD_DEPENDS+= ${RUBYGEMBIN}:${PORTSDIR}/devel/ruby-gems
402 RUN_DEPENDS+=   ${RUBYGEMBIN}:${PORTSDIR}/devel/ruby-gems
403
404 PKGNAMEPREFIX?= rubygem-
405 EXTRACT_SUFX=   .gem
406 EXTRACT_ONLY=
407 DIST_SUBDIR=    rubygem
408
409 EXTRACT_DEPENDS+=       ${RUBYGEMBIN}:${PORTSDIR}/devel/ruby-gems
410 GEMS_BASE_DIR=  lib/ruby/gems/${RUBY_VER}
411 GEMS_DIR=       ${GEMS_BASE_DIR}/gems
412 DOC_DIR=        ${GEMS_BASE_DIR}/doc
413 CACHE_DIR=      ${GEMS_BASE_DIR}/cache
414 SPEC_DIR=       ${GEMS_BASE_DIR}/specifications
415 GEM_NAME?=      ${PORTNAME}-${PORTVERSION}
416 GEM_LIB_DIR?=   ${GEMS_DIR}/${GEM_NAME}
417 GEM_DOC_DIR?=   ${DOC_DIR}/${GEM_NAME}
418 GEM_SPEC?=      ${SPEC_DIR}/${GEM_NAME}.gemspec
419 GEM_CACHE?=     ${CACHE_DIR}/${GEM_NAME}.gem
420
421 PLIST_SUB+=     PORTVERSION="${PORTVERSION}" \
422                 REV="${RUBY_GEM}" \
423                 GEMS_BASE_DIR="lib/ruby/gems/${RUBY_VER}" \
424                 GEMS_DIR="${GEMS_DIR}" \
425                 DOC_DIR="${DOC_DIR}" \
426                 CACHE_DIR="${CACHE_DIR}" \
427                 SPEC_DIR="${SPEC_DIR}" \
428                 PORT="${PORTNAME}-${PORTVERSION}" \
429                 GEM_NAME="${GEM_NAME}" \
430                 GEM_LIB_DIR="${GEM_LIB_DIR}" \
431                 GEM_DOC_DIR="${GEM_DOC_DIR}" \
432                 GEM_SPEC="${GEM_SPEC}" \
433                 GEM_CACHE="${GEM_CACHE}" \
434                 EXTRACT_SUFX="${EXTRACT_SUFX}"
435
436 RUBYGEMBIN=     ${LOCALBASE}/bin/gem${RUBY_VER:S/.//}
437
438 . if defined(DISTFILES)
439 GEMFILES=       ${DISTFILES:C/:[^:]+$//}
440 . else
441 GEMFILES=       ${DISTNAME}${EXTRACT_SUFX}
442 . endif
443
444 RUBYGEM_ARGS=-l --no-update-sources --no-ri --install-dir ${STAGEDIR}${PREFIX}/lib/ruby/gems/${RUBY_VER} --ignore-dependencies --bindir=${STAGEDIR}${PREFIX}/bin
445 GEM_ENV+=       RB_USER_INSTALL=yes
446 .if defined(NOPORTDOCS)
447 RUBYGEM_ARGS+=  --no-rdoc
448 .endif
449
450 do-extract:
451         @${SETENV} ${GEM_ENV} ${RUBYGEMBIN} unpack --target=${WRKDIR} ${DISTDIR}/${DIST_SUBDIR}/${GEMFILES}
452         @${TAR} -xOzf ${DISTDIR}/${DIST_SUBDIR}/${GEMFILES} metadata.gz | ${GZCAT} > ${BUILD_WRKSRC}/${GEMFILES}spec
453
454 do-build:
455         @(cd ${BUILD_WRKSRC}; if ! ${SETENV} ${GEM_ENV} ${RUBYGEMBIN} build --force ${GEMFILES}spec ; then \
456                 if [ -n "${BUILD_FAIL_MESSAGE}" ] ; then \
457                         ${ECHO_MSG} "===> Compilation failed unexpectedly."; \
458                         (${ECHO_CMD} "${BUILD_FAIL_MESSAGE}") | ${FMT} 75 79 ; \
459                         fi; \
460                 ${FALSE}; \
461                 fi)
462
463 do-install:
464         @(cd ${BUILD_WRKSRC}; ${SETENV} ${GEM_ENV} ${RUBYGEMBIN} install ${RUBYGEM_ARGS} ${GEMFILES} -- --build-args ${CONFIGURE_ARGS})
465
466 . if defined(RUBYGEM_AUTOPLIST)
467 .  if !target(post-install-script)
468 post-install-script:
469         @${ECHO} ${GEM_CACHE} >> ${TMPPLIST}
470         @${ECHO} ${GEM_SPEC} >> ${TMPPLIST}
471 .if !defined(NOPORTDOCS)
472         @${FIND} -ds ${STAGEDIR}${PREFIX}/${GEM_DOC_DIR} -type f -print | ${SED} -E -e \
473                 's,^${STAGEDIR}${PREFIX}/?,,' >> ${TMPPLIST}
474         @${FIND} -ds ${STAGEDIR}${PREFIX}/${GEM_DOC_DIR} -type d -print | ${SED} -E -e \
475                 's,^${STAGEDIR}${PREFIX}/?,@dirrm ,' >> ${TMPPLIST}
476 .endif
477         @${FIND} -ds ${STAGEDIR}${PREFIX}/${GEM_LIB_DIR} -type f -print | ${SED} -E -e \
478                 's,^${STAGEDIR}${PREFIX}/?,,' >> ${TMPPLIST}
479         @${FIND} -ds ${STAGEDIR}${PREFIX}/${GEM_LIB_DIR} -type d -print | ${SED} -E -e \
480                 's,^${STAGEDIR}${PREFIX}/?,@dirrm ,' >> ${TMPPLIST}
481         @${ECHO_CMD} "@unexec rmdir %D/${GEMS_DIR} 2>/dev/null || true" >> ${TMPPLIST}
482 .if !defined(NOPORTDOCS)
483         @${ECHO_CMD} "@unexec rmdir %D/${DOC_DIR} 2>/dev/null || true" >> ${TMPPLIST}
484 .endif
485         @${ECHO_CMD} "@unexec rmdir %D/${CACHE_DIR} 2>/dev/null || true" >> ${TMPPLIST}
486         @${ECHO_CMD} "@unexec rmdir %D/${SPEC_DIR} 2>/dev/null || true" >> ${TMPPLIST}
487         @${ECHO_CMD} "@unexec rmdir %D/${GEMS_BASE_DIR} 2>/dev/null || true" >> ${TMPPLIST}
488         @${ECHO_CMD} "@unexec rmdir %D/lib/ruby/gems 2>/dev/null || true" >> ${TMPPLIST}
489         @${ECHO_CMD} "@unexec rmdir %D/lib/ruby 2>/dev/null || true" >> ${TMPPLIST}
490 .  endif
491 . endif
492
493 .endif # USE_RUBYGEMS
494
495 #
496 # extconf.rb support
497 #
498 .if defined(USE_RUBY_EXTCONF)
499 USE_RUBY=               yes
500
501 RUBY_EXTCONF?=          extconf.rb
502 CONFIGURE_ARGS+=        --with-opt-dir="${LOCALBASE}"
503 CONFIGURE_ENV+=         RB_USER_INSTALL=yes
504
505 do-configure:   ruby-extconf-configure
506
507 ruby-extconf-configure:
508 .if defined(RUBY_EXTCONF_SUBDIRS)
509 .for d in ${RUBY_EXTCONF_SUBDIRS}
510         @${ECHO_MSG} "===>  Running ${RUBY_EXTCONF} in ${d} to configure"
511         @cd ${CONFIGURE_WRKSRC}/${d}; \
512         ${SETENV} ${CONFIGURE_ENV} ${RUBY} ${RUBY_FLAGS} ${RUBY_EXTCONF} ${CONFIGURE_ARGS}
513 .endfor
514 .else
515         @${ECHO_MSG} "===>  Running ${RUBY_EXTCONF} to configure"
516         @cd ${CONFIGURE_WRKSRC}; \
517         ${SETENV} ${CONFIGURE_ENV} ${RUBY} ${RUBY_FLAGS} ${RUBY_EXTCONF} ${CONFIGURE_ARGS}
518 .endif
519 .endif
520
521 #
522 # setup.rb support
523 #
524 .if defined(USE_RUBY_SETUP)
525 RUBY_SETUP?=            setup.rb
526
527 do-configure:   ruby-setup-configure
528
529 ruby-setup-configure:
530         @${ECHO_MSG} "===>  Running ${RUBY_SETUP} to configure"
531         @cd ${BUILD_WRKSRC}; \
532         ${SETENV} ${CONFIGURE_ENV} ${RUBY} ${RUBY_FLAGS} ${RUBY_SETUP} config ${CONFIGURE_ARGS}
533
534 do-build:       ruby-setup-build
535
536 ruby-setup-build:
537         @${ECHO_MSG} "===>  Running ${RUBY_SETUP} to build"
538         @cd ${BUILD_WRKSRC}; \
539         ${SETENV} ${MAKE_ENV} ${RUBY} ${RUBY_FLAGS} ${RUBY_SETUP} setup
540
541 do-install:     ruby-setup-install
542
543 ruby-setup-install:
544         @${ECHO_MSG} "===>  Running ${RUBY_SETUP} to install"
545         @cd ${INSTALL_WRKSRC}; \
546         ${SETENV} ${MAKE_ENV} ${RUBY} ${RUBY_FLAGS} ${RUBY_SETUP} install --prefix=${STAGEDIR}
547 .endif
548
549 .if defined(USE_LIBRUBY)
550 LIB_DEPENDS+=           ${DEPEND_LIBRUBY}
551 .endif
552
553 .if defined(USE_RUBY)
554 .if !defined(RUBY_NO_BUILD_DEPENDS)
555 EXTRACT_DEPENDS+=       ${DEPEND_RUBY}
556 PATCH_DEPENDS+=         ${DEPEND_RUBY}
557 BUILD_DEPENDS+=         ${DEPEND_RUBY}
558 .endif
559 .if !defined(RUBY_NO_RUN_DEPENDS)
560 RUN_DEPENDS+=           ${DEPEND_RUBY}
561 .endif
562 .endif
563
564 .if defined(USE_RAKE)
565 BUILD_DEPENDS+=         ${LOCALBASE}/bin/rake:${PORTSDIR}/devel/rubygem-rake
566 RAKE_BIN=       ${LOCALBASE}/bin/rake
567 .endif
568
569 # documents
570
571 RUBY_NO_RD_HTML=        yes
572
573 .if defined(RUBY_RD_HTML)
574 .undef RUBY_NO_RD_HTML
575 .endif
576
577 .if defined(NOPORTDOCS)
578 RUBY_NO_RD_HTML=        yes
579 .endif
580
581 .if defined(RUBY_RD_FILES) && !defined(RUBY_NO_RD_HTML)
582 USE_RUBY_RDTOOL=        yes
583
584 RUBY_RD_HTML_FILES=     ${RUBY_RD_FILES:S/.rb$//:S/.rd././:S/.rd$//:S/$/.html/}
585
586 PLIST_SUB+=             RUBY_RD_HTML_FILES=""
587
588 pre-install:    ruby-rd-build
589
590 ruby-rd-build:
591 .if !empty(RUBY_RD_FILES)
592         @${ECHO_MSG} "===>  Generating HTML documents from RD documents"
593         @cd ${WRKSRC}; for rd in ${RUBY_RD_FILES}; do \
594                 html=$$(echo $$rd | ${SED} 's/\.rb$$//;s/\.rd\././;s/\.rd$$//').html; \
595                 ${ECHO_MSG} "${RUBY_RD2} $$rd > $$html"; \
596                 ${RUBY_RD2} $$rd > $$html; \
597         done
598 .else
599         @${DO_NADA}
600 .endif
601
602 .else
603 RUBY_RD_HTML_FILES=     # empty
604
605 PLIST_SUB+=             RUBY_RD_HTML_FILES="@comment "
606 .endif
607
608 .if !defined(NOPORTDOCS) && defined(USE_RUBY_RDTOOL)
609 BUILD_DEPENDS+=         ${DEPEND_RUBY_RDTOOL}
610 .endif
611
612 .endif