#!/usr/bin/make -f
include /usr/share/cdbs/1/class/makefile.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/ocaml.mk

PKGNAME = camlp5
OCAML_OCAMLDOC_PACKAGES = $(PKGNAME)
OCAML_OCAMLDOC_FLAGS += -pp debian/camlp5r_w_macro.sh
OCAML_OCAMLDOC_FLAGS += -I +compiler-libs/parsing/
OCAML_DHOCAML_FLAGS += \
  --runtime-map camlp5 \
  --nodefined-map camlp5:Dynlinkaux,Dynlink # temporary hack, should be fixed

CONFIGURE_FLAGS =
CONFIGURE_FLAGS += -mandir /usr/share/man

DEB_INSTALL_DOCS_ALL := -X.cvsignore
DEB_MAKE_INSTALL_TARGET = install DESTDIR=$(CURDIR)/debian/tmp
ifeq ($(OCAML_HAVE_OCAMLOPT),yes)
DEB_MAKE_BUILD_TARGET = world.opt
else
DEB_MAKE_BUILD_TARGET = world
endif

configure/$(PKGNAME):: debian/configure-stamp
debian/configure-stamp:
	./configure $(CONFIGURE_FLAGS)
	touch debian/configure-stamp
clean::
	rm -f debian/configure-stamp
	rm -f doc/html/*.html config/Makefile config/Makefile.cnf myconfig
	rm -Rf doc/html/rss
	rm -f ocaml_src/lib/versdep.ml

pre-build:: debian/META
debian/META: debian/META.src
	sed 's/@NAME@/$(PKGNAME)/g' < $< > $@
clean::
	rm -f debian/META

build/$(PKGNAME)::
	$(MAKE) -C doc/htmlp/
	chmod +x debian/camlp5r_w_macro.sh
