Import security/amavis-stats version 0.1.12_3
[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 OCAMLFIND_DESTDIR?=     ${PREFIX}/${OCAML_SITELIBDIR}
82 OCAMLFIND_LDCONF?=      ${PREFIX}/${OCAML_LDCONF}
83
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}
89 . endif
90 . if !defined(NO_OCAML_RUNDEPENDS)
91 RUN_DEPENDS+=           ${OCAMLC_DEPEND}
92 . endif
93 PLIST_SUB+=     OCAML_SITELIBDIR="${OCAML_SITELIBDIR}"
94 .endif
95
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
99 . endif
100 .endif
101
102 .if defined(USE_OCAML_FINDLIB)
103 #
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
107 # ocamlfind
108 #
109 BUILD_DEPENDS+=         ${OCAMLFIND_DEPEND}
110 RUN_DEPENDS+=           ${OCAMLFIND_DEPEND}
111 MAKE_ENV+=      OCAMLFIND_DESTDIR="${STAGEDIR}${OCAMLFIND_DESTDIR}" \
112                 OCAMLFIND_LDCONF="${OCAMLFIND_LDCONF}"
113
114 #
115 # Directories under site-lib to process automatically
116 #
117 OCAML_PKGDIRS?= ${PORTNAME}
118 . if !target(ocaml-findlib)
119 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}
124 .   endif
125         @${ECHO_CMD} "@unexec rmdir %D/${OCAML_SITELIBDIR}/${DIR} 2>/dev/null || true" >> ${TMPPLIST}
126         @${ECHO_CMD} "@unexec ${OCAMLFIND} remove ${DIR} 2>/dev/null" \
127                 >> ${TMPPLIST}
128 .  endfor
129 . endif
130 .endif
131
132 .if defined(USE_OCAML_LDCONFIG)
133 #
134 # Directories under PREFIX for appending to ld.conf
135 #
136 OCAML_LDLIBS?=  ${OCAML_SITELIBDIR}/${PORTNAME}
137 . if !target(ocaml-ldconfig)
138 ocaml-ldconfig:
139 .  for LIB in ${OCAML_LDLIBS}
140 .   if defined(NO_STAGE)
141         @${ECHO_CMD} "${PREFIX}/${LIB}" >> "${PREFIX}/${OCAML_LDCONF}"
142 .   endif
143         @${ECHO_CMD} "@exec ${ECHO_CMD} "%D/${LIB}" >> %D/${OCAML_LDCONF}" \
144                 >> ${TMPPLIST}
145         @${ECHO_CMD} "@unexec ${SED} -i \"\" -e '/${LIB:S#/#\/#g}/d' %D/${OCAML_LDCONF}"  >> ${TMPPLIST}
146 .  endfor
147 . endif
148 .endif
149
150 .if defined(USE_OCAML_WASH)
151 . if !target(ocaml-wash)
152 ocaml-wash:
153         @${ECHO_CMD} "@unexec rmdir %D/${OCAML_SITELIBDIR} 2>/dev/null || true"\
154                 >> ${TMPPLIST}
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" \
158                 >> ${TMPPLIST}
159 . endif
160 .endif
161
162 .if !target(ocaml-findlib)
163 ocaml-findlib:
164         @${DO_NADA}
165 .endif
166
167 .if !target(ocaml-ldconfig)
168 ocaml-ldconfig:
169         @${DO_NADA}
170 .endif
171
172 .if !target(ocaml-wash)
173 ocaml-wash:
174         @${DO_NADA}
175 .endif
176
177 #
178 # XXX: temporary workaround for non-standard PREFIX
179 #
180 .if !target(add-plist-post)
181 add-plist-post:
182 . if (${PREFIX} != ${LOCALBASE} && \
183         ${PREFIX} != ${LINUXBASE} && ${PREFIX} != "/usr")
184         @${ECHO_CMD} "@unexec rmdir %D 2> /dev/null || true" >> ${TMPPLIST}
185 . else
186         @${DO_NADA}
187 . endif
188
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" \
193                 >> ${TMPPLIST}
194 . endif
195 .endif
196
197 .endif #!defined(OCAML_include)
198
199 .if defined(_POSTMKINCLUDED)
200
201 .if defined(USE_OCAML_FINDLIB)
202
203 pre-install: ${STAGEDIR}${OCAMLFIND_DESTDIR}
204 ${STAGEDIR}${OCAMLFIND_DESTDIR}:
205         @${MKDIR} ${.TARGET}
206
207 .endif
208
209 .endif # _POSTMKINCLUDED