| @@ -1,26 +1,30 @@ | | | @@ -1,26 +1,30 @@ |
1 | # $NetBSD: rubygem.mk,v 1.15 2008/03/13 18:29:20 jlam Exp $ | | 1 | # $NetBSD: rubygem.mk,v 1.16 2008/03/13 22:20:04 jlam 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 | # GEM_BUILD | | 8 | # GEM_BUILD |
9 | # The method used to build the local gem. | | 9 | # The method used to build the local gem. |
10 | # | | 10 | # |
11 | # Possible: gemspec, rake | | 11 | # Possible: gemspec, rake |
12 | # Default: rake | | 12 | # Default: rake |
13 | # | | 13 | # |
| | | 14 | # GEM_CLEANBUILD |
| | | 15 | # A list of shell globs representing files to remove from the |
| | | 16 | # gem installed in the buildroot. |
| | | 17 | # |
14 | # GEM_NAME | | 18 | # GEM_NAME |
15 | # The name of the gem to install. The default value is ${DISTNAME}. | | 19 | # The name of the gem to install. The default value is ${DISTNAME}. |
16 | # | | 20 | # |
17 | # GEMFILE | | 21 | # GEMFILE |
18 | # The complete filename of the gem to install. It defaults to | | 22 | # The complete filename of the gem to install. It defaults to |
19 | # ${DISTNAME}.gem. | | 23 | # ${DISTNAME}.gem. |
20 | # | | 24 | # |
21 | # Variables defined in this file: | | 25 | # Variables defined in this file: |
22 | # | | 26 | # |
23 | # GEM_DOCDIR | | 27 | # GEM_DOCDIR |
24 | # The path to the directory in the local gem repository that holds | | 28 | # The path to the directory in the local gem repository that holds |
25 | # the documentation for the installed gem. | | 29 | # the documentation for the installed gem. |
26 | # | | 30 | # |
| @@ -137,27 +141,32 @@ gem-extract: | | | @@ -137,27 +141,32 @@ gem-extract: |
137 | ### The gem-build target builds a new local gem from the extracted | | 141 | ### The gem-build target builds a new local gem from the extracted |
138 | ### gem's contents. The new gem as created as ${WRKSRC}/${GEMFILE}. | | 142 | ### gem's contents. The new gem as created as ${WRKSRC}/${GEMFILE}. |
139 | ### | | 143 | ### |
140 | .PHONY: gem-build gem-gemspec-build gem-rake-build | | 144 | .PHONY: gem-build gem-gemspec-build gem-rake-build |
141 | do-build: gem-build | | 145 | do-build: gem-build |
142 | | | 146 | |
143 | gem-build: gem-${GEM_BUILD}-build | | 147 | gem-build: gem-${GEM_BUILD}-build |
144 | | | 148 | |
145 | gem-gemspec-build: | | 149 | gem-gemspec-build: |
146 | ${RUN} cd ${WRKSRC} && ${RUBYGEM} build metadata | | 150 | ${RUN} cd ${WRKSRC} && ${RUBYGEM} build metadata |
147 | | | 151 | |
148 | gem-rake-build: | | 152 | gem-rake-build: |
149 | ${RUN} cd ${WRKSRC} && ${RAKE} gem | | 153 | ${RUN} cd ${WRKSRC} && ${RAKE} gem |
150 | ${RUN} cd ${WRKSRC} && ln -fs pkg/${GEMFILE} . | | 154 | ${RUN} cd ${WRKSRC} && rm -f ${GEMFILE} |
| | | 155 | ${RUN} cd ${WRKSRC} && find . -name ${GEMFILE} -print | \ |
| | | 156 | while read file; do \ |
| | | 157 | ln -fs "$$file" ${GEMFILE}; \ |
| | | 158 | exit 0; \ |
| | | 159 | done |
151 | | | 160 | |
152 | ### | | 161 | ### |
153 | ### gem-install | | 162 | ### gem-install |
154 | ### | | 163 | ### |
155 | ### The gem-install target installs the local gem in ${WRKDIR} into | | 164 | ### The gem-install target installs the local gem in ${WRKDIR} into |
156 | ### the gem repository. We this this as a staged installation | | 165 | ### the gem repository. We this this as a staged installation |
157 | ### (independent of PKG_DESTDIR_SUPPORT) because it can potentially | | 166 | ### (independent of PKG_DESTDIR_SUPPORT) because it can potentially |
158 | ### build software and we want that to happen within ${WRKDIR}. | | 167 | ### build software and we want that to happen within ${WRKDIR}. |
159 | ### | | 168 | ### |
160 | _RUBYGEM_BUILDROOT= ${WRKDIR}/.inst | | 169 | _RUBYGEM_BUILDROOT= ${WRKDIR}/.inst |
161 | _RUBYGEM_OPTIONS= --no-update-sources # don't cache the gem index | | 170 | _RUBYGEM_OPTIONS= --no-update-sources # don't cache the gem index |
162 | _RUBYGEM_OPTIONS+= --install-dir ${GEM_HOME} | | 171 | _RUBYGEM_OPTIONS+= --install-dir ${GEM_HOME} |
163 | _RUBYGEM_OPTIONS+= --build-root ${_RUBYGEM_BUILDROOT} | | 172 | _RUBYGEM_OPTIONS+= --build-root ${_RUBYGEM_BUILDROOT} |
| @@ -179,28 +188,46 @@ _GEM_INSTALL_TARGETS+= _gem-install-clea | | | @@ -179,28 +188,46 @@ _GEM_INSTALL_TARGETS+= _gem-install-clea |
179 | _GEM_INSTALL_TARGETS+= _gem-install-copy | | 188 | _GEM_INSTALL_TARGETS+= _gem-install-copy |
180 | | | 189 | |
181 | .PHONY: gem-install ${_GEM_INSTALL_TARGETS} | | 190 | .PHONY: gem-install ${_GEM_INSTALL_TARGETS} |
182 | .ORDER: ${_GEM_INSTALL_TARGETS} | | 191 | .ORDER: ${_GEM_INSTALL_TARGETS} |
183 | | | 192 | |
184 | do-install: gem-install | | 193 | do-install: gem-install |
185 | gem-install: ${_GEM_INSTALL_TARGETS} | | 194 | gem-install: ${_GEM_INSTALL_TARGETS} |
186 | | | 195 | |
187 | _gem-install-buildroot: | | 196 | _gem-install-buildroot: |
188 | @${STEP_MSG} "Installing gem into buildroot" | | 197 | @${STEP_MSG} "Installing gem into buildroot" |
189 | ${RUN} ${SETENV} ${INSTALL_ENV} ${MAKE_ENV} \ | | 198 | ${RUN} ${SETENV} ${INSTALL_ENV} ${MAKE_ENV} \ |
190 | ${RUBYGEM} install ${_RUBYGEM_OPTIONS} | | 199 | ${RUBYGEM} install ${_RUBYGEM_OPTIONS} |
191 | | | 200 | |
| | | 201 | GEM_CLEANBUILD?= # empty |
| | | 202 | .if !empty(GEM_CLEANBUILD:M/*) || !empty(GEM_CLEANBUILD:M*../*) |
| | | 203 | PKG_FAIL_REASON= "GEM_CLEANBUILD must be relative to "${GEM_LIBDIR:Q}"." |
| | | 204 | .endif |
| | | 205 | |
192 | _gem-install-cleanbuild: | | 206 | _gem-install-cleanbuild: |
193 | @${STEP_MSG} "Cleaning intermediate gem build files" | | 207 | @${STEP_MSG} "Cleaning intermediate gem build files" |
| | | 208 | .if !empty(GEM_CLEANBUILD) |
| | | 209 | ${RUN} cd ${_RUBYGEM_BUILDROOT}${GEM_LIBDIR} && \ |
| | | 210 | ls ${GEM_CLEANBUILD} | \ |
| | | 211 | while read file; do \ |
| | | 212 | if [ -d "$$file" ]; then \ |
| | | 213 | echo "rmdir "${GEM_LIBDIR:T}"/$$file"; \ |
| | | 214 | rmdir $$file; \ |
| | | 215 | else \ |
| | | 216 | echo "rm "${GEM_LIBDIR:T}"/$$file"; \ |
| | | 217 | rm -f $$file; \ |
| | | 218 | fi; \ |
| | | 219 | done |
| | | 220 | .endif |
194 | ${RUN} if [ -d ${_RUBYGEM_BUILDROOT}${GEM_LIBDIR}/ext ]; then \ | | 221 | ${RUN} if [ -d ${_RUBYGEM_BUILDROOT}${GEM_LIBDIR}/ext ]; then \ |
195 | cd ${_RUBYGEM_BUILDROOT}${GEM_LIBDIR} && \ | | 222 | cd ${_RUBYGEM_BUILDROOT}${GEM_LIBDIR} && \ |
196 | find ext -print | sort -r | \ | | 223 | find ext -print | sort -r | \ |
197 | while read file; do \ | | 224 | while read file; do \ |
198 | [ ! -e ${WRKSRC:Q}"/$$file" ] || continue; \ | | 225 | [ ! -e ${WRKSRC:Q}"/$$file" ] || continue; \ |
199 | if [ -d ${WRKSRC:Q}"/$$file" ]; then \ | | 226 | if [ -d ${WRKSRC:Q}"/$$file" ]; then \ |
200 | echo "rmdir "${GEM_LIBDIR:T}"/$$file"; \ | | 227 | echo "rmdir "${GEM_LIBDIR:T}"/$$file"; \ |
201 | rmdir $$file; \ | | 228 | rmdir $$file; \ |
202 | else \ | | 229 | else \ |
203 | echo "rm "${GEM_LIBDIR:T}"/$$file"; \ | | 230 | echo "rm "${GEM_LIBDIR:T}"/$$file"; \ |
204 | rm -f $$file; \ | | 231 | rm -f $$file; \ |
205 | fi; \ | | 232 | fi; \ |
206 | done; \ | | 233 | done; \ |