-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathMakefile.libgmp
70 lines (59 loc) · 2.47 KB
/
Makefile.libgmp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright 2012, Square, Inc.
GMP=gmp-6.1.1
# Converts the architecture name as returned from uname -m to a format that
# the JVM understands. ARCH is part of the platform string that the JVM
# will look at when searching directories for a native library.
ARCH=$(shell uname -m | sed -e 's/x86_64/x86-64/g' \
-e 's/amd64/x86-64/g' \
-e 's/i386/x86/g' \
-e 's/i686/x86/g' \
-e 's/powerpc/ppc/g' \
-e 's/powerpc64/ppc64/g' \
-e 's/^arm.*/arm/g')
# Like architecture the JVM has set of predefined OS names, so we need to convert
# the value output from uname to something that the JVM understands.
OS=$(shell uname | sed -e 's/CYGWIN.*/win32/g' \
-e 's/MINGW32.*/win32/g' \
-e 's/SunOS.*/sunos/g' \
-e 's/NetBSD/netbsd/g' \
-e 's/GNU\/kFreeBSD/kfreebsd/g' \
-e 's/FreeBSD/freebsd/g' \
-e 's/OpenBSD/openbsd/g' \
-e 's/Darwin.*/darwin/g' \
-e 's/AIX.*/aix/g' \
-e 's/Linux.*/linux/g')
# The filename for the shared library that was created differs based on the
# platform, so we conditionally set it below.
ifeq ($(OS), darwin)
LIBGMP=$(GMP)/.libs/libgmp.dylib
PLATFORM=$(OS)
else ifeq ($(OS)-$(ARCH), sunos-i86pc)
# uname -m doesn't give us a coherent answer for Solaris platforms, so
# we have to do an additional inspection
ARCH=$(shell isainfo -b | sed -e 's/64/x86-64/g' -e 's/32/x86/g')
LIBGMP=$(GMP)/.libs/libgmp.so
PLATFORM=$(OS)-$(ARCH)
else
LIBGMP=$(GMP)/.libs/libgmp.so
PLATFORM=$(OS)-$(ARCH)
endif
all: $(LIBGMP)
$(GMP).tar.bz2:
curl -O https://ftp.gnu.org/gnu/gmp/$(GMP).tar.bz2
$(GMP)/configure: $(GMP).tar.bz2
-mkdir $(GMP)
$(which sha1sum || which shasum) -c $(GMP).tar.bz2.sha512
tar -xjf $< -C $(GMP) --strip-components 1
touch -c $(GMP)/configure
$(GMP)/gmp.h $(GMP)/Makefile: $(GMP)/configure
cd $(GMP); ./configure --enable-fat --disable-static
$(LIBGMP): $(GMP)/gmp.h $(GMP)/Makefile
$(MAKE) -C $(GMP)/ all check
install: $(LIBGMP)
mkdir -p src/main/resources
cp -f $(GMP)/COPYING.LESSERv3 src/main/resources/COPYING.LIBGMP
mkdir -p src/main/resources/$(PLATFORM)
cp -f $< src/main/resources/$(PLATFORM)/
clean:
rm -rf $(GMP)/ $(GMP).tar.bz2
git checkout -- src/main/resources/$(PLATFORM)