Import devel/codeblocks version 13.12_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_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?=           ${PORTSDIR}/lang/ocaml
68 OCAMLC_DEPEND?=         ${OCAMLC}:${OCAMLC_PORT}
69
70 #
71 # OCaml package manager port dependency
72 #
73 OCAMLFIND_PORT?=        ${PORTSDIR}/devel/ocaml-findlib
74 OCAMLFIND_DEPEND?=      ${OCAMLFIND}:${OCAMLFIND_PORT}
75
76 #
77 # OCaml camlp4 port dependency
78 #
79 CAMLP4_PORT?=           ${PORTSDIR}/devel/ocaml-camlp4
80 CAMLP4_DEPEND?=         ${CAMLP4}:${CAMLP4_PORT}
81
82 #
83 # OCaml TK bindings dependency
84 #
85 OCAMLTK_PORT?=          ${PORTSDIR}/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) || defined(USE_OCAML_LDCONFIG)
123 . if !target(post-install-script)
124 post-install-script: ocaml-findlib ocaml-ldconfig ocaml-wash
125 . endif
126 .endif
127
128 .if defined(USE_OCAML_FINDLIB)
129 #
130 # We'll additionally add ocamlfind to RUN_DEPENDS, since
131 # if the port requires ocamlfind to install - it requires
132 # some ocaml libraries and these libraries RUN_DEPENDS on
133 # ocamlfind
134 #
135 BUILD_DEPENDS+=         ${OCAMLFIND_DEPEND}
136 RUN_DEPENDS+=           ${OCAMLFIND_DEPEND}
137 MAKE_ENV+=      OCAMLFIND_DESTDIR="${STAGEDIR}${OCAMLFIND_DESTDIR}" \
138                 OCAMLFIND_LDCONF="${OCAMLFIND_LDCONF}"
139
140 #
141 # Directories under site-lib to process automatically
142 #
143 OCAML_PKGDIRS?= ${PORTNAME}
144 . if !target(ocaml-findlib)
145 ocaml-findlib:
146 .  for DIR in ${OCAML_PKGDIRS}
147 .   if defined(USE_OCAMLFIND_PLIST)
148         @${FIND} ${STAGEDIR}${PREFIX}/${OCAML_SITELIBDIR}/${DIR}/ -type f -print | ${SED} -e \
149                 's,^${STAGEDIR}${PREFIX}/,,' >> ${TMPPLIST}
150 .   endif
151         @${ECHO_CMD} "@unexec ${OCAMLFIND} remove ${DIR} 2>/dev/null" \
152                 >> ${TMPPLIST}
153 .  endfor
154 . endif
155 .endif
156
157 .if defined(USE_OCAML_CAMLP4)
158 BUILD_DEPENDS+=         ${CAMLP4_DEPEND}
159 .endif
160
161 .if defined(USE_OCAML_TK)
162 . if !defined(NO_OCAMLTK_BUILDDEPENDS)
163 EXTRACT_DEPENDS+=       ${OCAMLTK_DEPENDS}
164 PATCH_DEPENDS+=         ${OCAMLTK_DEPENDS}
165 BUILD_DEPENDS+=         ${OCAMLTK_DEPENDS}
166 . endif
167 . if !defined(NO_OCAMLTK_RUNDEPENDS)
168 RUN_DEPENDS+=           ${OCAMLTK_DEPENDS}
169 . endif
170 .endif
171
172 .if defined(USE_OCAML_LDCONFIG)
173 #
174 # Directories under PREFIX for appending to ld.conf
175 #
176 OCAML_LDLIBS?=  ${OCAML_SITELIBDIR}/${PORTNAME}
177 . if !target(ocaml-ldconfig)
178 ocaml-ldconfig:
179 .  for LIB in ${OCAML_LDLIBS}
180         @${ECHO_CMD} "@exec ${ECHO_CMD} "%D/${LIB}" >> %D/${OCAML_LDCONF}" \
181                 >> ${TMPPLIST}
182         @${ECHO_CMD} "@unexec ${SED} -i \"\" -e '/${LIB:S#/#\/#g}/d' %D/${OCAML_LDCONF}"  >> ${TMPPLIST}
183 .  endfor
184 . endif
185 .endif
186
187 .if defined(USE_OCAML_WASH)
188 . if !target(ocaml-wash)
189 ocaml-wash:
190 #       If ld.conf is empty
191         @${ECHO_CMD} "@unexec if [ ! -s %D/${OCAML_LDCONF} ]; then ${RM} -f %D/${OCAML_LDCONF}; fi || true" >> ${TMPPLIST}
192 . endif
193 .endif
194
195 .if !target(ocaml-findlib)
196 ocaml-findlib:
197         @${DO_NADA}
198 .endif
199
200 .if !target(ocaml-ldconfig)
201 ocaml-ldconfig:
202         @${DO_NADA}
203 .endif
204
205 .if !target(ocaml-wash)
206 ocaml-wash:
207         @${DO_NADA}
208 .endif
209
210 .endif #!defined(OCAML_include)
211
212 .if defined(_POSTMKINCLUDED)
213
214 .if defined(USE_OCAML_FINDLIB)
215
216 pre-install: ${STAGEDIR}${OCAMLFIND_DESTDIR}
217 ${STAGEDIR}${OCAMLFIND_DESTDIR}:
218         @${MKDIR} ${.TARGET}
219
220 .endif
221
222 .endif # _POSTMKINCLUDED