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

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to