Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conf-gmp: use pkg-config where available #23330

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/conf-gmp-powm-sec/conf-gmp-powm-sec.4/files/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <gmp.h>
#ifndef __GMP_H__
#error "No GMP header"
#endif
#if __GNU_MP_VERSION < 5
#error "GMP >= 5 is required to support mpz_powm_sec"
#endif

void test(void) {
mpz_t base;
mpz_t exp;
mpz_t mod;
mpz_t rop;

mpz_init_set_ui(base, 2u);
mpz_init_set_ui(exp, 4u);
mpz_init_set_ui(mod, 3u);
mpz_init(rop);

mpz_powm_sec(rop, base, exp, mod);

mpz_clear(base);
mpz_clear(exp);
mpz_clear(mod);
mpz_clear(rop);
}
17 changes: 17 additions & 0 deletions packages/conf-gmp-powm-sec/conf-gmp-powm-sec.4/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
opam-version: "2.0"
maintainer: "Etienne Millon <etienne@cryptosense.com>"
homepage: "http://gmplib.org/"
bug-reports: "https://github.com/ocaml/opam-repository/issues"
license: "GPL-1.0-or-later"
build: [
["sh" "-exc" "pkg-config --print-errors --exists gmp || cc -c $CFLAGS -I/usr/local/include test.c"]
]
depends: ["conf-gmp"]
synopsis:
"Virtual package relying on a GMP lib with constant-time modular exponentiation"
description: """
This package can only install if the GMP lib is installed on the system and
corresponds to a version that has the mpz_powm_sec function."""
authors: "Etienne Millon <etienne@cryptosense.com>"
extra-files: ["test.c" "md5=29317f477fa828e18428660ef31064fb"]
flags: conf
10 changes: 10 additions & 0 deletions packages/conf-gmp/conf-gmp.5/files/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <gmp.h>
#ifndef __GMP_H__
#error "No GMP header"
#endif

void test(void) {
mpz_t n;
mpz_init(n);
mpz_clear(n);
}
32 changes: 32 additions & 0 deletions packages/conf-gmp/conf-gmp.5/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
opam-version: "2.0"
maintainer: "https://github.com/ocaml/opam-repository/issues"
authors: "GMP dev team"
homepage: "http://gmplib.org/"
bug-reports: "https://github.com/ocaml/opam-repository/issues"
license: "GPL-1.0-or-later"
build: [
["sh" "-c" "pkg-config --print-errors --exists gmp || cc -c $CFLAGS -I/usr/local/include test.c"]
]
depends: [
"conf-pkg-config" {build}
]
depexts: [
["libgmp-dev"] {os-family = "debian"}
["libgmp-dev"] {os-family = "ubuntu"}
["gmp-dev"] {os-family = "alpine"}
["gmp" "gmp-devel"] {os-distribution = "centos"}
["gmp" "gmp-devel"] {os-distribution = "fedora"}
["gmp" "gmp-devel"] {os-distribution = "ol"}
["gmp-devel"] {os-family = "suse"}
["gmp"] {os-family = "arch"}
["gmp"] {os = "freebsd"}
["gmp"] {os = "openbsd"}
["gmp"] {os = "netbsd"}
["gmp"] {os = "macos" & os-distribution = "homebrew"}
["gmp"] {os = "macos" & os-distribution = "macports"}
]
synopsis: "Virtual package relying on a GMP lib system installation"
description:
"This package can only install if the GMP lib is installed on the system."
extra-files: ["test.c" "md5=2fd2970c293c36222a6d299ec155823f"]
flags: conf
47 changes: 47 additions & 0 deletions packages/zarith/zarith.1.12-1/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
opam-version: "2.0"
maintainer: "Xavier Leroy <xavier.leroy@inria.fr>"
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"
license: "LGPL-2.0-only WITH OCaml-LGPL-linking-exception"
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 $(pkg-config --libs-only-L gmp)\" CFLAGS=\"$CFLAGS $(pkg-config --cflags gmp)\" ./configure"
] {os = "macos" & (os-distribution = "homebrew" | os-distribution = "macports")}
[make]
]
install: [
[make "install"]
]
depends: [
"ocaml" {>= "4.04.0"}
"ocamlfind"
"conf-gmp"
]
synopsis:
"Implements arithmetic and logical operations over arbitrary-precision integers"
description: """
The Zarith library implements arithmetic and logical operations over
arbitrary-precision integers. It uses GMP to efficiently implement
arithmetic over big integers. Small integers are represented as Caml
unboxed integers, for speed and space economy."""
url {
src: "https://github.com/ocaml/Zarith/archive/release-1.12.tar.gz"
checksum: [
"md5=bf368f3d9e20b6b446d54681afc05a04"
"sha512=8075573ae65579a2606b37dd1b213032a07d220d28c733f9288ae80d36f8a2cc4d91632806df2503c130ea9658dc207ee3a64347c21aa53969050a208f5b2bb4"
]
}