| @@ -1,25 +1,26 @@ | | | @@ -1,25 +1,26 @@ |
1 | # $NetBSD: gem.mk,v 1.16 2012/10/03 12:58:34 asau Exp $ | | 1 | # $NetBSD: gem.mk,v 1.17 2013/03/07 16:42:53 taca Exp $ |
2 | # | | 2 | # |
3 | # This Makefile fragment is intended to be included by packages that build | | 3 | # This Makefile fragment is intended to be included by packages that build |
4 | # and install Ruby gems. | | 4 | # and install Ruby gems. |
5 | # | | 5 | # |
6 | # Package-settable variables: | | 6 | # Package-settable variables: |
7 | # | | 7 | # |
8 | # RUBYGEMS_REQD | | 8 | # RUBYGEMS_REQD |
9 | # Minimum version of required rubygems. Ruby base packages contain: | | 9 | # Minimum version of required rubygems. Ruby base packages contain: |
10 | # | | 10 | # |
11 | # ruby18-base: none | | 11 | # ruby18-base: none |
12 | # ruby193-base: 1.8.11 | | 12 | # ruby193-base: 1.8.11 |
| | | 13 | # ruby200-base: 2.0.0 |
13 | # | | 14 | # |
14 | # If newer version of rubygems is resuiqred, set RUBYGEMS_REQD to | | 15 | # If newer version of rubygems is resuiqred, set RUBYGEMS_REQD to |
15 | # minimum version. | | 16 | # minimum version. |
16 | # | | 17 | # |
17 | # Default: not defined | | 18 | # Default: not defined |
18 | # | | 19 | # |
19 | # OVERRIDE_GEMSPEC | | 20 | # OVERRIDE_GEMSPEC |
20 | # Fix version of depending gem or modify files in gemspec. | | 21 | # Fix version of depending gem or modify files in gemspec. |
21 | # | | 22 | # |
22 | # (1) Specify as gem and dependency pattern as usual pkgsrc's one. | | 23 | # (1) Specify as gem and dependency pattern as usual pkgsrc's one. |
23 | # | | 24 | # |
24 | # Example: | | 25 | # Example: |
25 | # When gemspec contains "json~>1.4.7" as runtime dependency | | 26 | # When gemspec contains "json~>1.4.7" as runtime dependency |
| @@ -27,27 +28,32 @@ | | | @@ -27,27 +28,32 @@ |
27 | # "json>=1.4.6" then use: | | 28 | # "json>=1.4.6" then use: |
28 | # | | 29 | # |
29 | # OVERRIDE_GEMSPEC+= json>=1.4.6 | | 30 | # OVERRIDE_GEMSPEC+= json>=1.4.6 |
30 | # | | 31 | # |
31 | # If you want to change depending gem to "json_pure>=1.4.6" | | 32 | # If you want to change depending gem to "json_pure>=1.4.6" |
32 | # then use: | | 33 | # then use: |
33 | # | | 34 | # |
34 | # OVERRIDE_GEMSPEC+= json:json_pure>=1.4.6 | | 35 | # OVERRIDE_GEMSPEC+= json:json_pure>=1.4.6 |
35 | # | | 36 | # |
36 | # You can also remove dependency: | | 37 | # You can also remove dependency: |
37 | # | | 38 | # |
38 | # OVERRIDE_GEMSPEC+= json: | | 39 | # OVERRIDE_GEMSPEC+= json: |
39 | # | | 40 | # |
40 | # (2) Modify files in gemspec. | | 41 | # (2) Modify instance of gemspec. |
| | | 42 | # |
| | | 43 | # Example: |
| | | 44 | # Rename gem's name to "foo" (setting instance @name): |
| | | 45 | # |
| | | 46 | # OVERRIDE_GEMSPEC+= :name=foo |
41 | # | | 47 | # |
42 | # Example: | | 48 | # Example: |
43 | # Remove files (a.rb and b.rb) from 'files': | | 49 | # Remove files (a.rb and b.rb) from 'files': |
44 | # | | 50 | # |
45 | # OVERRIDE_GEMSPEC+= :files a.rb= b.rb= | | 51 | # OVERRIDE_GEMSPEC+= :files a.rb= b.rb= |
46 | # | | 52 | # |
47 | # Example: | | 53 | # Example: |
48 | # Add a file (exec.rb) to 'executables': | | 54 | # Add a file (exec.rb) to 'executables': |
49 | # | | 55 | # |
50 | # OVERRIDE_GEMSPEC+= :executables exec.rb | | 56 | # OVERRIDE_GEMSPEC+= :executables exec.rb |
51 | # | | 57 | # |
52 | # Example: | | 58 | # Example: |
53 | # Rename a file (from 'ruby' to 'ruby193') in 'files': | | 59 | # Rename a file (from 'ruby' to 'ruby193') in 'files': |
| @@ -153,33 +159,37 @@ PRINT_PLIST_AWK+= /^${RUBY_GEM_BASE:S|/| | | | @@ -153,33 +159,37 @@ PRINT_PLIST_AWK+= /^${RUBY_GEM_BASE:S|/| |
153 | # resulting installed gem can run with older versions of rubygems. | | 159 | # resulting installed gem can run with older versions of rubygems. |
154 | # | | 160 | # |
155 | # If we're using rake to build the local gem, then include it as a | | 161 | # If we're using rake to build the local gem, then include it as a |
156 | # build tool. | | 162 | # build tool. |
157 | # | | 163 | # |
158 | | | 164 | |
159 | .if ${RUBY_VER} == "18" | | 165 | .if ${RUBY_VER} == "18" |
160 | BUILD_DEPENDS+= ${RUBY_PKGPREFIX}-rubygems>=1.1.0:../../misc/rubygems | | 166 | BUILD_DEPENDS+= ${RUBY_PKGPREFIX}-rubygems>=1.1.0:../../misc/rubygems |
161 | DEPENDS+= ${RUBY_PKGPREFIX}-rubygems>=1.0.1:../../misc/rubygems | | 167 | DEPENDS+= ${RUBY_PKGPREFIX}-rubygems>=1.0.1:../../misc/rubygems |
162 | .else # !ruby18 | | 168 | .else # !ruby18 |
163 | . if defined(RUBYGEMS_REQD) | | 169 | . if defined(RUBYGEMS_REQD) |
164 | | | 170 | |
165 | RUBY193_RUBYGEMS_VERS= 1.8.11 | | 171 | RUBY193_RUBYGEMS_VERS= 1.8.11 |
| | | 172 | RUBY200_RUBYGEMS_VERS= 2.0.0 |
166 | | | 173 | |
167 | _RUBYGEMS_REQD_MAJOR= ${RUBYGEMS_REQD:C/\.[0-9\.]+$//} | | 174 | _RUBYGEMS_REQD_MAJOR= ${RUBYGEMS_REQD:C/\.[0-9\.]+$//} |
168 | _RUBYGEMS_REQD_MINORS= ${RUBYGEMS_REQD:C/^([0-9]+)\.*//} | | 175 | _RUBYGEMS_REQD_MINORS= ${RUBYGEMS_REQD:C/^([0-9]+)\.*//} |
169 | | | 176 | |
170 | . if ${RUBY_VER} == "193" | | 177 | . if ${RUBY_VER} == "193" |
171 | _RUBYGEMS_MAJOR= ${RUBY193_RUBYGEMS_VERS:C/\.[0-9\.]+$//} | | 178 | _RUBYGEMS_MAJOR= ${RUBY193_RUBYGEMS_VERS:C/\.[0-9\.]+$//} |
172 | _RUBYGEMS_MINORS= ${RUBY193_RUBYGEMS_VERS:C/^([0-9]+)\.*//} | | 179 | _RUBYGEMS_MINORS= ${RUBY193_RUBYGEMS_VERS:C/^([0-9]+)\.*//} |
| | | 180 | . elif ${RUBY_VER} == "200" |
| | | 181 | _RUBYGEMS_MAJOR= ${RUBY200_RUBYGEMS_VERS:C/\.[0-9\.]+$//} |
| | | 182 | _RUBYGEMS_MINORS= ${RUBY200_RUBYGEMS_VERS:C/^([0-9]+)\.*//} |
173 | . else | | 183 | . else |
174 | PKG_FAIL_REASON+= "Unknown Ruby version specified: ${RUBY_VER}." | | 184 | PKG_FAIL_REASON+= "Unknown Ruby version specified: ${RUBY_VER}." |
175 | . endif | | 185 | . endif |
176 | | | 186 | |
177 | _RUBYGEMS_REQD= NO | | 187 | _RUBYGEMS_REQD= NO |
178 | | | 188 | |
179 | . if ${_RUBYGEMS_REQD_MAJOR} > ${_RUBYGEMS_MAJOR} | | 189 | . if ${_RUBYGEMS_REQD_MAJOR} > ${_RUBYGEMS_MAJOR} |
180 | _RUBYGEMS_REQD= YES | | 190 | _RUBYGEMS_REQD= YES |
181 | . elif ${_RUBYGEMS_REQD_MAJOR} == ${_RUBYGEMS_MAJOR} | | 191 | . elif ${_RUBYGEMS_REQD_MAJOR} == ${_RUBYGEMS_MAJOR} |
182 | . if !empty(_RUBYGEMS_MINORS) && ${_RUBYGEMS_REQD_MINORS} > ${_RUBYGEMS_MINORS} | | 192 | . if !empty(_RUBYGEMS_MINORS) && ${_RUBYGEMS_REQD_MINORS} > ${_RUBYGEMS_MINORS} |
183 | _RUBYGEMS_REQD= YES | | 193 | _RUBYGEMS_REQD= YES |
184 | . endif | | 194 | . endif |
185 | . endif | | 195 | . endif |
| @@ -234,31 +244,30 @@ PLIST_SUBST+= GEM_DOCDIR=${GEM_DOCDIR} | | | @@ -234,31 +244,30 @@ PLIST_SUBST+= GEM_DOCDIR=${GEM_DOCDIR} |
234 | ### | | 244 | ### |
235 | ### The gem-extract target extracts a standard gem file. It is an | | 245 | ### The gem-extract target extracts a standard gem file. It is an |
236 | ### automatic dependency for the post-extract target so it doesn't | | 246 | ### automatic dependency for the post-extract target so it doesn't |
237 | ### disturb the usual do-extract actions. | | 247 | ### disturb the usual do-extract actions. |
238 | ### | | 248 | ### |
239 | GEM_SPECFILE?= ${WRKDIR}/${DISTNAME}.gemspec | | 249 | GEM_SPECFILE?= ${WRKDIR}/${DISTNAME}.gemspec |
240 | | | 250 | |
241 | .PHONY: gem-extract | | 251 | .PHONY: gem-extract |
242 | post-extract: gem-extract | | 252 | post-extract: gem-extract |
243 | .if !target(gem-extract) | | 253 | .if !target(gem-extract) |
244 | gem-extract: fake-home | | 254 | gem-extract: fake-home |
245 | . for _gem_ in ${DISTFILES:M*.gem} | | 255 | . for _gem_ in ${DISTFILES:M*.gem} |
246 | ${RUN} cd ${WRKDIR} && ${SETENV} ${MAKE_ENV} ${RUBYGEM_ENV} \ | | 256 | ${RUN} cd ${WRKDIR} && ${SETENV} ${MAKE_ENV} ${RUBYGEM_ENV} \ |
247 | ${RUBYGEM} unpack ${RUBYGEM_INSTALL_ROOT_OPTION} \ | | 257 | ${RUBYGEM} unpack ${_DISTDIR:Q}${_gem_:Q} |
248 | ${_DISTDIR:Q}/${_gem_:Q} | | | |
249 | ${RUN} cd ${WRKDIR} && \ | | 258 | ${RUN} cd ${WRKDIR} && \ |
250 | ${SETENV} ${MAKE_ENV} TZ=UTC ${RUBYGEM_ENV} \ | | 259 | ${SETENV} ${MAKE_ENV} TZ=UTC ${RUBYGEM_ENV} \ |
251 | ${RUBYGEM} spec ${_DISTDIR:Q}/${_gem_:Q} > ${_gem_}spec | | 260 | ${RUBYGEM} spec --ruby ${_DISTDIR:Q}${_gem_:Q} > ${_gem_}spec |
252 | . endfor | | 261 | . endfor |
253 | .endif | | 262 | .endif |
254 | | | 263 | |
255 | ### | | 264 | ### |
256 | ### gem-build | | 265 | ### gem-build |
257 | ### | | 266 | ### |
258 | ### The gem-build target builds a new local gem from the extracted gem's | | 267 | ### The gem-build target builds a new local gem from the extracted gem's |
259 | ### contents. The new gem as created as ${WRKSRC}/${GEM_NAME}.gem. | | 268 | ### contents. The new gem as created as ${WRKSRC}/${GEM_NAME}.gem. |
260 | ### The local gem is then installed into a special build root under | | 269 | ### The local gem is then installed into a special build root under |
261 | ### ${WRKDIR} (${RUBYGEM_INSTALL_ROOT}), possibly compiling any extensions. | | 270 | ### ${WRKDIR} (${RUBYGEM_INSTALL_ROOT}), possibly compiling any extensions. |
262 | ### | | 271 | ### |
263 | GEM_CLEANBUILD?= ext/* | | 272 | GEM_CLEANBUILD?= ext/* |
264 | | | 273 | |
| @@ -311,27 +320,27 @@ _RUBYGEM_OPTIONS+= --no-ri | | | @@ -311,27 +320,27 @@ _RUBYGEM_OPTIONS+= --no-ri |
311 | .if !empty(RUBY_BUILD_RDOC:M[nN][oO]) | | 320 | .if !empty(RUBY_BUILD_RDOC:M[nN][oO]) |
312 | _RUBYGEM_OPTIONS+= --no-rdoc | | 321 | _RUBYGEM_OPTIONS+= --no-rdoc |
313 | .endif | | 322 | .endif |
314 | .if !empty(CONFIGURE_ARGS) | | 323 | .if !empty(CONFIGURE_ARGS) |
315 | _RUBYGEM_OPTIONS+= -- --build-args ${CONFIGURE_ARGS} | | 324 | _RUBYGEM_OPTIONS+= -- --build-args ${CONFIGURE_ARGS} |
316 | .endif | | 325 | .endif |
317 | | | 326 | |
318 | RUBYGEM_INSTALL_ROOT_OPTION= --install-root ${RUBYGEM_INSTALL_ROOT} | | 327 | RUBYGEM_INSTALL_ROOT_OPTION= --install-root ${RUBYGEM_INSTALL_ROOT} |
319 | | | 328 | |
320 | .PHONY: _gem-build-install-root | | 329 | .PHONY: _gem-build-install-root |
321 | _gem-build-install-root: | | 330 | _gem-build-install-root: |
322 | @${STEP_MSG} "Installing gem into installation root" | | 331 | @${STEP_MSG} "Installing gem into installation root" |
323 | ${RUN} ${SETENV} ${MAKE_ENV} ${RUBYGEM_ENV} \ | | 332 | ${RUN} ${SETENV} ${MAKE_ENV} ${RUBYGEM_ENV} \ |
324 | ${RUBYGEM} install ${RUBYGEM_OPTIONS} ${_RUBYGEM_OPTIONS} | | 333 | ${RUBYGEM} install --backtrace ${RUBYGEM_OPTIONS} ${_RUBYGEM_OPTIONS} |
325 | | | 334 | |
326 | # The ``gem'' command doesn't exit with a non-zero result even if the | | 335 | # The ``gem'' command doesn't exit with a non-zero result even if the |
327 | # install of the gem failed, so we do the check and return the proper exit | | 336 | # install of the gem failed, so we do the check and return the proper exit |
328 | # code ourselves. | | 337 | # code ourselves. |
329 | # | | 338 | # |
330 | .PHONY: _gem-build-install-root-check | | 339 | .PHONY: _gem-build-install-root-check |
331 | _gem-build-install-root-check: | | 340 | _gem-build-install-root-check: |
332 | ${RUN} ${TEST} -f ${RUBYGEM_INSTALL_ROOT}${PREFIX}/${GEM_CACHEDIR}/${GEM_NAME}.gem || \ | | 341 | ${RUN} ${TEST} -f ${RUBYGEM_INSTALL_ROOT}${PREFIX}/${GEM_CACHEDIR}/${GEM_NAME}.gem || \ |
333 | ${FAIL_MSG} "Installing ${GEM_NAME}.gem into installation root failed." | | 342 | ${FAIL_MSG} "Installing ${GEM_NAME}.gem into installation root failed." |
334 | | | 343 | |
335 | .if !empty(GEM_CLEANBUILD) | | 344 | .if !empty(GEM_CLEANBUILD) |
336 | .PHONY: _gem-build-cleanbuild | | 345 | .PHONY: _gem-build-cleanbuild |
337 | _gem-build-cleanbuild: | | 346 | _gem-build-cleanbuild: |