Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

Commit

Permalink
Add a recipe for GMP 4
Browse files Browse the repository at this point in the history
  • Loading branch information
asmeurer committed Feb 14, 2014
1 parent f4a1da6 commit a2457be
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
13 changes: 13 additions & 0 deletions gmp-4/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

chmod +x configure

if [ `uname` == Darwin ]; then
./configure --prefix=$PREFIX --disable-shared
else
./configure --prefix=$PREFIX
fi

make
make check
make install
16 changes: 16 additions & 0 deletions gmp-4/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package:
name: gmp
version: 4.3.2

source:
fn: gmp-4.3.2.tar.bz2
url: http://ftp.gnu.org/pub/gnu/gmp/gmp-4.3.2.tar.bz2
sha1: c011e8feaf1bb89158bd55eaabd7ef8fdd101a2c

about:
home: http://gmplib.org/
license: GPL 3

test:
files:
- test.c
2 changes: 2 additions & 0 deletions gmp-4/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cc -I $PREFIX/include -L $PREFIX/lib test.c -lgmp -o test.out
./test.out
28 changes: 28 additions & 0 deletions gmp-4/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* Taken from the GMP Wikipedia article */

#include <stdio.h>
#include <stdlib.h>
#include "gmp.h"

int main(void)
{
mpz_t x;
mpz_t y;
mpz_t result;

mpz_init(x);
mpz_init(y);
mpz_init(result);

mpz_set_str(x, "7612058254738945", 10);
mpz_set_str(y, "9263591128439081", 10);

mpz_mul(result, x, y);
gmp_printf("\n %Zd\n*\n %Zd\n--------------------\n%Zd\n\n", x, y, result);

/* free used memory */
mpz_clear(x);
mpz_clear(y);
mpz_clear(result);
return EXIT_SUCCESS;
}

0 comments on commit a2457be

Please sign in to comment.