2
# Description: CDBS class for OCaml related packages
4
# Copyright © 2006-2007 Stefano Zacchiroli <zack@debian.org>
6
# This program is free software; you can redistribute it and/or modify it under
7
# the terms of the GNU General Public License as published by the Free Software
8
# Foundation; either version 2, or (at your option) any later version.
10
# This program is distributed in the hope that it will be useful, but WITHOUT
11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15
# You should have received a copy of the GNU General Public License along with
16
# this program; if not, write to the Free Software Foundation, Inc., 51
17
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
# $Id: ocaml.mk 4944 2007-12-28 14:50:46Z zack $
21
_cdbs_scripts_path ?= /usr/lib/cdbs
22
_cdbs_rules_path ?= /usr/share/cdbs/1/rules
23
_cdbs_class_path ?= /usr/share/cdbs/1/class
25
ifndef _cdbs_class_ocaml
28
# needed by debian/control:: rule below
29
include $(_cdbs_rules_path)/buildcore.mk$(_cdbs_makefile_suffix)
31
# to ensure invocations and tests on /usr/bin/ocaml* are meaningful
32
CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), ocaml-nox
34
# import OCAML_* make variables
35
include $(_cdbs_class_path)/ocaml-vars.mk$(_cdbs_makefile_suffix)
37
ifdef _cdbs_rules_debhelper
39
# ensure dpkg-gencontrol will fill F:OCamlABI fields with the proper value
40
DEB_DH_GENCONTROL_ARGS += -- -VF:OCamlABI="$(OCAML_ABI)"
41
DEB_DH_GENCONTROL_ARGS += -VF:OCamlNativeArchs="$(OCAML_NATIVE_ARCHS)"
45
# post-install hook to invoke ocamldoc on OCAML_OCAMLDOC_PACKAGES packages
46
$(patsubst %,binary-install/%,$(DEB_PACKAGES))::
47
@OCAMLDOC="ocamldoc $(OCAML_OCAMLDOC_FLAGS)"; \
48
if test -n "$(OCAML_OCAMLDOC_OCAMLFIND_FLAGS)" ; then \
49
if ! test -x "/usr/bin/ocamlfind"; then \
50
echo "OCamlfind flags set and no ocamlfind to be found" >&2; \
53
OCAMLDOC="ocamlfind $$OCAMLDOC $(OCAML_OCAMLDOC_OCAMLFIND_FLAGS)"; \
55
OCAML_OCAMLDOC_INCLUDE=`for i in $(OCAML_OCAMLDOC_PACKAGES); do \
56
find debian/$$i/$(OCAML_STDLIB_DIR)/ -type d -exec echo -I \{} \; ; \
58
if (echo $(OCAML_OCAMLDOC_PACKAGES) | egrep '( |^)$(cdbs_curpkg)( |$$)' > /dev/null) ; then \
59
echo 'mkdir -p debian/$(cdbs_curpkg)/$(OCAML_OCAMLDOC_DESTDIR_HTML)' ; \
60
mkdir -p debian/$(cdbs_curpkg)/$(OCAML_OCAMLDOC_DESTDIR_HTML) ; \
61
echo 'invoking ocamldoc on debian/$(cdbs_curpkg)$(OCAML_STDLIB_DIR)/ ...' ; \
62
find debian/$(cdbs_curpkg)$(OCAML_STDLIB_DIR)/ \
63
-type f -name '*.mli' -or -name '*.ml' \
64
| xargs $$OCAMLDOC $$OCAML_OCAMLDOC_INCLUDE \
65
-html $(OCAML_OCAMLDOC_FLAGS_HTML) \
66
-d debian/$(cdbs_curpkg)/$(OCAML_OCAMLDOC_DESTDIR_HTML) \
70
# post-build hook to create doc-base entries for OCAML_OCAMLDOC_PACKAGES packages
71
$(patsubst %,build/%,$(DEB_PACKAGES))::
72
@if (echo $(OCAML_OCAMLDOC_PACKAGES) $(OCAML_OCAMLDOC_PACKAGES_DOCBASE) \
73
| egrep '( |^)$(cdbs_curpkg)( |$$)' > /dev/null) ; then \
74
$(_cdbs_class_path)/ocamldoc-api-ref-config --doc-base-generate $(cdbs_curpkg) ; \
78
rm -f debian/*.doc-base.ocamldoc-apiref
80
# generate .in files counterpars before building, substituting @OCamlABI@
81
# markers with the proper value; clean stamps after building
83
ocamlinit: ocamlinit-stamp
85
for f in $(OCAML_IN_FILES) ; do \
87
-e 's,@OCamlABI@,$(OCAML_ABI),g' \
88
-e 's,@OCamlStdlibDir@,$(OCAML_STDLIB_DIR),g' \
89
-e 's,@OCamlDllDir@,$(OCAML_DLL_DIR),g' \
94
rm -f ocamlinit-stamp $(OCAML_IN_FILES)
96
# avoid dpatch breaking upon clean if debian/patches/*.in files are in use
97
deapply-dpatches: ocamlinit
99
# update debian/control substituting @OCamlNativeArchs@
100
# XXX ASSUMPTION: debian/control has already been generated, i.e. this rule is
101
# executed after the debian/control:: rule in builcore.mk
102
ifneq ($(DEB_AUTO_UPDATE_DEBIAN_CONTROL),)
104
if test -f debian/control && test -f debian/control.in ; then \
106
-e "s/@OCamlNativeArchs@/$(OCAML_NATIVE_ARCHS)/g" \
107
-e "s/@OCamlTeam@/$(OCAML_TEAM)/g" \