caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Hendrik Tews <tews@tcs.inf.tu-dresden.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] autoconf and caml
Date: Fri, 6 Sep 2002 11:42:30 +0200 (CEST)	[thread overview]
Message-ID: <15736.30854.341472.383808@gargle.gargle.HOWL> (raw)
In-Reply-To: <20020905135720.D5343@pauillac.inria.fr>

   
> 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


      parent reply	other threads:[~2002-09-06  9:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-04 15:20 Kenneth Oksanen
2002-09-05 11:57 ` Xavier Leroy
2002-09-05 12:23   ` Kenneth Oksanen
2002-09-05 12:53     ` Olivier Andrieu
2002-09-05 13:16     ` Lauri Alanko
2002-09-06 10:12       ` Kenneth Oksanen
2002-09-06 10:25         ` Jun P.FURUSE
2002-09-06 10:46         ` Yann Régis-Gianas
2002-09-06 10:56           ` Yaron M. Minsky
2002-09-06 11:07             ` Maxence Guesdon
2002-09-06 12:31               ` pa_ifdef [Was: Re: [Caml-list] autoconf and caml] Stefano Zacchiroli
2002-09-06 12:52                 ` Daniel de Rauglaudre
2002-09-08 10:07                   ` Stefano Zacchiroli
2002-09-09  8:59                     ` Daniel de Rauglaudre
2002-09-06 11:33             ` [Caml-list] autoconf and caml Yann Régis-Gianas
2002-09-06 11:22               ` Yaron M. Minsky
2002-09-06 11:28                 ` Jérôme Marant
2002-09-06 11:41                   ` Yaron M. Minsky
2002-09-06  9:42   ` Hendrik Tews [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15736.30854.341472.383808@gargle.gargle.HOWL \
    --to=tews@tcs.inf.tu-dresden.de \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).