[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Hendrik Tews <tews@t...> |
| Subject: | Re: [Caml-list] autoconf and caml |
> I'm writing a piece of software using O'Caml and GNU autoconf (among
> others). In C the results of running `./configure' are conveniently
> accessed with `#include "config.h"'. My current solution is to
> preprocess also the O'Caml code, but this requires some clumsy hacks
> in Makefiles etc. Is there a better way? If not, then I'ld suggest
> some flag in O'Caml which would run the source files through cpp.
Why not writing Ocaml files directly through configure? Just set
your own variables and apply AC_SUBST to them. And if you need
conditional compilation use camlp4 and pa_ifdef.
In our Ocaml project I let configure write a shell script and
invoke the shell script immediately to write other files
(including ml files). The redirection via a shell script is
necessary because configure might output something like
prefix=/usr/local
libdir=${prefix}/lib
Here are fragments from the relevant files, you can inspect the
full source code at
http://wwwtcs.inf.tu-dresden.de/~tews/ccsl/#getandrun.
configure.in fragment
=============================
AC_OUTPUT(Makefile varsubst.sh, sh varsubst.sh)
=============================
varsubst.sh.in
========================================================================
files="Common/config.ml Doc/ccslc.1 Doc/ccslc.html"
prefix=/usr/local
exec_prefix=${prefix}
libdir=/home/tews/Privat/Coda/Work2/Lib/Pvs
echo writing files $files
for f in $files ; do
# echo sed -e "s%@mllibdir@%$libdir%" \< ${mlconfigfile}.in \> ${mlconfigfile}
echo writing $f
sed -e "s%@mllibdir@%$libdir%" < $f.in > $f
done
=======================================================================
Common/config.ml.in
===========================================================
let fixedpointlib = "@mllibdir@"
===========================================================
Bye,
Hendrik
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners