caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
To: Edgar Friendly <thelema314@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Conditional compilation
Date: Tue, 18 Aug 2009 11:20:41 +0100	[thread overview]
Message-ID: <20090818102041.GA4353@annexia.org> (raw)
In-Reply-To: <4A8A0B3C.10504@gmail.com>

On Mon, Aug 17, 2009 at 10:00:28PM -0400, Edgar Friendly wrote:
> Is there a better way to do this?  The path I'm following is looking
> very byzantine compared to C's [-DFOO] + [#ifdef FOO].

You can just use autoconf's ordinary features:

eg:

  AC_ARG_ENABLE([foo],
          [AS_HELP_STRING([--enable-foo],
            [enable foo @<:@default=no@:>@])],
          [],
          [enable_foo=no])
  
  # Define an automake conditional:
  AM_CONDITIONAL([FOO],[test "x$enable_foo" = "xyes"])
  
  # Define an autoconf substitution:
  if test "x$enable_foo" = "xyes"; then
    FOO=1
  else
    FOO=0
  fi
  AC_SUBST(FOO)

And then in Makefile.am you can use:

  ifdef FOO
  FLAGS = -DFOO=1
  else
  FLAGS =
  endif

and in any autoconf-substituted files you can use:

  @FOO@

We use autoconf/automake with OCaml code all the time, and it works
fine.  There are also OCaml macros available:

  http://forge.ocamlcore.org/projects/ocaml-autoconf/
  http://git.ocamlcore.org/cgi-bin/gitweb.cgi?p=ocaml-autoconf/ocaml-autoconf.git;a=summary

Rich.

-- 
Richard Jones
Red Hat


      parent reply	other threads:[~2009-08-18 10:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-18  2:00 Edgar Friendly
2009-08-18  2:26 ` [Caml-list] " Andre Nathan
2009-08-18  2:37   ` Edgar Friendly
2009-08-18  7:00     ` Olivier Andrieu
2009-08-21  9:39   ` Pietro Abate
2009-08-18 10:20 ` Richard Jones [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=20090818102041.GA4353@annexia.org \
    --to=rich@annexia.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=thelema314@gmail.com \
    /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).