aboutsummaryrefslogtreecommitdiffstats
path: root/lang/ruby18/Makefile
blob: 6d73963f6b947c78f3d324d4997d803130f86633 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# New ports collection makefile for:    ruby18
# Date created:     6 May 2001
# Whom:         Akinori MUSHA aka knu <knu@idaemons.org>
#
# $FreeBSD$
#

PORTNAME=   ruby
PORTVERSION=    ${RUBY_PORTVERSION}
PORTREVISION=   4
PORTEPOCH=  1
CATEGORIES= lang ruby ipv6
MASTER_SITES=       ${MASTER_SITE_RUBY}
MASTER_SITE_SUBDIR= ${MASTER_SITE_SUBDIR_RUBY}
DIST_SUBDIR=    ruby

MAINTAINER= stas@FreeBSD.org
COMMENT?=   An object-oriented interpreted scripting language

GNU_CONFIGURE=  yes
WRKSRC=     ${RUBY_WRKSRC}
CONFIGURE_ARGS= ${RUBY_CONFIGURE_ARGS} \
        --enable-shared --with-openssl-include=${OPENSSLINC} \
        --mandir=${PREFIX}/man
USE_OPENSSL=    yes
USE_LDCONFIG=   yes

RUBY_VER=       1.8
USE_RUBY=       yes
RUBY_NO_BUILD_DEPENDS=  yes
RUBY_NO_RUN_DEPENDS=    yes
_RUBY_SYSLIBDIR=    ${PREFIX}/lib

OPTIONS=    PTHREADS "Enable pthreads support (may break some apps)" off \
        ONIGURUMA "Build with oniguruma regular expressions lib" off \
        IPV6 "Enable IPv6 support" on \
        RDOC "Build and install Rdoc indexes" on \
        DEBUG "Compile-in debug info" off

.include <bsd.port.pre.mk>

PKGNAMESUFFIX=  #empty
CFLAGS+=    ${PTHREAD_CFLAGS}   # Keep this, else ruby will fail to load
LDFLAGS+=   ${PTHREAD_LIBS}     # libraries dependent op libpthread.

.if defined(WITH_PTHREADS)
CONFIGURE_ARGS+=--enable-pthread
PKGNAMESUFFIX:= ${PKGNAMESUFFIX}+pthreads
.else
CONFIGURE_ARGS+=--disable-pthread
.endif

.if defined(WITH_ONIGURUMA)
PKGNAMESUFFIX:= ${PKGNAMESUFFIX}+oniguruma
BUILD_DEPENDS+= ${NONEXISTENT}:${ONIGURUMA_PORTDIR}:patch
ONIGURUMA_PORTDIR=${PORTSDIR}/devel/oniguruma
ONIGURUMA_WRKSRC=`cd ${ONIGURUMA_PORTDIR}; ${MAKE} -V WRKSRC`
PLIST_SUB+= ONIGURUMA=""
.else
PLIST_SUB+= ONIGURUMA="@comment "
.endif

.if defined(WITH_DEBUG)
CFLAGS+=    -g
STRIP=      # none
.endif

#
# Disable doc generation if requested or docs disabled at all
#
.if !defined(WITHOUT_RDOC) && !defined(NOPORTDOCS)
CONFIGURE_ARGS+=    --enable-install-doc
PLIST_SUB+=     RDOC=""
.else
CONFIGURE_ARGS+=    --disable-install-doc
PLIST_SUB+=     RDOC="@comment "
.endif

.if ${OSVERSION} < 502102
EXTRA_PATCHES=  ${PATCHDIR}/extrapatch-eval.c
.endif

.if ${OSVERSION} >= 400014 && !defined(WITHOUT_IPV6)
CONFIGURE_ARGS+=    --enable-ipv6
.endif

CONFIGURE_ENV=  CFLAGS="${CFLAGS}" \
        LIBS="${LDFLAGS}"

.if ${RUBY_VER} == ${RUBY_DEFAULT_VER}
MLINKS=     ${RUBY_NAME}.1 ruby.1
PLIST_SUB+= IF_DEFAULT=""
.else
PLIST_SUB+= IF_DEFAULT="@comment "
.endif

OBSOLETED_MODULES!= ${CAT} ${FILESDIR}/obsoleted

INSTALLED_SCRIPTS=  irb erb h2rb rdoc ri ruby testrb

EXTSAMPLES= bigdecimal/sample/*.rb  \
        curses/hello.rb     \
        curses/rain.rb      \
        curses/view.rb      \
        dl/sample/*.C       \
        dl/sample/*.rb      \
        pty/expect_sample.rb    \
        pty/script.rb       \
        pty/shl.rb
EXTDOCS=    bigdecimal/bigdecimal_*.html    \
        digest/digest.txt*      \
        dl/doc/dl.txt           \
        enumerator/enumerator.txt   \
        etc/etc.txt*            \
        pty/README*         \
        readline/README*        \
        syslog/syslog.txt       \
        zlib/doc/zlib.rd

MAN1=       ${RUBY_NAME}.1

# XXX: exists untill it will be committed to bsd.port.mk
COPYTREE_SHARE= ${SH} -c '(${FIND} -d $$0 $$2 | ${CPIO} -dumpl $$1 >/dev/null \
        2>&1) && \
        ${CHOWN} -R ${SHAREOWN}:${SHAREGRP} $$1 && \
        ${FIND} $$1/ -type d -exec ${CHMOD} 755 {} \; && \
        ${FIND} $$1/ -type f -exec ${CHMOD} ${SHAREMODE} {} \;' --

# Macros to change variables in rbconfig.rb
RB_SET_CONF_VAR=${SH} -c '${REINPLACE_CMD} -E -e "s,(CONFIG\[\"$$0\"\][[:space:]]*=[[:space:]]*)(\(?)(.*)(\)?),\1\2$$1\4," ${WRKSRC}/rbconfig.rb' --

post-extract:
    ${MV} ${WRKSRC}/ext/dl/h2rb ${WRKSRC}/bin/

post-patch:
.if ${OSVERSION} < 502102 || ${ARCH} == "sparc64" || ${ARCH} == "alpha"
    ${REINPLACE_CMD} -e 's|-lc"|"|g' ${WRKSRC}/configure
.endif
    ${REINPLACE_CMD} -e 's|-l$$pthread_lib|${PTHREAD_LIBS}|g' \
        ${WRKSRC}/configure

#
# Remove modules we don't want
#
.for d in Win32API win32ole
    ${RM} -rf ${BUILD_WRKSRC}/ext/${d}
.endfor

#
# Prepare modules we are wanting to build via external ports
#
.for d in gdbm iconv tk
    ${MV} ${BUILD_WRKSRC}/ext/${d} ${WRKDIR}/
.endfor

pre-configure:
.if defined(WITH_ONIGURUMA)
    cd ${ONIGURUMA_WRKSRC}; ./configure; \
        ${MAKE} -f Makefile ${RUBY_VER:S/.//} RUBYDIR="${WRKSRC}"
.endif
    ${TOUCH} ${CONFIGURE_WRKSRC}/${CONFIGURE_SCRIPT}

post-build:
#
# Hack to allow modules to be installed into separate PREFIX and/or under user
# privilegies
#
    @${RB_SET_CONF_VAR} "prefix" "ENV['PREFIX'] || \3"
    @${RB_SET_CONF_VAR} "INSTALL" "ENV['RB_USER_INSTALL'] ? '/usr/bin/install -c' : '/usr/bin/install -c ${_BINOWNGRP}'"
    @${RB_SET_CONF_VAR} "INSTALL_PROGRAM" "ENV['RB_USER_INSTALL'] ? '${INSTALL} ${COPY} ${STRIP} -m ${BINMODE}' : '${INSTALL_PROGRAM}'"
    @${RB_SET_CONF_VAR} "INSTALL_SCRIPT" "ENV['RB_USER_INSTALL'] ? '${INSTALL} ${COPY} -m ${BINMODE}' : '${INSTALL_SCRIPT}'"
    @${RB_SET_CONF_VAR} "INSTALL_DATA" "ENV['RB_USER_INSTALL'] ? '${INSTALL} ${COPY} -m ${SHAREMODE}' : '${INSTALL_DATA}'"

pre-install:
    ${MKDIR}    ${RUBY_DOCDIR}      \
            ${RUBY_ELISPDIR}    \
            ${RUBY_EXAMPLESDIR} \
            ${RUBY_RIDIR}       \
            ${RUBY_SITERIDIR}   \
            ${RUBY_SITEARCHLIBDIR}

    ${SETENV} LC_TIME=C /bin/date > ${RUBY_RIDIR}/created.rid
    ${SETENV} LC_TIME=C /bin/date > ${RUBY_SITERIDIR}/created.rid
    ${TOUCH} ${RUBY_ELISPDIR}/.keep_me.${RUBY_NAME}
    ${TOUCH} ${RUBY_EXAMPLESDIR}/.keep_me
    ${TOUCH} ${RUBY_DOCDIR}/.keep_me
    ${TOUCH} ${RUBY_SITEARCHLIBDIR}/.keep_me

post-install:
#
# XXX: hack to strip ruby binary. Ruby uses its own install script that seems
# bogus to hack.
#
.if defined(STRIP) && ${STRIP} == -s
    ${STRIP_CMD} ${PREFIX}/bin/${RUBY_NAME}
.endif

#
# Link just installed "ruby" to "ruby18", etc.
#
.if ${RUBY_VER} == ${RUBY_DEFAULT_VER}
. for FILE in ${INSTALLED_SCRIPTS}
    ${LN} -f ${PREFIX}/bin/${FILE}${RUBY_SUFFIX} ${PREFIX}/bin/${FILE}
. endfor
.endif

.if !defined(NOPORTDOCS)
    # Create all dirs required (":u" isn't avaiable in STABLE yet :-()
    ${MKDIR} ${EXTSAMPLES:C,^([^/]+)/.*,\1,:S,^,${RUBY_EXAMPLESDIR}/,}
    ${MKDIR} ${EXTDOCS:C,^([^/]+)/.*,\1,:S,^,${RUBY_DOCDIR}/,}
.for FILE in ${EXTSAMPLES}
    ${INSTALL_DATA} ${WRKSRC}/ext/${FILE} \
        ${RUBY_EXAMPLESDIR}/${FILE:C,^([^/]+)/.*,\1,}/
.endfor
.for FILE in ${EXTDOCS}
    ${INSTALL_DATA} ${WRKSRC}/ext/${FILE} \
        ${RUBY_DOCDIR}/${FILE:C,^([^/]+)/.*,\1,}/
.endfor
    @(cd ${WRKSRC}/sample/ && ${COPYTREE_SHARE} \* ${RUBY_EXAMPLESDIR}/)
    @(cd ${WRKSRC}/doc/ && ${COPYTREE_SHARE} \* ${RUBY_DOCDIR}/)
    ${INSTALL_DATA} ${WRKSRC}/COPYING*  \
            ${WRKSRC}/ChangeLog \
            ${WRKSRC}/LEGAL     \
            ${WRKSRC}/README*   \
            ${RUBY_DOCDIR}/
.endif
    @${ECHO} "Deinstalling obsoleted packages that are now part of ruby..."
    @cd ${PKG_DBDIR}; for portname in ${OBSOLETED_MODULES}; do \
        for pkg in ${RUBY_PKGNAMEPREFIX}$$portname-*; do \
            if [ -d $$pkg ]; then \
                ${ECHO} "---> $$pkg"; \
                ${PKG_DELETE} -f $$pkg; \
            fi; \
        done; \
    done
    @${ECHO_CMD} "@exec ${ECHO_CMD} \"Deinstalling obsoleted packages that are now part of ruby...\"" >> ${TMPPLIST}
    @${ECHO_CMD} "@exec cd ${PKG_DBDIR} && for portname in ${OBSOLETED_MODULES}; do for pkg in ${RUBY_PKGNAMEPREFIX}\$$portname-*; do if [ -d \$$pkg ]; then ${ECHO_CMD} \"---> \$$pkg\"; ${PKG_DELETE} -f \$$pkg; fi; done; done" >> ${TMPPLIST}
    @${CAT} ${PKGMESSAGE}

plist::
    truncate -s0 pkg-plist
.for FILE in ${INSTALLED_SCRIPTS}
    @${ECHO_CMD} "bin/${FILE}%%RUBY_SUFFIX%%" >> pkg-plist
    @${ECHO_CMD} "%%IF_DEFAULT%%bin/${FILE}" >> pkg-plist
.endfor
    @${ECHO_CMD} "lib/lib%%RUBY_NAME%%-static.a" >> pkg-plist
    @${ECHO_CMD} "lib/lib%%RUBY_NAME%%.so" >> pkg-plist
    @${ECHO_CMD} "lib/lib%%RUBY_NAME%%.so.%%RUBY_SHLIBVER%%" >> pkg-plist

    @${FIND} ${RUBY_DOCDIR}/ ! -type d ! -name .keep_me | \
        ${SED} 's,^${RUBY_DOCDIR},%%PORTDOCS%%%%RUBY_DOCDIR%%,' \
         >> pkg-plist
    @${FIND} ${RUBY_DOCDIR}/ -type d -mindepth 1 | ${SORT} -r | \
        ${SED} -E -e \
        's,^${RUBY_DOCDIR}(.*),%%PORTDOCS%%@dirrm %%RUBY_DOCDIR%%\1,' \
        >> pkg-plist

    @${FIND} ${RUBY_EXAMPLESDIR}/ ! -type d ! -name .keep_me | \
        ${SED} 's,^${RUBY_EXAMPLESDIR},%%PORTDOCS%%%%RUBY_EXAMPLESDIR%%,' \
         >> pkg-plist
    @${FIND} ${RUBY_EXAMPLESDIR}/ -type d -mindepth 1 | ${SORT} -r | \
        ${SED} -E -e \
        's,^${RUBY_EXAMPLESDIR}(.*),%%PORTDOCS%%@dirrm %%RUBY_EXAMPLESDIR%%\1,' \
        >> pkg-plist

    @${ECHO_CMD} "%%RUBY_DOCDIR%%/.keep_me" >> pkg-plist
    @${ECHO_CMD} "@dirrmtry %%RUBY_DOCDIR%%" >> pkg-plist

    @${ECHO_CMD} "%%RUBY_EXAMPLESDIR%%/.keep_me" >> pkg-plist
    @${ECHO_CMD} "@dirrmtry %%RUBY_EXAMPLESDIR%%" >> pkg-plist

    @${ECHO_CMD} "%%RUBY_ELISPDIR%%/.keep_me.%%RUBY_NAME%%" >> pkg-plist
    @${ECHO_CMD} "@dirrmtry %%RUBY_ELISPDIR%%" >> pkg-plist

    @${FIND} ${RUBY_RIDIR}/ ! -type d ! -name created.rid | \
        ${SED} 's,^${RUBY_RIDIR},%%RDOC%%%%RUBY_RIDIR%%,' >> pkg-plist
    @${FIND} ${RUBY_RIDIR}/ -type d -mindepth 1| ${SORT} -r | \
        ${SED} -E -e 's,^${RUBY_RIDIR}(.*),%%RDOC%%@dirrm %%RUBY_RIDIR%%\1,' \
        >> pkg-plist

    @${ECHO_CMD} "@exec /bin/mkdir -p %D/%%RUBY_RIDIR%%" >> pkg-plist
    @${ECHO_CMD} "@exec env LC_TIME=C /bin/date > %D/%%RUBY_RIDIR%%/created.rid" >> pkg-plist
    @${ECHO_CMD} "@unexec /bin/rm -f %D/%%RUBY_RIDIR%%/created.rid" >> pkg-plist

    @${ECHO_CMD} "@exec /bin/mkdir -p %D/%%RUBY_SITERIDIR%%" >> pkg-plist
    @${ECHO_CMD} "@exec env LC_TIME=C /bin/date > %D/%%RUBY_SITERIDIR%%/created.rid"  >> pkg-plist
    @${ECHO_CMD} "@unexec /bin/rm -f %D/%%RUBY_SITERIDIR%%/created.rid" \
        >> pkg-plist

    @${ECHO_CMD} "@dirrmtry %%RUBY_SITERIDIR%%" >> pkg-plist
    @${ECHO_CMD} "@dirrmtry %%RUBY_RIDIR%%" >> pkg-plist
    @${ECHO_CMD} "@dirrmtry share/ri/%%RUBY_VER%%" >> pkg-plist
    @${ECHO_CMD} "@dirrmtry share/ri" >> pkg-plist

    @${FIND} ${RUBY_LIBDIR}/ ! -type d | \
        ${SED} 's,^${RUBY_LIBDIR},%%RUBY_LIBDIR%%,' >> pkg-plist
    @${FIND} ${RUBY_LIBDIR}/ -type d | ${SORT} -r | \
        ${SED} -E -e 's,^${RUBY_LIBDIR}(.*),@dirrm %%RUBY_LIBDIR%%\1,' >> pkg-plist

    @${ECHO_CMD} "%%RUBY_SITEARCHLIBDIR%%/.keep_me" >> pkg-plist
    @${ECHO_CMD} "@dirrmtry %%RUBY_SITEARCHLIBDIR%%" >> pkg-plist
    @${ECHO_CMD} "@dirrmtry %%RUBY_SITELIBDIR%%" >> pkg-plist
    @${ECHO_CMD} "@dirrmtry lib/ruby/site_ruby" >> pkg-plist
    @${ECHO_CMD} "@dirrmtry lib/ruby" >> pkg-plist

    @${SED} -i "" -E -e "s,${RUBY_ARCH},%%RUBY_ARCH%%,g" pkg-plist

test:
    @(cd ${WRKSRC}; ${MAKE} test)

.include <bsd.port.post.mk>