Commit c8045f6d authored by Maximilien Colange's avatar Maximilien Colange

Handle assertions and debugging modes from the ocaml tags file.

parent 04564cfb
......@@ -10,7 +10,7 @@ OCAMLBUILD=ocamlbuild -use-ocamlfind -classic-display -build-dir $(BUILDDIR) @OC
UTAP_INCLUDEDIR=@abs_top_srcdir@/utap/src
UTAP_LIB=@abs_top_srcdir@/utap/src/libutap.a
CXX_FLAGS=-std=c++11 -O3 -DNDEBUG @TIAMO_MACROS@ -I$(UTAP_INCLUDEDIR) -I@abs_top_srcdir@/src
CXX_FLAGS=-std=c++11 @TIAMO_MACROS@ -I$(UTAP_INCLUDEDIR) -I@abs_top_srcdir@/src
XML_LINK_FLAGS=$(foreach i,$(XML_LIBS),-cclib $i)
......
......@@ -40,6 +40,51 @@ AC_SUBST(XML_CONFIG)
AC_SUBST(XML_CFLAGS)
AC_SUBST(XML_LIBS)
OCAMLTAGS=""
dnl Check for debug flags
enableval=no
AC_MSG_CHECKING([whether to compile with debug info])
AC_ARG_ENABLE(debugging,
AS_HELP_STRING([--enable-debugging], [compile with debugging information]))
case "${enableval}" in
yes)
AC_MSG_RESULT(yes)
OPT_FLAGS="$OPT_FLAGS -g"
OCAMLTAGS="$OCAMLTAGS, debug"
;;
no)
AC_MSG_RESULT(no)
OPT_FLAGS="$OPT_FLAGS -O3"
;;
*)
AC_MSG_ERROR([bad value ${enableval} for --enable-debugging, needs yes or no])
;;
esac
enableval=no
AC_MSG_CHECKING([whether to enable checking of run-time assertions])
AC_ARG_ENABLE(assertions,
AS_HELP_STRING([--enable-assertions], [check run-time assertions]))
case "${enableval}" in
yes)
AC_MSG_RESULT(yes)
;;
no)
AC_MSG_RESULT(no)
AC_DEFINE(NDEBUG, 1, [Assertions are disabled when this is defined])
OPT_FLAGS="$OPT_FLAGS -DNDEBUG"
OCAMLTAGS="$OCAMLTAGS, noassert"
;;
*)
AC_MSG_ERROR([bad value ${enableval} --enable-assertions, needs yes or no])
;;
esac
CFLAGS="$OPT_FLAGS"
CPPFLAGS="$OPT_FLAGS"
AC_SUBST(OCAMLTAGS)
AC_SUBST(OCAMLBUILDFLAGS)
AC_CONFIG_SUBDIRS([utap])
......
......@@ -18,8 +18,8 @@ let cxx_flags = ["-xc++"; "-fPIC"; Sys.getenv "CXX_FLAGS"]
(* a helper function *)
(* prefix every c++ flags with -ccopt *)
let ocaml_cxx_flags = fun flags ->
let camlflags = List.flatten (List.map (fun opt -> ["-ccopt"; opt]) (cxx_flags @ flags)) in
S [A "-cc"; A cxx; atomize camlflags]
let camlflags = List.flatten (List.map (fun opt -> ["-ccopt"; opt]) flags) in
atomize camlflags
(* TODO add C options when seeing tags:
* noassert -> add '-DNDEBUG'
......@@ -33,9 +33,13 @@ let _ =
| After_rules ->
(* TODO declare the internal utap library here *)
(* a custom noassert flag, only for compilation, not preprocessing *)
flag ["compile";"noassert"] (A"-noassert");
(* set proper compilation flags for c++ *)
flag ["c++"] (ocaml_cxx_flags []);
flag ["c++"] (S[A"-cc"; A cxx; ocaml_cxx_flags cxx_flags]);
flag ["c++";"debug"] (ocaml_cxx_flags ["-g"]);
flag ["c++";"noassert"] (ocaml_cxx_flags ["-DNDEBUG"]);
(* explicit link dependency for C-based object files *)
pdep ["link"] "linkdep" (fun param -> [param])
......
<*>: bin_annot
<*.c> or <*.cm{o,x}> or <main.native>: debug, custom
<*.c> or <*.cm{o,x}> or <main.native>: custom @OCAMLTAGS@
<main.native>: use_dynlink, linkdep(src/timedAutomatonBuilder.o)
<costs.ml>: pp(camlp4o pa_macro.cmo @TIAMO_MACROS@)
<timedAutomatonBuilder.c>: c++
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment