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_CAMLP4 - Set if your port uses camlp4 to build.
21 # USE_OCAML_TK - Set if you port needs ocaml-labltk.
22 # NO_OCAMLTK_BUILDDEPENDS - Don't add labltk to BUILD|EXTRACT|PATCH_DEPENDS.
23 # NO_OCAMLTK_RUNDEPENDS - Don't add labltk to RUN_DEPENDS.
24 # USE_OCAML_LDCONFIG - Set if your port installs shared libraries
25 # into ocaml site-lib dir. OCaml ld.conf file
26 # will be automatically processed.
27 # USE_OCAMLFIND_PLIST - Add contents of findlib target directories
29 # USE_OCAML_WASH - Set if your port wants to automatically
30 # purge shared Ocaml dirs on uninstall. It's
31 # useful when installing to non-standard PREFIX
32 # OCAML_PKGDIRS - Directories under site-lib to be processed
33 # if USE_OCAML_FINDLIB specified.
34 # Default: ${PORTNAME}
35 # OCAML_LDLIBS - Directories under PREFIX to be automatically
36 # added/removed from ld.conf
37 # Default: ${OCAML_SITELIBDIR}/${PORTNAME}
39 .if !defined(OCAML_include)
41 OCAML_MAINTAINER= ports@FreeBSD.org
42 OCAML_include= bsd.ocaml.mk
45 # OCaml programs location
47 OCAMLC?= ${LOCALBASE}/bin/ocamlc
48 OCAMLC_OPT?= ${LOCALBASE}/bin/ocamlc.opt
49 OCAMLCP?= ${LOCALBASE}/bin/ocamlcp
50 OCAMLFIND?= ${LOCALBASE}/bin/ocamlfind
51 CAMLP4?= ${LOCALBASE}/bin/camlp4
52 OCAMLTK?= ${LOCALBASE}/bin/labltk
55 # OCaml library directory
57 OCAML_LIBDIR?= lib/ocaml
60 # Where to install site libraries
62 OCAML_SITELIBDIR?= ${OCAML_LIBDIR}/site-lib
65 # OCaml compiler port dependency
67 OCAMLC_PORT?= lang/ocaml
68 OCAMLC_DEPEND?= ${OCAMLC}:${OCAMLC_PORT}
71 # OCaml package manager port dependency
73 OCAMLFIND_PORT?= devel/ocaml-findlib
74 OCAMLFIND_DEPEND?= ${OCAMLFIND}:${OCAMLFIND_PORT}
77 # OCaml camlp4 port dependency
79 CAMLP4_PORT?= devel/ocaml-camlp4
80 CAMLP4_DEPEND?= ${CAMLP4}:${CAMLP4_PORT}
83 # OCaml TK bindings dependency
85 OCAMLTK_PORT?= x11-toolkits/ocaml-labltk
86 OCAMLTK_DEPENDS?= ${OCAMLTK}:${OCAMLTK_PORT}
89 # Common OCaml examples and documents location
91 OCAML_DOCSDIR= ${PREFIX}/share/doc/ocaml
92 OCAML_EXAMPLESDIR= ${PREFIX}/share/examples/ocaml
95 # Location of OCaml ld.conf file
97 OCAML_LDCONF?= ${OCAML_LIBDIR}/ld.conf
99 # ocaml-findlib-1.4.1_1 wants to edit our ld.conf file, which does not
100 # work well with staging.
101 .if defined(USE_OCAML_LDCONFIG)
102 . if !target(ocaml-ldconfig)
103 OCAMLFIND_LDCONF?= /dev/null
107 OCAMLFIND_DESTDIR?= ${PREFIX}/${OCAML_SITELIBDIR}
108 OCAMLFIND_LDCONF?= ${PREFIX}/${OCAML_LDCONF}
110 .if defined(USE_OCAML)
111 . if !defined(NO_OCAML_BUILDDEPENDS)
112 EXTRACT_DEPENDS+= ${OCAMLC_DEPEND}
113 PATCH_DEPENDS+= ${OCAMLC_DEPEND}
114 BUILD_DEPENDS+= ${OCAMLC_DEPEND}
116 . if !defined(NO_OCAML_RUNDEPENDS)
117 RUN_DEPENDS+= ${OCAMLC_DEPEND}
119 PLIST_SUB+= OCAML_SITELIBDIR="${OCAML_SITELIBDIR}"
122 .if defined(USE_OCAML_FINDLIB)
124 # We'll additionally add ocamlfind to RUN_DEPENDS, since
125 # if the port requires ocamlfind to install - it requires
126 # some ocaml libraries and these libraries RUN_DEPENDS on
129 BUILD_DEPENDS+= ${OCAMLFIND_DEPEND}
130 RUN_DEPENDS+= ${OCAMLFIND_DEPEND}
131 MAKE_ENV+= OCAMLFIND_DESTDIR="${STAGEDIR}${OCAMLFIND_DESTDIR}" \
132 OCAMLFIND_LDCONF="${OCAMLFIND_LDCONF}"
135 # Directories under site-lib to process automatically
137 OCAML_PKGDIRS?= ${PORTNAME}
138 _USES_install+= 735:ocaml-findlib
139 . if !target(ocaml-findlib)
141 . for DIR in ${OCAML_PKGDIRS}
142 . if defined(USE_OCAMLFIND_PLIST)
143 @${FIND} ${STAGEDIR}${PREFIX}/${OCAML_SITELIBDIR}/${DIR}/ -type f -print | ${SED} -e \
144 's,^${STAGEDIR}${PREFIX}/,,' >> ${TMPPLIST}
146 @${ECHO_CMD} "@postunexec ${OCAMLFIND} remove ${DIR} 2>/dev/null" \
152 .if defined(USE_OCAML_CAMLP4)
153 BUILD_DEPENDS+= ${CAMLP4_DEPEND}
156 .if defined(USE_OCAML_TK)
157 . if !defined(NO_OCAMLTK_BUILDDEPENDS)
158 EXTRACT_DEPENDS+= ${OCAMLTK_DEPENDS}
159 PATCH_DEPENDS+= ${OCAMLTK_DEPENDS}
160 BUILD_DEPENDS+= ${OCAMLTK_DEPENDS}
162 . if !defined(NO_OCAMLTK_RUNDEPENDS)
163 RUN_DEPENDS+= ${OCAMLTK_DEPENDS}
167 .if defined(USE_OCAML_LDCONFIG)
169 # Directories under PREFIX for appending to ld.conf
171 OCAML_LDLIBS?= ${OCAML_SITELIBDIR}/${PORTNAME}
172 _USES_install+= 740:ocaml-ldconfig
173 . if !target(ocaml-ldconfig)
175 . for LIB in ${OCAML_LDLIBS}
176 @${ECHO_CMD} "@postexec ${ECHO_CMD} "%D/${LIB}" >> %D/${OCAML_LDCONF}" \
178 @${ECHO_CMD} "@postunexec ${SED} -i \"\" -e '/${LIB:S#/#\/#g}/d' %D/${OCAML_LDCONF}" >> ${TMPPLIST}
183 .if defined(USE_OCAML_WASH)
184 . if !target(ocaml-wash)
185 _USES_install+= 745:ocaml-wash
187 # If ld.conf is empty
188 @${ECHO_CMD} "@postunexec if [ ! -s %D/${OCAML_LDCONF} ]; then ${RM} %D/${OCAML_LDCONF}; fi || true" >> ${TMPPLIST}
192 .endif #!defined(OCAML_include)
194 .if defined(_POSTMKINCLUDED)
196 .if defined(USE_OCAML_FINDLIB)
198 pre-install: ${STAGEDIR}${OCAMLFIND_DESTDIR}
199 ${STAGEDIR}${OCAMLFIND_DESTDIR}:
204 .endif # _POSTMKINCLUDED