3 # $MBSDlabs: portmk/bsd.ocaml.mk,v 1.18 2006/08/06 18:47:23 stas Exp $
6 # bsd.ocaml.mk - Support for the Objective Caml language packages
8 # Author: Stanislav Sedov <ssedov@mbsd.msk.ru>
10 # Feel free to send any comments and suggestions to maintainer.
12 # Currently recognised variables are:
14 # USE_OCAML - Set if your port uses OCaml to build/install.
15 # NO_OCAML_BUILDDEPENDS - Don't add ocamlc to BUILD|EXTRACT|PATCH_DEPENDS.
16 # NO_OCAML_RUNDEPENDS - Don't add ocamlc to RUN_DEPENDS.
17 # USE_OCAML_FINDLIB - Set if your port uses ocamlfind to install
18 # packages. Package direcories will be
19 # automatically deleted.
20 # USE_OCAML_LDCONFIG - Set if your port installs shared libraries
21 # into ocaml site-lib dir. OCaml ld.conf file
22 # will be automatically processed.
23 # USE_OCAMLFIND_PLIST - Add contents of findlib target directories
25 # USE_OCAML_WASH - Set if your port wants to automatically
26 # purge shared Ocaml dirs on uninstall. It's
27 # useful when installing to non-standard PREFIX
28 # OCAML_PKGDIRS - Directories under site-lib to be processed
29 # if USE_OCAML_FINDLIB specified.
30 # Default: ${PORTNAME}
31 # OCAML_LDLIBS - Directories under PREFIX to be automatically
32 # added/removed from ld.conf
33 # Default: ${OCAML_SITELIBDIR}/${PORTNAME}
35 .if !defined(OCAML_include)
37 OCAML_MAINTAINER= ports@FreeBSD.org
38 OCAML_include= bsd.ocaml.mk
41 # OCaml programs location
43 OCAMLC?= ${LOCALBASE}/bin/ocamlc
44 OCAMLC_OPT?= ${LOCALBASE}/bin/ocamlc.opt
45 OCAMLCP?= ${LOCALBASE}/bin/ocamlcp
46 OCAMLFIND?= ${LOCALBASE}/bin/ocamlfind
49 # OCaml library directory
51 OCAML_LIBDIR?= lib/ocaml
54 # Where to install site libraries
56 OCAML_SITELIBDIR?= ${OCAML_LIBDIR}/site-lib
59 # OCaml compiler port dependency
61 OCAMLC_PORT?= ${PORTSDIR}/lang/ocaml
62 OCAMLC_DEPEND?= ${OCAMLC}:${OCAMLC_PORT}
65 # OCaml package manager port dependency
67 OCAMLFIND_PORT?= ${PORTSDIR}/devel/ocaml-findlib
68 OCAMLFIND_DEPEND?= ${OCAMLFIND}:${OCAMLFIND_PORT}
71 # Common OCaml examples and documents location
73 OCAML_DOCSDIR= ${PREFIX}/share/doc/ocaml
74 OCAML_EXAMPLESDIR= ${PREFIX}/share/examples/ocaml
77 # Location of OCaml ld.conf file
79 OCAML_LDCONF?= ${OCAML_LIBDIR}/ld.conf
81 OCAMLFIND_DESTDIR?= ${PREFIX}/${OCAML_SITELIBDIR}
82 OCAMLFIND_LDCONF?= ${PREFIX}/${OCAML_LDCONF}
84 .if defined(USE_OCAML)
85 . if !defined(NO_OCAML_BUILDDEPENDS)
86 EXTRACT_DEPENDS+= ${OCAMLC_DEPEND}
87 PATCH_DEPENDS+= ${OCAMLC_DEPEND}
88 BUILD_DEPENDS+= ${OCAMLC_DEPEND}
90 . if !defined(NO_OCAML_RUNDEPENDS)
91 RUN_DEPENDS+= ${OCAMLC_DEPEND}
93 PLIST_SUB+= OCAML_SITELIBDIR="${OCAML_SITELIBDIR}"
96 .if defined(USE_OCAML_FINDLIB) || defined(USE_OCAML_LDCONFIG)
97 . if !target(post-install-script)
98 post-install-script: ocaml-findlib ocaml-ldconfig ocaml-wash
102 .if defined(USE_OCAML_FINDLIB)
104 # We'll additionally add ocamlfind to RUN_DEPENDS, since
105 # if the port requires ocamlfind to install - it requires
106 # some ocaml libraries and these libraries RUN_DEPENDS on
109 BUILD_DEPENDS+= ${OCAMLFIND_DEPEND}
110 RUN_DEPENDS+= ${OCAMLFIND_DEPEND}
111 MAKE_ENV+= OCAMLFIND_DESTDIR="${STAGEDIR}${OCAMLFIND_DESTDIR}" \
112 OCAMLFIND_LDCONF="${OCAMLFIND_LDCONF}"
115 # Directories under site-lib to process automatically
117 OCAML_PKGDIRS?= ${PORTNAME}
118 . if !target(ocaml-findlib)
120 . for DIR in ${OCAML_PKGDIRS}
121 . if defined(USE_OCAMLFIND_PLIST)
122 @${FIND} ${STAGEDIR}${PREFIX}/${OCAML_SITELIBDIR}/${DIR}/ -type f -print | ${SED} -e \
123 's,^${STAGEDIR}${PREFIX}/,,' >> ${TMPPLIST}
125 @${ECHO_CMD} "@unexec rmdir %D/${OCAML_SITELIBDIR}/${DIR} 2>/dev/null || true" >> ${TMPPLIST}
126 @${ECHO_CMD} "@unexec ${OCAMLFIND} remove ${DIR} 2>/dev/null" \
132 .if defined(USE_OCAML_LDCONFIG)
134 # Directories under PREFIX for appending to ld.conf
136 OCAML_LDLIBS?= ${OCAML_SITELIBDIR}/${PORTNAME}
137 . if !target(ocaml-ldconfig)
139 . for LIB in ${OCAML_LDLIBS}
140 . if defined(NO_STAGE)
141 @${ECHO_CMD} "${PREFIX}/${LIB}" >> "${PREFIX}/${OCAML_LDCONF}"
143 @${ECHO_CMD} "@exec ${ECHO_CMD} "%D/${LIB}" >> %D/${OCAML_LDCONF}" \
145 @${ECHO_CMD} "@unexec ${SED} -i \"\" -e '/${LIB:S#/#\/#g}/d' %D/${OCAML_LDCONF}" >> ${TMPPLIST}
150 .if defined(USE_OCAML_WASH)
151 . if !target(ocaml-wash)
153 @${ECHO_CMD} "@unexec rmdir %D/${OCAML_SITELIBDIR} 2>/dev/null || true"\
155 # If ld.conf is empty
156 @${ECHO_CMD} "@unexec if [ ! -s %D/${OCAML_LDCONF} ]; then ${RM} -f %D/${OCAML_LDCONF}; fi || true" >> ${TMPPLIST}
157 @${ECHO_CMD} "@unexec rmdir %D/${OCAML_LIBDIR} 2>/dev/null || true" \
162 .if !target(ocaml-findlib)
167 .if !target(ocaml-ldconfig)
172 .if !target(ocaml-wash)
178 # XXX: temporary workaround for non-standard PREFIX
180 .if !target(add-plist-post)
182 . if (${PREFIX} != ${LOCALBASE} && \
183 ${PREFIX} != ${LINUXBASE} && ${PREFIX} != "/usr")
184 @${ECHO_CMD} "@unexec rmdir %D 2> /dev/null || true" >> ${TMPPLIST}
189 # If we are using PORTDOCS macro port cannot delete OCAML_DOCSDIR, so
190 # we shoud try to accomodate it
191 . if defined(PORTDOCS)
192 @${ECHO_CMD} "@unexec rmdir ${OCAML_DOCSDIR} 2>/dev/null || true" \
197 .endif #!defined(OCAML_include)
199 .if defined(_POSTMKINCLUDED)
201 .if defined(USE_OCAML_FINDLIB)
203 pre-install: ${STAGEDIR}${OCAMLFIND_DESTDIR}
204 ${STAGEDIR}${OCAMLFIND_DESTDIR}:
209 .endif # _POSTMKINCLUDED