Here's a diff to move most of the shared logic for building ruby
from the version specific Makefiles to Makefile.inc.

In order to allow this, a BINREV variable is added to track
the dotless version (REV 2.4 => BINREV 24).  This also removes
the RUBYLIBREV variable.  RUBYLIBREV was in the version specific
Makefiles, but it just duplicates REV from Makefile.inc.  This
complicates update-plist and similar code.

Not shown here are changes to the PLISTs to use REV instead of
RUBYLIBREV, as those are large and mechanical.

This diff made work on a new port for ruby 2.5.0-preview1
significantly easier (will send that one later as it needs more work).

Will be committing in a day or so unless I hear objections.

Thanks,
Jeremy

Index: Makefile.inc
===================================================================
RCS file: /cvs/ports/lang/ruby/Makefile.inc,v
retrieving revision 1.17
diff -u -p -u -p -r1.17 Makefile.inc
--- Makefile.inc        1 Nov 2017 10:52:06 -0000       1.17
+++ Makefile.inc        1 Nov 2017 11:53:33 -0000
@@ -1,7 +1,20 @@
 # $OpenBSD: Makefile.inc,v 1.17 2017/11/01 10:52:06 jeremy Exp $
 
+COMMENT-main ?=                object oriented script language with threads
+COMMENT-gdbm ?=                gdbm interface for ruby
+COMMENT-ri_docs ?=     ri documentation files for ruby
+
 DISTNAME ?=    ruby-${VERSION}
 
+PKGNAME-main ?=                ruby-${VERSION}
+PKGNAME-gdbm ?=                ruby${BINREV}-gdbm-${VERSION}
+PKGNAME-ri_docs ?=     ruby${BINREV}-ri_docs-${VERSION}
+
+PKG_ARCH-ri_docs ?=    *
+WANTLIB-ri_docs ?=     # empty
+
+PKGSPEC-main ?=                ruby->=${REV},<${NEXTVER}
+
 CATEGORIES ?=  lang
 
 HOMEPAGE ?=    http://www.ruby-lang.org/
@@ -16,20 +29,73 @@ PERMIT_DISTFILES_FTP ?= Yes
 MASTER_SITES ?=        http://cache.ruby-lang.org/pub/ruby/${VERSION:R}/
 
 CONFIGURE_STYLE ?=     gnu
-CONFIGURE_ARGS +=      --enable-shared
-CONFIGURE_ENV +=       PREFIX="${PREFIX}" \
+CONFIGURE_ARGS +=      --enable-shared \
+                       --program-suffix=${BINREV} \
+                       --with-soname=ruby${BINREV} \
+                       --with-ruby-version=minor \
+                       --with-mantype=doc \
+                       --enable-pthread \
+                       --enable-ipv6 \
+                       --without-bundled-libffi \
+                       --disable-option-checking
+
+CONFIGURE_ENV +=       LIBruby${BINREV}_VERSION=${LIBruby${BINREV}_VERSION} \
+                       PREFIX="${PREFIX}" \
                        CPPFLAGS="-DOPENSSL_NO_STATIC_ENGINE 
-I${LOCALBASE}/include" \
-                       LDFLAGS="-L${LOCALBASE}/lib"
+                       LDFLAGS="-L${LOCALBASE}/lib" \
+                       DLDFLAGS="-L${LOCALBASE}/lib" \
+                       ac_cv_prog_DOXYGEN="" \
+                       ac_cv_prog_DOT="" \
+
+MAKE_ENV +=            DLDFLAGS="-I${LOCALBASE}/lib"
+
+
+WANTLIB-main +=                c crypto ffi gmp m ncurses pthread readline ssl 
\
+                       util yaml z
+LIB_DEPENDS-main +=    devel/gmp \
+                       devel/libyaml \
+                       devel/libffi
+
+WANTLIB-gdbm +=                c m gdbm gmp pthread ruby${BINREV}
+LIB_DEPENDS-gdbm +=    databases/gdbm \
+                       devel/gmp \
+                       lang/ruby/${REV},-main>=${VERSION},<${NEXTVER}
+RUN_DEPENDS-gdbm ?=
+
+ALL_TARGET =           V=1 main
+INSTALL_TARGET =       V=1 install-nodoc
+
+RI_DOCS ?=             No
+
+TEST_DEPENDS ?=                ${FULLPKGNAME-main}:${BUILD_PKGPATH}
+
+POST_EXTRACT ?=                rm -rf ${WRKSRC}/ext/fiddle/libffi-* \
+                               ${WRKSRC}/tool/downloader.rb;
+
+# cc(1) uses too much ram to build ext/ripper/ripper.c
+# XXX remove arch if vmparam.h + login.conf give more than 1024M to pbuild
+.if ${MACHINE_ARCH:Malpha} || ${MACHINE_ARCH:Marm} || ${MACHINE_ARCH:Mhppa}
+CFLAGS_OVERRIDE =      -O1
+.endif
+
+FIX_RIPPER ?=  sed -i 's/%%CFLAGS_OVERRIDE%%/${CFLAGS_OVERRIDE}/g' \
+                       ${WRKSRC}/ext/ripper/depend;
+
+PRE_INSTALL ?= find ${WRKSRC} -name '*.orig' -print0 | xargs -0r rm; \
+               ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/ruby \
+               ${PREFIX}/lib/ruby/gems/${REV}/extensions/${SUB} \
+               ${PREFIX}/lib/ruby/gems/${REV}/extensions/${SUB}/${REV};
 
 # Ruby itself is clean, but some extensions (e.g. devel/ruby-therubyracer)
 # need W|X mappings.
 USE_WXNEEDED ?=                Yes
 
 REV ?=                 ${VERSION:R}
+BINREV ?=              ${REV:S/.//}
 SUB ?=                 ${MACHINE_ARCH:S/amd64/x86_64/}-openbsd
 SUBST_VARS +=          SUB REV
 FILESDIR ?=            ${.CURDIR}/../files
 
 FIX_RBCONFIG ?=                sed 's/INSTALL_ARGS/-c -o ${BINOWN} -g 
${BINGRP}/' < \
                                ${FILESDIR}/rbconfig_fix.rb >> \
-                               
${PREFIX}/lib/ruby/${RUBYLIBREV}/${SUB}/rbconfig.rb
+                               ${PREFIX}/lib/ruby/${REV}/${SUB}/rbconfig.rb
Index: 2.3/Makefile
===================================================================
RCS file: /cvs/ports/lang/ruby/2.3/Makefile,v
retrieving revision 1.20
diff -u -p -u -p -r1.20 Makefile
--- 2.3/Makefile        1 Nov 2017 10:52:06 -0000       1.20
+++ 2.3/Makefile        1 Nov 2017 11:44:37 -0000
@@ -1,49 +1,11 @@
 # $OpenBSD: Makefile,v 1.20 2017/11/01 10:52:06 jeremy Exp $
 
-COMMENT-main =         object oriented script language with threads
-COMMENT-gdbm =         gdbm interface for ruby
-COMMENT-tk =           tk interface for ruby
-COMMENT-ri_docs =      ri documentation files for ruby
-
 VERSION =              2.3.5
-RUBYLIBREV =           2.3
-
-SHARED_LIBS =          ruby23  2.0
-PKGNAME-main =         ruby-${VERSION}
-PKGNAME-gdbm =         ruby23-gdbm-${VERSION}
-PKGNAME-tk =           ruby23-tk-${VERSION}
-PKGNAME-ri_docs =      ruby23-ri_docs-${VERSION}
-
-PKG_ARCH-ri_docs =     *
-WANTLIB-ri_docs =      # empty
-
 NEXTVER =              2.4
-PKGSPEC-main =         ruby->=${RUBYLIBREV},<${NEXTVER}
+SHARED_LIBS =          ruby${BINREV}   2.0
 
-CONFIGURE_ARGS =       --program-suffix=23 \
-                       --with-soname=ruby23 \
-                       --with-ruby-version=minor \
-                       --with-mantype=doc \
-                       --enable-pthread \
-                       --enable-ipv6 \
-                       --without-bundled-libffi \
-                       --disable-option-checking
-
-CONFIGURE_ENV =                LIBruby23_VERSION=${LIBruby23_VERSION} \
-                       ac_cv_prog_DOXYGEN="" \
-                       ac_cv_prog_DOT="" \
-                       DLDFLAGS="-L${LOCALBASE}/lib"
-
-MAKE_ENV =             DLDFLAGS="-I${LOCALBASE}/lib"
-
-ALL_TARGET =           V=1 main
-INSTALL_TARGET =       V=1 install-nodoc
-
-WANTLIB-main =         c crypto ffi gmp m ncurses pthread readline ssl \
-                       util yaml z
-LIB_DEPENDS-main =     devel/gmp \
-                       devel/libyaml \
-                       devel/libffi
+COMMENT-tk =           tk interface for ruby
+PKGNAME-tk =           ruby${BINREV}-tk-${VERSION}
 
 PSEUDO_FLAVORS=                no_tk no_ri_docs bootstrap
 # Do not build the RI docs on slow arches
@@ -56,19 +18,13 @@ FLAVOR?=
 MULTI_PACKAGES =       -main -gdbm -tk -ri_docs
 .include <bsd.port.arch.mk>
 
-WANTLIB-gdbm =         c m gdbm gmp pthread ruby23
-LIB_DEPENDS-gdbm =     databases/gdbm \
-                       devel/gmp \
-                       lang/ruby/${REV},-main>=${VERSION},<${NEXTVER}
-RUN_DEPENDS-gdbm =
-
 .if ${BUILD_PACKAGES:M-tk}
 CONFIGURE_ARGS+=       --with-tcl-include=${LOCALBASE}/include/tcl8.5 \
                        --with-tk-include=${LOCALBASE}/include/tk8.5 \
                        --with-tcllib=tcl85 \
                        --with-tklib=tk85 \
                        --with-X11-dir=${X11BASE}
-WANTLIB-tk =           X11 c gmp m pthread ruby23 tcl85 tk85
+WANTLIB-tk =           X11 c gmp m pthread ruby${BINREV} tcl85 tk85
 LIB_DEPENDS-tk =       tk->=8.5,<8.6:x11/tk/8.5 \
                        devel/gmp \
                        lang/ruby/${REV},-main>=${VERSION},<${NEXTVER}
@@ -80,31 +36,18 @@ ALL_TARGET +=               rdoc
 INSTALL_TARGET +=      install-doc
 .endif
 
-SUBST_VARS +=          RUBYLIBREV
-
-TEST_DEPENDS =         ${FULLPKGNAME-main}:${BUILD_PKGPATH}
-
 post-extract:
-       rm -rf ${WRKSRC}/ext/fiddle/libffi-* ${WRKSRC}/tool/downloader.rb
+       ${POST_EXTRACT}
 
-# cc(1) uses too much ram to build ext/ripper/ripper.c
-# XXX remove arch if vmparam.h + login.conf give more than 1024M to pbuild
-.if ${MACHINE_ARCH:Malpha} || ${MACHINE_ARCH:Marm} || ${MACHINE_ARCH:Mhppa}
-CFLAGS_OVERRIDE =      -O1
-.endif
 pre-configure:
-       sed -i 's/%%CFLAGS_OVERRIDE%%/${CFLAGS_OVERRIDE}/g' \
-           ${WRKSRC}/ext/ripper/depend
+       ${FIX_RIPPER}
 
 pre-install:
-       find ${WRKSRC} -name '*.orig' -print0 | xargs -0r rm
-       ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/ruby \
-               ${PREFIX}/lib/ruby/gems/${RUBYLIBREV}/extensions/${SUB} \
-               
${PREFIX}/lib/ruby/gems/${RUBYLIBREV}/extensions/${SUB}/${RUBYLIBREV}
+       ${PRE_INSTALL}
 
 post-install:
        ${FIX_RBCONFIG}
-       chmod 444 
${PREFIX}/lib/ruby/gems/${RUBYLIBREV}/{cache,specifications}/*.gem*
+       chmod 444 ${PREFIX}/lib/ruby/gems/${REV}/{cache,specifications}/*.gem*
 
 # 16021 tests, 2256593 assertions, 3 failures, 5 errors, 127 skips
 do-test:
Index: 2.4/Makefile
===================================================================
RCS file: /cvs/ports/lang/ruby/2.4/Makefile,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 Makefile
--- 2.4/Makefile        1 Nov 2017 10:52:06 -0000       1.7
+++ 2.4/Makefile        1 Nov 2017 11:44:41 -0000
@@ -1,47 +1,8 @@
 # $OpenBSD: Makefile,v 1.7 2017/11/01 10:52:06 jeremy Exp $
 
-COMMENT-main =         object oriented script language with threads
-COMMENT-gdbm =         gdbm interface for ruby
-COMMENT-ri_docs =      ri documentation files for ruby
-
 VERSION =              2.4.2
-RUBYLIBREV =           2.4
-
 SHARED_LIBS =          ruby24  2.0
-PKGNAME-main =         ruby-${VERSION}
-PKGNAME-gdbm =         ruby24-gdbm-${VERSION}
-PKGNAME-ri_docs =      ruby24-ri_docs-${VERSION}
-
-PKG_ARCH-ri_docs =     *
-WANTLIB-ri_docs =      # empty
-
 NEXTVER =              2.5
-PKGSPEC-main =         ruby->=${RUBYLIBREV},<${NEXTVER}
-
-CONFIGURE_ARGS =       --program-suffix=24 \
-                       --with-soname=ruby24 \
-                       --with-ruby-version=minor \
-                       --with-mantype=doc \
-                       --enable-pthread \
-                       --enable-ipv6 \
-                       --without-bundled-libffi \
-                       --disable-option-checking
-
-CONFIGURE_ENV =                LIBruby24_VERSION=${LIBruby24_VERSION} \
-                       ac_cv_prog_DOXYGEN="" \
-                       ac_cv_prog_DOT="" \
-                       DLDFLAGS="-L${LOCALBASE}/lib"
-
-MAKE_ENV =             DLDFLAGS="-I${LOCALBASE}/lib"
-
-ALL_TARGET =           V=1 main
-INSTALL_TARGET =       V=1 install-nodoc
-
-WANTLIB-main =         c crypto ffi gmp m ncurses pthread readline ssl \
-                       util yaml z
-LIB_DEPENDS-main =     devel/gmp \
-                       devel/libyaml \
-                       devel/libffi
 
 PSEUDO_FLAVORS=                no_ri_docs bootstrap
 # Do not build the RI docs on slow arches
@@ -54,38 +15,19 @@ FLAVOR?=
 MULTI_PACKAGES =       -main -gdbm -ri_docs
 .include <bsd.port.arch.mk>
 
-WANTLIB-gdbm =         c m gdbm gmp pthread ruby24
-LIB_DEPENDS-gdbm =     databases/gdbm \
-                       devel/gmp \
-                       lang/ruby/${REV},-main>=${VERSION},<${NEXTVER}
-RUN_DEPENDS-gdbm =
-
 .if ${BUILD_PACKAGES:M-ri_docs}
 ALL_TARGET +=          rdoc
 INSTALL_TARGET +=      install-doc
 .endif
 
-SUBST_VARS +=          RUBYLIBREV
-
-TEST_DEPENDS =         ${FULLPKGNAME-main}:${BUILD_PKGPATH}
-
 post-extract:
-       rm -rf ${WRKSRC}/ext/fiddle/libffi-* ${WRKSRC}/tool/downloader.rb
+       ${POST_EXTRACT}
 
-# cc(1) uses too much ram to build ext/ripper/ripper.c
-# XXX remove arch if vmparam.h + login.conf give more than 1024M to pbuild
-.if ${MACHINE_ARCH:Malpha} || ${MACHINE_ARCH:Marm} || ${MACHINE_ARCH:Mhppa}
-CFLAGS_OVERRIDE =      -O1
-.endif
 pre-configure:
-       sed -i 's/%%CFLAGS_OVERRIDE%%/${CFLAGS_OVERRIDE}/g' \
-           ${WRKSRC}/ext/ripper/depend
+       ${FIX_RIPPER}
 
 pre-install:
-       find ${WRKSRC} -name '*.orig' -print0 | xargs -0r rm
-       ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/ruby \
-               ${PREFIX}/lib/ruby/gems/${RUBYLIBREV}/extensions/${SUB} \
-               
${PREFIX}/lib/ruby/gems/${RUBYLIBREV}/extensions/${SUB}/${RUBYLIBREV}
+       ${PRE_INSTALL}
 
 post-install:
        ${FIX_RBCONFIG}

Reply via email to