forked from ocaml/Zarith
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
211 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## 1.12+dune (2022-04-01) | ||
|
||
- PR #1: dunify the package and allow the cross-compilation via `opam monorepo` | ||
[Romain Calascibetta, Lucas Pluvinage, Thomas Gazagnaire] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
let () = Printexc.record_backtrace true | ||
|
||
let () = | ||
if Array.length Sys.argv <> 2 then ( | ||
print_endline "Usage: ./configure_env.exe %{cc}"; | ||
exit 1) | ||
|
||
let uname () = | ||
let ic = Unix.open_process_in "uname -s" in | ||
let s = input_line ic in | ||
String.trim s | ||
|
||
module Var : sig | ||
val os : string | ||
val is_homebrew_amr64 : bool | ||
end = struct | ||
let is_homebrew_amr64 = Sys.file_exists "/opt/homebrew/bin/brew" | ||
|
||
let normalise raw = | ||
match String.lowercase_ascii raw with "darwin" | "osx" -> "macos" | s -> s | ||
|
||
let os = normalise (match Sys.os_type with "Unix" -> uname () | s -> s) | ||
end | ||
|
||
let cc = Sys.argv.(1) | ||
|
||
let ldflags = | ||
match Unix.getenv "LDFLAGS" with exception Not_found -> "" | s -> s | ||
|
||
let cflags = | ||
match Unix.getenv "CFLAGS" with exception Not_found -> "" | s -> s | ||
|
||
let flags = | ||
match Var.os with | ||
| "openbsd" | "freebsd" -> | ||
Printf.sprintf | ||
"LDFLAGS=\"%s -L/usr/local/lib\" CFLAGS=\"%s -I/usr/local/include\"" | ||
ldflags cflags | ||
| "macos" when Var.is_homebrew_amr64 -> | ||
Printf.sprintf | ||
"LDFLAGS=\"%s -L/opt/homebrew/lib\" CFLAGS=\"%s \ | ||
-I/opt/homebrew/include\"" | ||
ldflags cflags | ||
| "macos" -> | ||
Printf.sprintf | ||
"LDFLAGS=\"%s -L/opt/local/lib -L/usr/local/lib\" CFLAGS=\"%s \ | ||
-I/opt/local/include -I/usr/local/include\"" | ||
ldflags cflags | ||
| _ -> "" | ||
|
||
let () = Printf.printf "CC=\"%s\" %s%!" cc flags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
(env | ||
(dev | ||
(flags | ||
(:standard -w -6)))) | ||
|
||
(library | ||
(name zarith) | ||
(public_name zarith) | ||
(modules z q big_int_Z zarith_version) | ||
(wrapped false) | ||
(foreign_stubs | ||
(language c) | ||
(names caml_z) | ||
(flags | ||
:standard | ||
(:include cflags.sexp))) | ||
(c_library_flags | ||
(:include libs.sexp))) | ||
|
||
(executable | ||
(name discover) | ||
(libraries unix) | ||
(modules discover)) | ||
|
||
(rule | ||
(target Makefile) | ||
(deps configure config.guess gmp.env) | ||
(action | ||
(with-stdout-to | ||
configure.out | ||
(bash "env %{read:gmp.env} ./configure")))) | ||
|
||
(rule | ||
(target gmp.env) | ||
(deps | ||
(:exe discover.exe)) | ||
(action | ||
(with-stdout-to | ||
%{target} | ||
(run %{exe} "%{cc}")))) | ||
|
||
(rule | ||
(target cflags.sexp) | ||
(deps Makefile) | ||
(action | ||
(with-stdout-to | ||
%{target} | ||
(progn | ||
(bash "echo -n '('") | ||
(bash "cat Makefile | sed -n -e 's/CFLAGS=//p'") | ||
(bash "echo -n ')'"))))) | ||
|
||
(rule | ||
(target libs.sexp) | ||
(deps Makefile) | ||
(action | ||
(with-stdout-to | ||
%{target} | ||
(progn | ||
(bash "echo -n '('") | ||
(bash "cat Makefile | sed -n -e 's/LIBS=//p'") | ||
(bash "echo -n ')'"))))) | ||
|
||
(rule | ||
(deps META) | ||
(action | ||
(with-stdout-to | ||
zarith_version.ml | ||
(progn | ||
(run echo "let") | ||
(bash "grep \"version\" META | head -1"))))) | ||
|
||
(library | ||
(name zarith_top) | ||
(optional) | ||
(public_name zarith.top) | ||
(modules zarith_top) | ||
(libraries zarith compiler-libs.toplevel)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(lang dune 2.0) | ||
(name zarith) | ||
(formatting disabled) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
(env | ||
(dev | ||
(flags | ||
(:standard -w -27-35)))) | ||
|
||
(executable | ||
(name zq) | ||
(modes byte exe) | ||
(modules zq) | ||
(libraries zarith)) | ||
|
||
(rule | ||
(alias runtest) | ||
(action | ||
(progn | ||
(with-stdout-to zq.out (run ./zq.exe)) | ||
(diff zq.output%{ocaml-config:word_size} zq.out)))) | ||
|
||
(rule | ||
(alias runtest) | ||
(action | ||
(progn | ||
(with-stdout-to zq.out.bc (run ./zq.bc)) | ||
(diff zq.output%{ocaml-config:word_size} zq.out.bc)))) | ||
|
||
(executable | ||
(name pi) | ||
(modes exe) | ||
(modules pi) | ||
(libraries zarith)) | ||
|
||
(rule | ||
(alias runtest) | ||
(action | ||
(progn | ||
(with-stdout-to pi.out (run ./pi.exe 500)) | ||
(diff pi.output pi.out)))) | ||
|
||
(test | ||
(name ofstring) | ||
(modules ofstring) | ||
(modes exe) | ||
(libraries zarith)) | ||
|
||
(test | ||
(name timings) | ||
(modules timings) | ||
(modes exe) | ||
(libraries zarith)) | ||
|
||
(test | ||
(name tofloat) | ||
(modules tofloat) | ||
(modes exe) | ||
(foreign_stubs (language c) (names setround)) | ||
(libraries zarith)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,21 @@ | ||
opam-version: "2.0" | ||
name: "zarith" | ||
maintainer: "Xavier Leroy <[email protected]>" | ||
authors: [ | ||
"Antoine Miné" | ||
"Xavier Leroy" | ||
"Pascal Cuoq" | ||
] | ||
homepage: "https://github.com/ocaml/Zarith" | ||
bug-reports: "https://github.com/ocaml/Zarith/issues" | ||
dev-repo: "git+https://github.com/ocaml/Zarith.git" | ||
homepage: "https://github.com/dune-universe/Zarith" | ||
bug-reports: "https://github.com//Zarith/issues" | ||
dev-repo: "git+https://github.com/dune-universe/Zarith.git" | ||
build: [ | ||
["./configure"] {os != "openbsd" & os != "freebsd" & os != "macos"} | ||
[ | ||
"sh" | ||
"-exc" | ||
"LDFLAGS=\"$LDFLAGS -L/usr/local/lib\" CFLAGS=\"$CFLAGS -I/usr/local/include\" ./configure" | ||
] {os = "openbsd" | os = "freebsd"} | ||
[ | ||
"sh" | ||
"-exc" | ||
"LDFLAGS=\"$LDFLAGS -L/opt/local/lib -L/usr/local/lib\" CFLAGS=\"$CFLAGS -I/opt/local/include -I/usr/local/include\" ./configure" | ||
] {os = "macos"} | ||
[make] | ||
] | ||
install: [ | ||
[make "install"] | ||
[ "dune" "subst" ] {pinned} | ||
[ "dune" "build" "-p" name "-j" jobs ] | ||
[ "dune" "runtest" "-p" name "-j" jobs ] | ||
] | ||
depends: [ | ||
"ocaml" {>= "4.04.0"} | ||
"ocamlfind" | ||
"ocaml" {>="4.05.0"} | ||
"dune" {>="2.0"} | ||
"conf-gmp" | ||
] | ||
synopsis: | ||
|