Added a build system for Heptagon

./configure 
make
make install
master
Cédric Pasteur 13 years ago
parent 81ad14ab7b
commit f4aafa10d6

@ -0,0 +1,13 @@
.PHONY: all install
all:
(cd compiler/; $(MAKE))
(cd lib; $(MAKE))
install:
(cd compiler; $(MAKE) install)
(cd lib; $(MAKE) install)
clean:
(cd compiler; $(MAKE) clean)
(cd lib; $(MAKE) clean)

14
aclocal.m4 vendored

@ -0,0 +1,14 @@
# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
m4_include([m4/ocaml.m4])

@ -1,24 +1,49 @@
include ../config
BUILD:= _build
OCAMLBUILD:=ocamlbuild
COMPILER:=heptc
ifeq ($(ENABLE_SIMULATOR), yes)
BIN:=heptc.$(TARGET) hepts.$(TARGET)
else
BIN:=heptc.$(TARGET)
endif
TARGET:=byte
.PHONY: all opt byte debug profile clean
.PHONY: all clean opt byte clean debug install
all: $(TARGET)
opt:
ifeq ($(ENABLE_SIMULATOR), yes)
$(OCAMLBUILD) $(COMPILER).native $(SIMULATOR).native
else
$(OCAMLBUILD) $(COMPILER).native
endif
byte:
ifeq ($(ENABLE_SIMULATOR), yes)
$(OCAMLBUILD) $(COMPILER).byte $(SIMULATOR).byte
else
$(OCAMLBUILD) $(COMPILER).byte
endif
debug:
ifeq ($(ENABLE_SIMULATOR), yes)
$(OCAMLBUILD) $(COMPILER).d.byte $(SIMULATOR).d.byte
else
$(OCAMLBUILD) $(COMPILER).d.byte
endif
profile:
ifeq ($(ENABLE_SIMULATOR), yes)
$(OCAMLBUILD) $(COMPILER).p.native $(SIMULATOR).p.native
else
$(OCAMLBUILD) $(COMPILER).p.native
endif
install: all
$(INSTALL) -d $(INSTALL_BINDIR)
$(INSTALL) $(COMPILER).$(TARGET) $(INSTALL_BINDIR)/$(COMPILER)
ifeq ($(ENABLE_SIMULATOR), yes)
$(INSTALL) $(COMPILER).$(TARGET) $(INSTALL_BINDIR)/$(SIMULATOR)
endif
clean:
$(OCAMLBUILD).native -clean
$(OCAMLBUILD) -clean

@ -1,10 +1,8 @@
<global> or <utilities> or <minils> or <heptagon> or <main> or <obc>:include
<**/*.ml>: debug, dtypes
<**/*.ml>: debug, dtypes, pkg_ocamlgraph
<preproc.ml>: camlp4of, use_camlp4
<**/hept_parser.ml>: use_menhirLib
<**/mls_parser.ml>: use_menhirLib
<**/*.{byte,native}>: use_unix, use_str, link_menhirLib, link_graph, debug
true: use_menhir, use_graph
true:use_menhir
<**/*.{byte,native}>: use_unix, use_str, debug, pkg_menhirLib, pkg_ocamlgraph
<main/hepts.ml>: use_lablgtk, thread
<main/hepts.{byte,native}>: use_lablgtk, use_lablgtkthread, thread
<main/hepts.ml>: pkg_lablgtk2, thread
<main/hepts.{byte,native}>: pkg_lablgtk2, thread

@ -0,0 +1 @@
<hept_parser.ml>: pkg_menhirLib

@ -1,26 +1,15 @@
open Ocamlbuild_plugin
open Ocamlbuild_plugin.Options
open Myocamlbuild_config
let df = function
| Before_options -> ocamlfind_before_options ()
| After_rules ->
ocamlfind_after_rules ();
(* Tell ocamlbuild about the camlp4 library. *)
ocaml_lib ~extern:true ~dir:"+camlp4" "camlp4";
(* Tell ocamlbuild about Menhir library (needed by --table). *)
ocaml_lib ~extern:true ~dir:"+menhirLib" "menhirLib";
(* Tell ocamlbuild about the ocamlgraph library. *)
ocaml_lib ~extern:true ~dir:"+ocamlgraph" "graph";
(* Menhir does not come with menhirLib.cmxa so we have to manually by-pass
OCamlbuild's built-in logic and add the needed menhirLib.cmxa. *)
flag ["link"; "native"; "link_menhirLib"] (S [A "-I"; A "+menhirLib";
A "menhirLib.cmx"]);
flag ["link"; "byte"; "link_menhirLib"] (S [A "-I"; A "+menhirLib";
A "menhirLib.cmo"]);
(* Add preproc.cmo to the ocaml pre-processor when use_preproc is set *)
flag ["ocaml"; "pp"; "use_preproc"] (A "preproc.cmo");
@ -30,10 +19,6 @@ let df = function
ocamlbuild. *)
dep ["ocaml"; "ocamldep"; "use_preproc"] ["preproc.cmo"];
(* LablGTK use for graphical simulator *)
ocaml_lib ~extern:true ~dir:"+lablgtk2" "lablgtk";
ocaml_lib ~extern:true "lablgtkthread";
flag ["ocaml"; "parser" ; "menhir" ; "use_menhir"] (S[A"--explain";
A"--table"]);

@ -0,0 +1,80 @@
open Ocamlbuild_plugin
(* these functions are not really officially exported *)
let run_and_read = Ocamlbuild_pack.My_unix.run_and_read
let blank_sep_strings = Ocamlbuild_pack.Lexers.blank_sep_strings
let split s ch =
let x = ref [] in
let rec go s =
let pos = String.index s ch in
x := (String.before s pos)::!x;
go (String.after s (pos + 1))
in
try
go s
with Not_found -> !x
let split_nl s = split s '\n'
let before_space s =
try
String.before s (String.index s ' ')
with Not_found -> s
(* this lists all supported packages *)
let find_packages () =
List.map before_space (split_nl & run_and_read "ocamlfind list")
(* this is supposed to list available syntaxes, but I don't know how to do it. *)
let find_syntaxes () = ["camlp4o"; "camlp4r"]
(* ocamlfind command *)
let ocamlfind x = S[A"ocamlfind"; x]
let ocamlfind_before_options () =
(* by using Before_options one let command line options have an higher priority *)
(* on the contrary using After_options will guarantee to have the higher priority *)
(* override default commands by ocamlfind ones *)
Options.ocamlc := ocamlfind & A"ocamlc";
Options.ocamlopt := ocamlfind & A"ocamlopt";
Options.ocamldep := ocamlfind & A"ocamldep";
Options.ocamldoc := ocamlfind & A"ocamldoc";
Options.ocamlmktop := ocamlfind & A"ocamlmktop"
let ocamlfind_after_rules () =
(* When one link an OCaml library/binary/package, one should use -linkpkg *)
flag ["ocaml"; "link"; "program"] & A"-linkpkg";
(* For each ocamlfind package one inject the -package option when
* compiling, computing dependencies, generating documentation and
* linking. *)
List.iter begin fun pkg ->
flag ["ocaml"; "compile"; "pkg_"^pkg] & S[A"-package"; A pkg];
flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S[A"-package"; A pkg];
flag ["ocaml"; "doc"; "pkg_"^pkg] & S[A"-package"; A pkg];
flag ["ocaml"; "link"; "pkg_"^pkg] & S[A"-package"; A pkg];
flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S[A"-package"; A pkg];
end (find_packages ());
(* Like -package but for extensions syntax. Morover -syntax is useless
* when linking. *)
List.iter begin fun syntax ->
flag ["ocaml"; "compile"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
flag ["ocaml"; "ocamldep"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
flag ["ocaml"; "doc"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
flag ["ocaml"; "infer_interface"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
end (find_syntaxes ());
(* The default "thread" tag is not compatible with ocamlfind.
Indeed, the default rules add the "threads.cma" or "threads.cmxa"
options when using this tag. When using the "-linkpkg" option with
ocamlfind, this module will then be added twice on the command line.
To solve this, one approach is to add the "-thread" option when using
the "threads" package using the previous plugin.
*)
flag ["ocaml"; "pkg_threads"; "compile"] (S[A "-thread"]);
flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]);
flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"])

@ -30,8 +30,12 @@ let date =
(** [stdlib] is the location of the standard Heptagon library. *)
let stdlib =
let wd = Unix.getcwd () in
Filename.concat (Filename.dirname (Filename.dirname wd)) "lib"
try
Unix.getenv "STDLIB"
with
| Not_found ->
let wd = Unix.getcwd () in
Filename.concat (Filename.dirname (Filename.dirname wd)) "lib"
(** Association list defining bindings between constant and our "compile-time
constants". *)

@ -0,0 +1,22 @@
srcdir = .
top_srcdir = .
prefix = /opt/local
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
libdir = ${exec_prefix}/lib
INSTALL= /usr/bin/install -c
MAKE= @MAKE@
BUILD= _build
COMPILER=heptc
SIMULATOR=hepts
INSTALL_BINDIR=$(bindir)
INSTALL_LIBDIR=$(libdir)/heptagon
STDLIB_DIR=${exec_prefix}/lib/heptagon
OCAMLBUILD=STDLIB=$(STDLIB_DIR) ocamlbuild
TARGET=byte
ENABLE_SIMULATOR=yes

@ -0,0 +1,22 @@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
INSTALL= @INSTALL@
MAKE= @MAKE@
BUILD= _build
COMPILER=heptc
SIMULATOR=hepts
INSTALL_BINDIR=$(bindir)
INSTALL_LIBDIR=$(libdir)/heptagon
STDLIB_DIR=@stdlib_dir@
OCAMLBUILD=STDLIB=$(STDLIB_DIR) @OCAMLBUILD@
TARGET=byte
ENABLE_SIMULATOR=@enable_simulator@

4238
configure vendored

File diff suppressed because it is too large Load Diff

@ -0,0 +1,60 @@
AC_INIT(heptagon,1.0)
AC_PROG_INSTALL
AC_ARG_ENABLE(simulator,
[ --enable-simulator enable Why3 IDE],,
enable_simulator=no)
AC_ARG_ENABLE(local_stdlib,
[ --enable-local-stdlib Use the standard library in the source tree],,
enable_local_stdlib=no)
AC_PROG_OCAML
if test "$OCAMLC" = "no"; then
AC_MSG_ERROR([Please install the OCaml compiler])
fi
case "$OCAMLVERSION" in
0.*|1.*|2.*|3.0*)
AC_MSG_ERROR(You need Objective Caml 3.10 or higher);;
esac
AC_PROG_FINDLIB
if test "$OCAMLFIND" = "no"; then
AC_MSG_ERROR([Please install OCaml findlib (the ocamlfind command)])
fi
AC_CHECK_PROG(MENHIR,menhir,menhir,no)
if test "$MENHIR" = no ; then
AC_MSG_ERROR(Please install menhir.)
fi
AC_CHECK_OCAML_PKG([menhirLib])
if test "$OCAML_PKG_menhirLib" = "no"; then
AC_MSG_ERROR([Please install menhirLib package.])
fi
AC_CHECK_OCAML_PKG([ocamlgraph])
if test "$OCAML_PKG_ocamlgraph" = "no"; then
AC_MSG_ERROR([Please install ocamlgraph package.])
fi
AC_CHECK_OCAML_PKG([lablgtk2])
if test "$OCAML_PKG_lablgtk2" = "no"; then
enable_simulator=no
AC_MSG_WARN([Could not find 'lablgtk2'. The simulator will not be built])
fi
if test "$enable_local_stdlib" = "yes"; then
stdlib_dir=$srcdir/lib
else
stdlib_dir=$libdir/heptagon
fi
AC_SUBST(INSTALL)
AC_SUBST(stdlib_dir)
AC_SUBST(enable_simulator)
AC_OUTPUT(config)
Loading…
Cancel
Save