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 # ocaml-findlib-1.4.1_1 wants to edit our ld.conf file, which does not
82 # work well with staging.
83 .if defined(USE_OCAML_LDCONFIG)
84 . if !target(ocaml-ldconfig)
85 OCAMLFIND_LDCONF?= /dev/null
89 OCAMLFIND_DESTDIR?= ${PREFIX}/${OCAML_SITELIBDIR}
90 OCAMLFIND_LDCONF?= ${PREFIX}/${OCAML_LDCONF}
92 .if defined(USE_OCAML)
93 . if !defined(NO_OCAML_BUILDDEPENDS)
94 EXTRACT_DEPENDS+= ${OCAMLC_DEPEND}
95 PATCH_DEPENDS+= ${OCAMLC_DEPEND}
96 BUILD_DEPENDS+= ${OCAMLC_DEPEND}
98 . if !defined(NO_OCAML_RUNDEPENDS)
99 RUN_DEPENDS+= ${OCAMLC_DEPEND}
101 PLIST_SUB+= OCAML_SITELIBDIR="${OCAML_SITELIBDIR}"
104 .if defined(USE_OCAML_FINDLIB) || defined(USE_OCAML_LDCONFIG)
105 . if !target(post-install-script)
106 post-install-script: ocaml-findlib ocaml-ldconfig ocaml-wash
110 .if defined(USE_OCAML_FINDLIB)
112 # We'll additionally add ocamlfind to RUN_DEPENDS, since
113 # if the port requires ocamlfind to install - it requires
114 # some ocaml libraries and these libraries RUN_DEPENDS on
117 BUILD_DEPENDS+= ${OCAMLFIND_DEPEND}
118 RUN_DEPENDS+= ${OCAMLFIND_DEPEND}
119 MAKE_ENV+= OCAMLFIND_DESTDIR="${STAGEDIR}${OCAMLFIND_DESTDIR}" \
120 OCAMLFIND_LDCONF="${OCAMLFIND_LDCONF}"
123 # Directories under site-lib to process automatically
125 OCAML_PKGDIRS?= ${PORTNAME}
126 . if !target(ocaml-findlib)
128 . for DIR in ${OCAML_PKGDIRS}
129 . if defined(USE_OCAMLFIND_PLIST)
130 @${FIND} ${STAGEDIR}${PREFIX}/${OCAML_SITELIBDIR}/${DIR}/ -type f -print | ${SED} -e \
131 's,^${STAGEDIR}${PREFIX}/,,' >> ${TMPPLIST}
133 @${ECHO_CMD} "@unexec ${OCAMLFIND} remove ${DIR} 2>/dev/null" \
139 .if defined(USE_OCAML_LDCONFIG)
141 # Directories under PREFIX for appending to ld.conf
143 OCAML_LDLIBS?= ${OCAML_SITELIBDIR}/${PORTNAME}
144 . if !target(ocaml-ldconfig)
146 . for LIB in ${OCAML_LDLIBS}
147 @${ECHO_CMD} "@exec ${ECHO_CMD} "%D/${LIB}" >> %D/${OCAML_LDCONF}" \
149 @${ECHO_CMD} "@unexec ${SED} -i \"\" -e '/${LIB:S#/#\/#g}/d' %D/${OCAML_LDCONF}" >> ${TMPPLIST}
154 .if defined(USE_OCAML_WASH)
155 . if !target(ocaml-wash)
157 # If ld.conf is empty
158 @${ECHO_CMD} "@unexec if [ ! -s %D/${OCAML_LDCONF} ]; then ${RM} -f %D/${OCAML_LDCONF}; fi || true" >> ${TMPPLIST}
162 .if !target(ocaml-findlib)
167 .if !target(ocaml-ldconfig)
172 .if !target(ocaml-wash)
177 .endif #!defined(OCAML_include)
179 .if defined(_POSTMKINCLUDED)
181 .if defined(USE_OCAML_FINDLIB)
183 pre-install: ${STAGEDIR}${OCAMLFIND_DESTDIR}
184 ${STAGEDIR}${OCAMLFIND_DESTDIR}:
189 .endif # _POSTMKINCLUDED