Update editors/libreoffice-sq to version 5.2.5
[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_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
28 #                               automatically.
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}
38
39 .if !defined(OCAML_include)
40
41 OCAML_MAINTAINER=       ports@FreeBSD.org
42 OCAML_include=          bsd.ocaml.mk
43
44 #
45 # OCaml programs location
46 #
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
53
54 #
55 # OCaml library directory
56 #
57 OCAML_LIBDIR?=          lib/ocaml
58
59 #
60 # Where to install site libraries
61 #
62 OCAML_SITELIBDIR?=      ${OCAML_LIBDIR}/site-lib
63
64 #
65 # OCaml compiler port dependency
66 #
67 OCAMLC_PORT?=           lang/ocaml
68 OCAMLC_DEPEND?=         ${OCAMLC}:${OCAMLC_PORT}
69
70 #
71 # OCaml package manager port dependency
72 #
73 OCAMLFIND_PORT?=        devel/ocaml-findlib
74 OCAMLFIND_DEPEND?=      ${OCAMLFIND}:${OCAMLFIND_PORT}
75
76 #
77 # OCaml camlp4 port dependency
78 #
79 CAMLP4_PORT?=           devel/ocaml-camlp4
80 CAMLP4_DEPEND?=         ${CAMLP4}:${CAMLP4_PORT}
81
82 #
83 # OCaml TK bindings dependency
84 #
85 OCAMLTK_PORT?=          x11-toolkits/ocaml-labltk
86 OCAMLTK_DEPENDS?=       ${OCAMLTK}:${OCAMLTK_PORT}
87
88 #
89 # Common OCaml examples and documents location
90 #
91 OCAML_DOCSDIR=          ${PREFIX}/share/doc/ocaml
92 OCAML_EXAMPLESDIR=      ${PREFIX}/share/examples/ocaml
93
94 #
95 # Location of OCaml ld.conf file
96 #
97 OCAML_LDCONF?=          ${OCAML_LIBDIR}/ld.conf
98
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
104 . endif
105 .endif
106
107 OCAMLFIND_DESTDIR?=     ${PREFIX}/${OCAML_SITELIBDIR}
108 OCAMLFIND_LDCONF?=      ${PREFIX}/${OCAML_LDCONF}
109
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}
115 . endif
116 . if !defined(NO_OCAML_RUNDEPENDS)
117 RUN_DEPENDS+=           ${OCAMLC_DEPEND}
118 . endif
119 PLIST_SUB+=     OCAML_SITELIBDIR="${OCAML_SITELIBDIR}"
120 .endif
121
122 .if defined(USE_OCAML_FINDLIB)
123 #
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
127 # ocamlfind
128 #
129 BUILD_DEPENDS+=         ${OCAMLFIND_DEPEND}
130 RUN_DEPENDS+=           ${OCAMLFIND_DEPEND}
131 MAKE_ENV+=      OCAMLFIND_DESTDIR="${STAGEDIR}${OCAMLFIND_DESTDIR}" \
132                 OCAMLFIND_LDCONF="${OCAMLFIND_LDCONF}"
133
134 #
135 # Directories under site-lib to process automatically
136 #
137 OCAML_PKGDIRS?= ${PORTNAME}
138 _USES_install+= 735:ocaml-findlib
139 . if !target(ocaml-findlib)
140 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}
145 .   endif
146         @${ECHO_CMD} "@postunexec ${OCAMLFIND} remove ${DIR} 2>/dev/null" \
147                 >> ${TMPPLIST}
148 .  endfor
149 . endif
150 .endif
151
152 .if defined(USE_OCAML_CAMLP4)
153 BUILD_DEPENDS+=         ${CAMLP4_DEPEND}
154 .endif
155
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}
161 . endif
162 . if !defined(NO_OCAMLTK_RUNDEPENDS)
163 RUN_DEPENDS+=           ${OCAMLTK_DEPENDS}
164 . endif
165 .endif
166
167 .if defined(USE_OCAML_LDCONFIG)
168 #
169 # Directories under PREFIX for appending to ld.conf
170 #
171 OCAML_LDLIBS?=  ${OCAML_SITELIBDIR}/${PORTNAME}
172 _USES_install+= 740:ocaml-ldconfig
173 . if !target(ocaml-ldconfig)
174 ocaml-ldconfig:
175 .  for LIB in ${OCAML_LDLIBS}
176         @${ECHO_CMD} "@postexec ${ECHO_CMD} "%D/${LIB}" >> %D/${OCAML_LDCONF}" \
177                 >> ${TMPPLIST}
178         @${ECHO_CMD} "@postunexec ${SED} -i \"\" -e '/${LIB:S#/#\/#g}/d' %D/${OCAML_LDCONF}"  >> ${TMPPLIST}
179 .  endfor
180 . endif
181 .endif
182
183 .if defined(USE_OCAML_WASH)
184 . if !target(ocaml-wash)
185 _USES_install+= 745:ocaml-wash
186 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}
189 . endif
190 .endif
191
192 .endif #!defined(OCAML_include)
193
194 .if defined(_POSTMKINCLUDED)
195
196 .if defined(USE_OCAML_FINDLIB)
197
198 pre-install: ${STAGEDIR}${OCAMLFIND_DESTDIR}
199 ${STAGEDIR}${OCAMLFIND_DESTDIR}:
200         @${MKDIR} ${.TARGET}
201
202 .endif
203
204 .endif # _POSTMKINCLUDED