Import devel/fpc-fpmkunit version 2.6.4
[dports.git] / Mk / bsd.ocaml.mk
1 # ex:ts=4
2 #
3 # $MBSDlabs: portmk/bsd.ocaml.mk,v 1.18 2006/08/06 18:47:23 stas Exp $
4 # $FreeBSD$
5 #
6 # bsd.ocaml.mk - Support for the Objective Caml language packages
7 #
8 # Author: Stanislav Sedov <ssedov@mbsd.msk.ru>
9 #
10 # Feel free to send any comments and suggestions to maintainer.
11 #
12 # Currently recognised variables are:
13 #
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
24 #                               automatically.
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}
34
35 .if !defined(OCAML_include)
36
37 OCAML_MAINTAINER=       ports@FreeBSD.org
38 OCAML_include=          bsd.ocaml.mk
39
40 #
41 # OCaml programs location
42 #
43 OCAMLC?=                ${LOCALBASE}/bin/ocamlc
44 OCAMLC_OPT?=            ${LOCALBASE}/bin/ocamlc.opt
45 OCAMLCP?=               ${LOCALBASE}/bin/ocamlcp
46 OCAMLFIND?=             ${LOCALBASE}/bin/ocamlfind
47
48 #
49 # OCaml library directory
50 #
51 OCAML_LIBDIR?=          lib/ocaml
52
53 #
54 # Where to install site libraries
55 #
56 OCAML_SITELIBDIR?=      ${OCAML_LIBDIR}/site-lib
57
58 #
59 # OCaml compiler port dependency
60 #
61 OCAMLC_PORT?=           ${PORTSDIR}/lang/ocaml
62 OCAMLC_DEPEND?=         ${OCAMLC}:${OCAMLC_PORT}
63
64 #
65 # OCaml package manager port dependency
66 #
67 OCAMLFIND_PORT?=        ${PORTSDIR}/devel/ocaml-findlib
68 OCAMLFIND_DEPEND?=      ${OCAMLFIND}:${OCAMLFIND_PORT}
69
70 #
71 # Common OCaml examples and documents location
72 #
73 OCAML_DOCSDIR=          ${PREFIX}/share/doc/ocaml
74 OCAML_EXAMPLESDIR=      ${PREFIX}/share/examples/ocaml
75
76 #
77 # Location of OCaml ld.conf file
78 #
79 OCAML_LDCONF?=          ${OCAML_LIBDIR}/ld.conf
80
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
86 . endif
87 .endif
88
89 OCAMLFIND_DESTDIR?=     ${PREFIX}/${OCAML_SITELIBDIR}
90 OCAMLFIND_LDCONF?=      ${PREFIX}/${OCAML_LDCONF}
91
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}
97 . endif
98 . if !defined(NO_OCAML_RUNDEPENDS)
99 RUN_DEPENDS+=           ${OCAMLC_DEPEND}
100 . endif
101 PLIST_SUB+=     OCAML_SITELIBDIR="${OCAML_SITELIBDIR}"
102 .endif
103
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
107 . endif
108 .endif
109
110 .if defined(USE_OCAML_FINDLIB)
111 #
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
115 # ocamlfind
116 #
117 BUILD_DEPENDS+=         ${OCAMLFIND_DEPEND}
118 RUN_DEPENDS+=           ${OCAMLFIND_DEPEND}
119 MAKE_ENV+=      OCAMLFIND_DESTDIR="${STAGEDIR}${OCAMLFIND_DESTDIR}" \
120                 OCAMLFIND_LDCONF="${OCAMLFIND_LDCONF}"
121
122 #
123 # Directories under site-lib to process automatically
124 #
125 OCAML_PKGDIRS?= ${PORTNAME}
126 . if !target(ocaml-findlib)
127 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}
132 .   endif
133         @${ECHO_CMD} "@dirrmtry ${OCAML_SITELIBDIR}/${DIR}" >> ${TMPPLIST}
134         @${ECHO_CMD} "@unexec ${OCAMLFIND} remove ${DIR} 2>/dev/null" \
135                 >> ${TMPPLIST}
136 .  endfor
137 . endif
138 .endif
139
140 .if defined(USE_OCAML_LDCONFIG)
141 #
142 # Directories under PREFIX for appending to ld.conf
143 #
144 OCAML_LDLIBS?=  ${OCAML_SITELIBDIR}/${PORTNAME}
145 . if !target(ocaml-ldconfig)
146 ocaml-ldconfig:
147 .  for LIB in ${OCAML_LDLIBS}
148         @${ECHO_CMD} "@exec ${ECHO_CMD} "%D/${LIB}" >> %D/${OCAML_LDCONF}" \
149                 >> ${TMPPLIST}
150         @${ECHO_CMD} "@unexec ${SED} -i \"\" -e '/${LIB:S#/#\/#g}/d' %D/${OCAML_LDCONF}"  >> ${TMPPLIST}
151 .  endfor
152 . endif
153 .endif
154
155 .if defined(USE_OCAML_WASH)
156 . if !target(ocaml-wash)
157 ocaml-wash:
158         @${ECHO_CMD} "@dirrmtry ${OCAML_SITELIBDIR}" >> ${TMPPLIST}
159 #       If ld.conf is empty
160         @${ECHO_CMD} "@rmtry ${OCAML_LDCONF}" >> ${TMPPLIST}
161         @${ECHO_CMD} "@dirrmtry ${OCAML_LIBDIR}" >> ${TMPPLIST}
162 . endif
163 .endif
164
165 .if !target(ocaml-findlib)
166 ocaml-findlib:
167         @${DO_NADA}
168 .endif
169
170 .if !target(ocaml-ldconfig)
171 ocaml-ldconfig:
172         @${DO_NADA}
173 .endif
174
175 .if !target(ocaml-wash)
176 ocaml-wash:
177         @${DO_NADA}
178 .endif
179
180 #
181 # XXX: temporary workaround for non-standard PREFIX
182 #
183 .if !target(add-plist-post)
184 add-plist-post:
185 . if (${PREFIX} != ${LOCALBASE} && \
186         ${PREFIX} != ${LINUXBASE} && ${PREFIX} != "/usr")
187         @${ECHO_CMD} "@dirrmtry ${PREFIX}" >> ${TMPPLIST}
188 . else
189         @${DO_NADA}
190 . endif
191
192 # If we are using PORTDOCS macro port cannot delete OCAML_DOCSDIR, so
193 # we shoud try to accomodate it
194 . if defined(PORTDOCS)
195         @${ECHO_CMD} "@dirrmtry ${OCAML_DOCSDIR}" >> ${TMPPLIST}
196 . endif
197 .endif
198
199 .endif #!defined(OCAML_include)
200
201 .if defined(_POSTMKINCLUDED)
202
203 .if defined(USE_OCAML_FINDLIB)
204
205 pre-install: ${STAGEDIR}${OCAMLFIND_DESTDIR}
206 ${STAGEDIR}${OCAMLFIND_DESTDIR}:
207         @${MKDIR} ${.TARGET}
208
209 .endif
210
211 .endif # _POSTMKINCLUDED