Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Jul 2006 23:14:31 +0400 (MSD)
From:      Stanislav Sedov <ssedov@mbsd.msk.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/101029: [PATCH] Mk: add include to support OCaml packages
Message-ID:  <20060729191431.F012A1208B@fonon.realnet>
Resent-Message-ID: <200607291920.k6TJKUG3028767@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         101029
>Category:       ports
>Synopsis:       [PATCH] Mk: add include to support OCaml packages
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 29 19:20:29 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Stanislav Sedov
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
MBSD labs, Inc.
>Environment:
System: FreeBSD fonon.realnet 7.0-CURRENT FreeBSD 7.0-CURRENT #7: Sun Jun 18 20:51:36 MSD 2006 root@fonon.realnet:/work/src/fbsd-cur/src/sys/i386/compile/FONON i386


	
>Description:
	We have a lot of OCaml ports that provides additional language
	packages for OCaml language. Installing of such pacakge requites
	a lot of steps, e.g. running ocamlfind utility on install/deinstall
	with correct enviropment, updating OCaml-specific ld.conf on
	install/deinstall and other. As result ports become a bit complex
	and very large. You can see working examples in devel/ocaml-equeue,
	devel/ocaml-sem etc. This ports do similar work "by-hand" via
	pmake constructs and pkg-install script.

	This include simplifies creation on such ports. For example, the
	port for ocaml-xstr might look like this (this port isn't in
	ports collection yet):
	PORTNAME=       xstr
	PORTVERSION=    0.2.1
	CATEGORIES=     devel
	MASTER_SITES=   http://www.ocaml-programming.de/packages/
	PKGNAMEPREFIX=  ocaml-

	MAINTAINER=     ssedov@mbsd.msk.ru
	COMMENT=        Thread-safe implementation of string searching/matching

	WRKSRC=         ${WRKDIR}/${PORTNAME}
	USE_GMAKE=      yes
	USE_OCAML=      yes
	USE_OCAML_FINDLIB=      yes
	USE_OCAML_LDCONFIG=     yes

	.include <bsd.port.mk>

	Simple, isn't it? Compare with ocaml-sem - it does the same steps.

	The include doesn't interfere with ports available, and sufficient
	for ocaml-* ports needs (hopely).
>How-To-Repeat:
	
>Fix:

	

--- mk1.diff begins here ---
diff -ruN Mk.orig/bsd.ocaml.mk Mk/bsd.ocaml.mk
--- Mk.orig/bsd.ocaml.mk	Thu Jan  1 03:00:00 1970
+++ Mk/bsd.ocaml.mk	Sat Jul 29 22:55:46 2006
@@ -0,0 +1,144 @@
+# ex:ts=4
+#
+# $MBSDlabs: portmk/bsd.ocaml.mk,v 1.14 2006/07/29 18:54:54 stas Exp $
+# $FreeBSD$
+#
+# bsd.ocaml.mk - Support for the Objective Caml language packages
+#
+# Author: Stanislav Sedov <ssedov@mbsd.msk.ru>
+#
+# Feel free to send any comments and suggestions to maintainer.
+#
+# Currently recognised variables are:
+#
+# USE_OCAML		-	Set if your port uses OCaml to build/install.
+# NO_OCAML_BUILDDEPENDS	-	Don't add ocamlc to BUILD|EXTRACT|PATCH_DEPENDS.
+# NO_OCAML_RUNDEPENDS	-	Don't add ocamlc to RUN_DEPENDS.
+# USE_OCAML_FINDLIB	-	Set if your port uses ocamlfind to install
+#				packages. Package direcories will be
+#				automatically deleted.
+# USE_OCAML_LDCONFIG	-	Set if your port installs shared libraries
+#				into ocaml site-lib dir. OCaml ld.conf file
+#				will be automatically processed.
+# OCAML_PKGDIRS		-	Directories under site-lib to be processed
+#				if USE_OCAML_FINDLIB specified.
+#				Default: ${PORTNAME}
+# OCAML_LDLIBS		-	Directories under PREFIX to be automatically
+#				added/removed from ld.conf
+#				Default: ${OCAML_SITELIBDIR}/${PORTNAME}
+
+.if !defined(OCAML_include)
+
+OCAML_MAINTAINER=	ssedov@mbsd.msk.ru
+OCAML_include=		bsd.ocaml.mk
+
+#
+# OCaml programs location
+#
+OCAMLC?=		${LOCALBASE}/bin/ocamlc
+OCAMLC_OPT?=		${LOCALBASE}/bin/ocamlc.opt
+OCAMLCP?=		${LOCALBASE}/bin/ocamlcp
+OCAMLFIND?=		${LOCALBASE}/bin/ocamlfind
+
+#
+# Where to install site libraries
+#
+OCAML_SITELIBDIR?=	lib/ocaml/site-lib
+
+#
+# OCaml compiler port dependency
+#
+OCAMLC_PORT?=		${PORTSDIR}/lang/ocaml
+OCAMLC_DEPEND?=		${OCAMLC}:${OCAMLC_PORT}
+
+#
+# OCaml package manager port dependency
+#
+OCAMLFIND_PORT?=	${PORTSDIR}/devel/ocaml-findlib
+OCAMLFIND_DEPEND?=	${OCAMLFIND}:${OCAMLFIND_PORT}
+
+#
+# Location of OCaml ld.conf file
+#
+OCAML_LDCONF?=		lib/ocaml/ld.conf
+
+OCAMLFIND_DESTDIR?=	${PREFIX}/${OCAML_SITELIBDIR}
+OCAMLFIND_LDCONF?=	${PREFIX}/${OCAML_LDCONF}
+
+.if defined(USE_OCAML)
+. if !defined(NO_OCAML_BUILDDEPENDS)
+EXTRACT_DEPENDS+=	${OCAMLC_DEPEND}
+PATCH_DEPENDS+=		${OCAMLC_DEPEND}
+BUILD_DEPENDS+=		${OCAMLC_DEPEND}
+. endif
+. if !defined(NO_OCAML_RUNDEPENDS)
+RUN_DEPENDS+=		${OCAMLC_DEPEND}
+. endif
+PLIST_SUB+=	OCAML_SITELIBDIR="${OCAML_SITELIBDIR}"
+.endif
+
+.if defined(USE_OCAML_FINDLIB) || defined(USE_OCAML_LDCONFIG)
+. if !target(post-install-script)
+post-install-script: ocaml-findlib ocaml-ldconfig
+. endif
+.endif
+
+.if defined(USE_OCAML_FINDLIB)
+#
+# We'll additionally add ocamlfind to RUN_DEPENDS, since
+# if the port requires ocamlfind to install - it requires
+# some ocaml libraries and these libraries RUN_DEPENDS on
+# ocamlfind
+#
+BUILD_DEPENDS+=		${OCAMLFIND_DEPEND}
+RUN_DEPENDS+=		${OCAMLFIND_DEPEND}
+MAKE_ENV+=	OCAMLFIND_DESTDIR="${OCAMLFIND_DESTDIR}" \
+		OCAMLFIND_LDCONF="${OCAMLFIND_LDCONF}"
+
+#
+# Directories under site-lib to process automatically
+#
+OCAML_PKGDIRS?=	${PORTNAME}
+. if !target(pre-install-script)
+pre-install-script:
+.if !exists(${OCAMLFIND_DESTDIR})
+	@${MKDIR} "${PREFIX}/${OCAML_SITELIBDIR}"
+.endif
+. endif
+. if !target(ocaml-findlib)
+ocaml-findlib:
+.  for DIR in ${OCAML_PKGDIRS}
+	@${ECHO_CMD} "@unexec rmdir %D/${OCAML_SITELIBDIR}/${DIR} 2>/dev/null || true" >> ${TMPPLIST}
+	@${ECHO_CMD} "@unexec ${OCAMLFIND} remove ${DIR} 2>/dev/null" \
+		>> ${TMPPLIST}
+.  endfor
+. endif
+.endif
+
+.if defined(USE_OCAML_LDCONFIG)
+#
+# Directories under PREFIX for appending to ld.conf
+#
+OCAML_LDLIBS?=	${OCAML_SITELIBDIR}/${PORTNAME}
+. if !target(ocaml-ldconfig)
+ocaml-ldconfig:
+.  for LIB in ${OCAML_LDLIBS}
+	@${ECHO_CMD} "${PREFIX}/${LIB}" >> "${PREFIX}/${OCAML_LDCONF}"
+	@${ECHO_CMD} "@exec ${ECHO_CMD} "%D/${LIB}" >> %D/${OCAML_LDCONF}" \
+		>> ${TMPPLIST}
+	@${ECHO_CMD} "@unexec ${SED} -i \"\" -e '/${LIB:S#/#\/#g}/d' %D/${OCAML_LDCONF}"  >> ${TMPPLIST}
+.  endfor
+. endif
+.endif
+
+.if !target(ocaml-findlib)
+ocaml-findlib:
+	@${DO_NADA}
+.endif
+
+.if !target(ocaml-ldconfig)
+ocaml-ldconfig:
+	@${DO_NADA}
+.endif
+
+.endif
diff -ruN Mk.orig/bsd.port.mk Mk/bsd.port.mk
--- Mk.orig/bsd.port.mk	Sat Jul 29 23:01:03 2006
+++ Mk/bsd.port.mk	Sat Jul 29 23:01:22 2006
@@ -408,6 +408,9 @@
 # USE_JAVA		- If set, this port relies on the Java language.
 #				  Implies inclusion of bsd.java.mk.  (Also see
 #				  that file for more information on USE_JAVA_*).
+# USE_OCAML		- If set, this port relies on the OCaml language.
+#				  Implies inclusion of bsd.ocaml.mk.  (Also see
+#				  that file for more information on USE_OCAML*).
 # USE_PYTHON	- If set, this port relies on the Python language.
 #				  Implies inclusion of bsd.python.mk. (Also see
 #				  that file for more information on USE_PYTHON_*
@@ -1418,6 +1421,10 @@
 
 .if defined(USE_RUBY) || defined(USE_LIBRUBY)
 .include "${PORTSDIR}/Mk/bsd.ruby.mk"
+.endif
+
+.if defined(USE_OCAML)
+.include "${PORTSDIR}/Mk/bsd.ocaml.mk"
 .endif
 
 .if defined(USE_TCL) || defined(USE_TCL_BUILD) || defined(USE_TK)
--- mk1.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060729191431.F012A1208B>