From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA31743; Fri, 6 Sep 2002 11:42:32 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA31915 for ; Fri, 6 Sep 2002 11:42:31 +0200 (MET DST) Received: from tcs.inf.tu-dresden.de (tcs.inf.tu-dresden.de [141.76.75.101]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g869gV113092 for ; Fri, 6 Sep 2002 11:42:31 +0200 (MET DST) Received: from ithif51 (ithif51 [141.76.75.51]) by tcs.inf.tu-dresden.de (8.12.0.Beta7/8.12.0.Beta7) with ESMTP id g869gU3f022204 for ; Fri, 6 Sep 2002 11:42:30 +0200 (MET DST) Received: from tews by ithif51 with local (Exim 3.12 #1 (Debian)) id 17nFdG-0003OR-00 for ; Fri, 06 Sep 2002 11:42:30 +0200 From: Hendrik Tews MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15736.30854.341472.383808@gargle.gargle.HOWL> Date: Fri, 6 Sep 2002 11:42:30 +0200 (CEST) To: caml-list@inria.fr Subject: Re: [Caml-list] autoconf and caml In-Reply-To: <20020905135720.D5343@pauillac.inria.fr> References: <20020905135720.D5343@pauillac.inria.fr> X-Mailer: VM 6.75 under Emacs 20.7.2 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > 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