# # add_file "config.make.in" # # add_file "configure.ac" # # add_file "ocaml.m4" # # patch "Makefile" # from [e29cde2a2e3b69f223b04a4ecb2c7a81f852470d] # to [bb3af8407dd3f0b135fbfaecc3872f0af6389e1f] # # patch "config.make.in" # from [] # to [f5c8ece6dbb2201a5a0d666c353b4b0346aa8f3a] # # patch "configure.ac" # from [] # to [029ca43d56d8741f33ad5377bfc282a47d959412] # # patch "ocaml.m4" # from [] # to [ec43df3f629049753f8f617e3b2702a9161ae48b] # --- Makefile +++ Makefile @@ -1,17 +1,6 @@ -USE_NATIVE = true +include config.make -OCAMLC = ocamlc -OCAMLOPT = ocamlopt -OCAMLLEX = ocamllex -OCAMLYACC = ocamlyacc -OCAMLDEP = ocamldep -CAMLP4O = camlp4o - -MONOTONE_DIR := $(HOME)/src/monotone/monotone-0.17-mt -LABLGTK_DIR := $(HOME)/src/caml/lablgtk/lablgtk-no26/src -CRYPTO_LIB := /usr/lib/libcrypto.a - OCAMLNET := ocamlnet-0.97.1 EXTLIB := extlib-1.3 @@ -41,10 +30,8 @@ OBJ = $(patsubst %.ml,%.cmo,$(filter %.ml, $(SRC))) OBJX = $(patsubst %.ml,%.cmx,$(filter %.ml, $(SRC))) - -NAME = monotone-viz -VERSION = 0.9 -DISTSRC = Makefile monotone-viz.style.sample README NEWS \ +DISTSRC = Makefile configure.ac config.make.in ocaml.m4 configure aclocal.m4 \ + monotone-viz.style.sample README NEWS \ viz_misc.ml viz_misc.mli viz_types.ml viz_types.mli q.ml q.mli \ autocolor.ml autocolor.mli viz_style.ml viz_style.mli heap.ml heap.mli \ dot_types.mli dot_lexer.mll dot_parser.mly \ @@ -60,7 +47,7 @@ crypto/ocaml-openssl.c crypto/crypto.ml crypto/crypto.mli -ifdef USE_NATIVE +ifeq ($(OCAMLBEST), opt) monotone-viz : $(OBJX) lib3rdparty.a $(OCAMLOPT) -o $@ -I . -I $(LABLGTK_DIR) $(MLLIBS) $^ $(CRYPTO_LIB) monotone-viz : MLLIBS = str.cmxa lablgtk.cmxa gtkInit.cmx lablgnomecanvas.cmxa @@ -111,11 +98,15 @@ .PHONY : clean dist +ifeq ($OCAMLBEST, opt) +DEP_FLAGS = -native +endif + -include .depend .depend : $(SRC) @echo "making deps ..." - @$(OCAMLDEP) $(if $(USE_NATIVE),-native) $(addprefix -I ,$(VPATH)) $(filter-out $(USE_P4),$^) > $@ - @$(OCAMLDEP) $(if $(USE_NATIVE),-native) -pp '$(CAMLP4O)' $(USE_P4) >> $@ + @$(OCAMLDEP) $(DEP_FLAGS) $(addprefix -I ,$(VPATH)) $(filter-out $(USE_P4),$^) > $@ + @$(OCAMLDEP) $(DEP_FLAGS) -pp '$(CAMLP4O)' $(USE_P4) >> $@ dist : ../$(NAME)-$(VERSION).tar.gz ../$(NAME)-$(VERSION).tar.gz : $(DISTSRC) @@ -123,3 +114,9 @@ cd .. && mv "$$DIRNAME" $(NAME)-$(VERSION) && \ tar zcvf $(@F) $(addprefix $(NAME)-$(VERSION)/,$(DISTSRC)) && \ mv $(NAME)-$(VERSION) "$$DIRNAME" + +config.make : config.make.in configure + $(error run ./configure) +configure : configure.ac + aclocal -I . + autoconf --- config.make.in +++ config.make.in @@ -0,0 +1,16 @@ +# -*- makefile -*- + +OCAMLBEST = @OCAMLBEST@ +OCAMLC = @OCAMLC@ +OCAMLOPT = @OCAMLOPT@ +OCAMLLEX = @OCAMLLEX@ +OCAMLYACC = @OCAMLYACC@ +OCAMLDEP = @OCAMLDEP@ +CAMLP4O = @CAMLP4O@ + +MONOTONE_DIR := @MONOTONE_DIR@ +LABLGTK_DIR := @LABLGTK_DIR@ +CRYPTO_LIB := /usr/lib/libcrypto.a + +NAME := @PACKAGE_NAME@ +VERSION := @PACKAGE_VERSION@ --- configure.ac +++ configure.ac @@ -0,0 +1,54 @@ +AC_INIT(monotone-viz, 0.9) + +AC_PROG_OCAML +AC_PROG_OCAML_TOOLS +AC_PROG_CAMLP4 + +# Check LablGTK +AC_ARG_WITH([lablgtk-dir], + AS_HELP_STRING([--with-lablgtk-dir], + [specify location of lablgtk library]), + LABLGTK_DIR=$withval) +AC_CHECK_OCAML_MODULE(lablgtk, LABLGTK_DIR, GFile, +lablgtk2 +lablgtk) +# Stop if LablGTK is not found +if test -z "$LABLGTK_DIR" ; then + AC_MSG_ERROR([dnl +Could not find LablGTK. Make sure LablGTK >= 2.4.0 is installed and specify its location to configure with the `--with-lablgtk-dir' option.]) +fi +LABLGTK_DIR=$(echo $LABLGTK_DIR | sed "address@hidden@$OCAMLLIB/@") +# Check if LablGTK was compiled with libgnomecanvas support +AC_MSG_CHECKING([GnomeCanvas support]) +if test -r "$LABLGTK_DIR/lablgnomecanvas.cma" ; then + AC_MSG_RESULT(found) +else + AC_MSG_ERROR([dnl +libgnomecanvas support not found. LablGTK need to be built with GnomeCanvas support.]) +fi +# Check if LablGTK is natively compiled +if test -r "$LABLGTK_DIR/lablgtk.cmxa" -a -r "$LABLGTK_DIR/lablgnomecanvas.cmxa"; then + echo [Using the native code compiler] +else + echo [Using the byte code compiler] + OCAMLBEST=byte +fi + + +# Check the sqlite3 sources +AC_ARG_WITH([monotone-dir], + AS_HELP_STRING([--with-monotone-dir], + [specify location of monotone build tree]), + MONOTONE_DIR=$withval, + MONOTONE_DIR=monotone) +AC_MSG_CHECKING(sqlite sources) +if test -d "$MONOTONE_DIR" -a -r "$MONOTONE_DIR/sqlite/lib3rdparty_a-main.o" ; then + AC_MSG_RESULT(found in $MONOTONE_DIR/sqlite) +else + AC_MSG_ERROR([dnl +Could not find compiled sqlite sources. Monotone-viz needs a compiled monotone tree for the sqlite library. Create a link named `monotone' or specify the location to configure using the `--with-monotone-dir' option.]) +fi +if test "${MONOTONE_DIR:0:1}" != "/" ; then + MONOTONE_DIR=$PWD/$MONOTONE_DIR +fi +AC_SUBST(MONOTONE_DIR) + +AC_OUTPUT(config.make) --- ocaml.m4 +++ ocaml.m4 @@ -0,0 +1,209 @@ +dnl -*- autoconf -*- macros for OCaml +dnl by Olivier Andrieu +dnl from a configure.in by Jean-Christophe FilliĆ¢tre, +dnl from a first script by Georges Mariano +dnl +dnl defines AC_PROG_OCAML that will check the OCaml compiler +dnl and set the following variables : +dnl OCAMLC "ocamlc" if present in the path, or a failure +dnl or "ocamlc.opt" if present with same version number as ocamlc +dnl OCAMLOPT "ocamlopt" (or "ocamlopt.opt" if present), or unset +dnl OCAMLBEST either "byte" if no native compiler was found, +dnl "opt" otherwise +dnl OCAMLDEP "ocamldep" +dnl OCAMLLIB the path to the ocaml standard library +dnl OCAMLVERSION the ocaml version number +dnl +dnl OCAMLMKTOP +dnl OCAMLMKLIB +dnl OCAMLDOC +AC_DEFUN([AC_PROG_OCAML], +[dnl +# checking for ocamlc +AC_CHECK_PROG(OCAMLC,ocamlc,ocamlc,AC_MSG_ERROR(Cannot find ocamlc.)) +OCAMLVERSION=$($OCAMLC -version) +AC_MSG_RESULT(OCaml version is $OCAMLVERSION) +OCAMLLIB=$($OCAMLC -where) +AC_MSG_RESULT(OCaml library path is $OCAMLLIB) +# checking for ocamlopt +AC_CHECK_PROG(OCAMLOPT,ocamlopt,ocamlopt) +OCAMLBEST=byte +if test -z "$OCAMLOPT"; then + AC_MSG_WARN(Cannot find ocamlopt; bytecode compilation only.) +else + TMPVERSION=$($OCAMLOPT -version) + if test "$TMPVERSION" != "$OCAMLVERSION" ; then + AC_MSG_RESULT(versions differs from ocamlc; ocamlopt discarded.) + unset OCAMLOPT + else + OCAMLBEST=opt + fi +fi +# checking for ocamlc.opt +AC_CHECK_PROG(OCAMLCDOTOPT,ocamlc.opt,ocamlc.opt) +if test "$OCAMLCDOTOPT"; then + TMPVERSION=$($OCAMLCDOTOPT -version) + if test "$TMPVERSION" != "$OCAMLVERSION" ; then + AC_MSG_RESULT(versions differs from ocamlc; ocamlc.opt discarded.) + else + OCAMLC=$OCAMLCDOTOPT + fi +fi +# checking for ocamlopt.opt +if test "$OCAMLOPT" ; then + AC_CHECK_PROG(OCAMLOPTDOTOPT,ocamlopt.opt,ocamlopt.opt) + if test "$OCAMLOPTDOTOPT"; then + TMPVERSION=$($OCAMLOPTDOTOPT -version) + if test "$TMPVERSION" != "$OCAMLVERSION" ; then + AC_MSG_RESULT(version differs from ocamlc; ocamlopt.opt discarded.) + else + OCAMLOPT=$OCAMLOPTDOTOPT + fi + fi +fi +# checking for ocamldep +AC_CHECK_PROG(OCAMLDEP,ocamldep,ocamldep,AC_MSG_ERROR(Cannot find ocamldep.)) + +#checking for ocamlmktop +AC_CHECK_PROG(OCAMLMKTOP,ocamlmktop,ocamlmktop, AC_MSG_WARN(Cannot find ocamlmktop.)) +#checking for ocamlmklib +AC_CHECK_PROG(OCAMLMKLIB,ocamlmklib,ocamlmklib, AC_MSG_WARN(Cannot find ocamlmklib.)) +# checking for ocamldoc +AC_CHECK_PROG(OCAMLDOC,ocamldoc,ocamldoc, AC_MSG_WARN(Cannot find ocamldoc.)) + +# get the C compiler used by ocamlc +if test -z "$CC" ; then + touch conftest.c + CC=$($OCAMLC -verbose conftest.c 2>&1 | awk '/^+/ {print $[]2 ; exit}') + echo OCaml uses $CC to compile C files +fi + +AC_SUBST(OCAMLC) +AC_SUBST(OCAMLOPT) +AC_SUBST(OCAMLDEP) +AC_SUBST(OCAMLBEST) +AC_SUBST(OCAMLVERSION) +AC_SUBST(OCAMLLIB) +AC_SUBST(OCAMLMKLIB) +AC_SUBST(OCAMLMKTOP) +AC_SUBST(OCAMLDOC) +]) +dnl +dnl +dnl +dnl macro AC_PROG_OCAML_TOOLS will check OCamllex and OCamlyacc : +dnl OCAMLLEX "ocamllex" or "ocamllex.opt" if present +dnl OCAMLYACC "ocamlyac" +AC_DEFUN([AC_PROG_OCAML_TOOLS], +[dnl +# checking for ocamllex and ocamlyacc +AC_CHECK_PROG(OCAMLLEX,ocamllex,ocamllex,AC_MSG_ERROR(Cannot find ocamllex.)) +if test "$OCAMLLEX"; then + AC_CHECK_PROG(OCAMLLEXDOTOPT,ocamllex.opt,ocamllex.opt) + if test "$OCAMLLEXDOTOPT"; then + OCAMLLEX=$OCAMLLEXDOTOPT + fi +else + AC_MSG_ERROR(Cannot find ocamllex.) +fi +AC_CHECK_PROG(OCAMLYACC,ocamlyacc,ocamlyacc,AC_MSG_ERROR(Cannot find ocamlyacc.)) +AC_SUBST(OCAMLLEX) +AC_SUBST(OCAMLYACC) +]) +dnl +dnl +dnl +dnl AC_PROG_CAMLP4 checks for Camlp4 +AC_DEFUN([AC_PROG_CAMLP4], +[dnl +AC_REQUIRE([AC_PROG_OCAML]) +# checking for camlp4 +AC_CHECK_PROG(CAMLP4,camlp4,camlp4) +if test "$CAMLP4"; then + TMPVERSION=$($CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p') + if test "$TMPVERSION" != "$OCAMLVERSION" ; then + AC_MSG_ERROR(versions differs from ocamlc) + else + AC_CHECK_PROG(CAMLP4O,camlp4o,camlp4o) + fi +fi +AC_SUBST(CAMLP4) +AC_SUBST(CAMLP4O) +]) +dnl +dnl +dnl +dnl macro AC_PROG_FINDLIB will check for the presence of +dnl ocamlfind if configure is called with --with-findlib +AC_DEFUN([AC_PROG_FINDLIB], +[dnl +AC_ARG_WITH(findlib,[ --with-findlib use findlib package system], + use_findlib="$withval") +# checking for ocamlfind +if test "$use_findlib" = yes ; then + AC_CHECK_PROG(OCAMLFIND,ocamlfind,ocamlfind, + AC_MSG_ERROR(ocamlfind not found)) +else + unset OCAMLFIND +fi +AC_SUBST(OCAMLFIND) +]) +dnl +dnl +dnl +dnl AC_CHECK_OCAML_PKG checks wether a findlib package is present +dnl defines pkg_name to name +AC_DEFUN([AC_CHECK_OCAML_PKG], +[dnl +AC_REQUIRE([AC_PROG_FINDLIB]) +if test "$use_findlib" = yes ; then + AC_MSG_CHECKING(findlib package $1) + if $OCAMLFIND query $1 >/dev/null 2>/dev/null; then + AC_MSG_RESULT(found) + pkg_$1="$1" + else + AC_MSG_WARN(not found) + unset pkg_$1 + fi +fi +]) +dnl +dnl +dnl +dnl AC_ARG_OCAML_INSTALLDIR adds a --with-installdir option +AC_DEFUN([AC_ARG_OCAML_INSTALLDIR], +[dnl +AC_ARG_WITH(installdir,[ --with-installdir=DIR specify installation directory],INSTALLDIR="$withval") +if ! test "$INSTALLDIR" -o "$use_findlib" ; then + INSTALLDIR='$(OCAMLLIB)/$(NAME)' +fi +AC_SUBST(INSTALLDIR) +]) +dnl +dnl +dnl +dnl AC_CHECK_OCAML_MODULE looks for a module in a given path +dnl 1 -> name (for printing) +dnl 2 -> env var name +dnl 3 -> module to check +dnl 4 -> default dirs +AC_DEFUN([AC_CHECK_OCAML_MODULE], +[dnl +AC_MSG_CHECKING($1 directory) +cat > conftest.ml < /dev/null 2>&1 ; then + found=yes + break + fi +done +if test "$found" ; then + AC_MSG_RESULT($$2) +else + AC_MSG_RESULT(not found) + unset $2 +fi +AC_SUBST($2)])