Hi Kalzium of KDE 3.5 supports a solver for chemical equations. The solver is written by Thomas Nagy in OCaml. AFAIK (and google tells me) CMake does not support OCaml right now. Unsermake/autotools didn't support it either, so we created a static Makefile (attached) which worked on most systems and the following ugly configure.in-check. I would now like to activate OCaml in Kalzium but have not the slightest idea how to do that...
Carsten
PS: facile (libfacile) is a lib written in OCaml we use for the solver.
ocaml_installed=no
facile_installed=no
eqchem_enabled=no
AC_DEFUN([OCAML_PROG],[
KDE_FIND_PATH(ocamlopt, OCAML, [$bindir],
[
OCAML=''
])
])
AC_DEFUN([FACILE_PROG],[
AC_REQUIRE([OCAML_PROG])
AC_MSG_CHECKING([if the facile constraint solver is installed])
FACILE="`ocamlopt -where`/facile"
if test -d "$FACILE" ; then
eqchem_enabled=yes
AC_MSG_RESULT([yes])
facile_installed=yes
else
eqchem_enabled=no
AC_MSG_RESULT([no])
facile_installed=no
fi
AC_SUBST([FACILE])
])
AC_ARG_ENABLE( ocamlsolver,
[ --disable-ocamlsolver Disable support for the OCaml solver
@<:@default=check@:>@]],
[ with_ocamlsolver=$enableval ],
[ with_ocamlsolver=check] )
if test "x$with_ocamlsolver" != xno; then
OCAML_PROG
if test -n "$OCAML"; then
ocaml_installed=yes
FACILE_PROG
fi
AH_TEMPLATE(HAVE_FACILE, facile solver available?)
EQCHEM_SUB=
OCAMLLIB=
EQCHEM_LDADD=
if test "$eqchem_enabled" = "yes"; then
EQCHEM_SUB=solver
OCAMLLIB=`ocamlc -where`
FACILELIB=`ocamlc -where`/facile
EQCHEM_LDADD="-lasmrun -lstr -lnums -lm -ldl solver.o modwrap.o"
AC_DEFINE(HAVE_FACILE, 1)
fi
AC_SUBST(EQCHEM_SUB)
AC_SUBST(OCAMLLIB)
AC_SUBST(FACILELIB)
AC_SUBST(EQCHEM_LDADD)
if test "$eqchem_enabled" = "yes"; then
with_ocamlsolver=yes
fi
fi
OCAMLC = ocamlc -g
OCAMLMLI = ocamlc
OCAMLOPT = ocamlopt
OCAMLDEP = ocamldep
INCLUDES = -I +facile
OPTOPT =
OCAMLLIB := `ocamlc -where`
FACILELIB = $(OCAMLLIB)/facile
# link to these libraries
LIBADD_CMX = $(OCAMLLIB)/facile/facile.cmxa #$(OCAMLLIB)/str.cmxa
LIBADD_CMO = $(OCAMLLIB)/facile/facile.cma #$(OCAMLLIB)/str.cma
# our sources
SOURCES_CHEM = chemset.ml parser.ml lexer.ml datastruct.ml chem.ml calc.ml
SOURCES_WRAP = modwrap.c
# the targets
CHEM_CMO = $(SOURCES_CHEM:.ml=.cmo)
CHEM_CMX = $(SOURCES_CHEM:.ml=.cmx)
CHEM_O = $(SOURCES_WRAP:.c=.o)
# default target : the object files for eqchem
all : solver.o
# shows how to build a program that embeds the solver
# in compiled ocaml, bytecode ocaml and compiled program using compiled caml code
test: atestprog.opt btestprog.out testcprog
atestprog.opt: $(CHEM_CMX) main.cmx
$(OCAMLOPT) -o $@ $(LIBADD_CMX) $(CHEM_CMX) main.cmx
btestprog.out: $(CHEM_CMO) main.cmo
$(OCAMLMLI) -o $@ $(LIBADD_CMO) $(CHEM_CMO) main.cmo
solver.o: $(CHEM_CMX) $(CHEM_O)
$(OCAMLOPT) -output-obj -o solver.o $(LIBADD_CMX) $(CHEM_CMX)
cp -f solver.o modwrap.o ../
testcprog: $(CHEM_CMX) $(CHEM_O)
$(OCAMLOPT) -output-obj -o solver.o $(LIBADD_CMX) $(CHEM_CMX) modwrap.o
gcc -c -o main.o main.c -L $(OCAMLLIB)
gcc -o $@ main.o solver.o -L $(OCAMLLIB) \
-L $(OCAMLLIB)/facile -lasmrun -lstr -lnums -lm -ldl modwrap.o
.SUFFIXES:
.SUFFIXES: .ml .mli .mly .mll .cmi .cmo .cmx .p.cmx .c
.ml.cmo :
$(OCAMLC) $(INCLUDES) $(INCLUDES) -c $<
.mli.cmi :
$(OCAMLMLI) $(INCLUDES) -c $<
.ml.cmx :
$(OCAMLOPT) $(OPTOPT) $(INCLUDES) -c $<
.mly.ml :
ocamlyacc $<
.mll.ml :
ocamllex $<
%.o : %.c
$(OCAMLOPT) $(OPTOPT) $(INCLUDES) -c $<
clean:
\rm -f *.cm[iox] *.o *~ .depend *testprog.* testcprog
cleanall : clean
\rm -f *.cmxa *.a *.cma
distclean : clean
interfaces:
ocamlc -i datastruct.ml > datastruct.mli
ocamlc -I +facile -i chem.ml > chem.mli
ocamlc -I +facile -i calc.ml > calc.mli
maintainer-clean : clean
uninstall : clean
install :
echo "done"
.depend: parser.ml lexer.ml
$(OCAMLDEP) $(INCLUDES) *.mli *.ml > $@
include .depend
pgpCRvnE27BI6.pgp
Description: PGP signature
_______________________________________________ Kde-buildsystem mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-buildsystem
