LICENSEFILES = README COPYING

# svn://pari.math.u-bordeaux.fr/pari/trunk

HOMEPAGE = http://pari.math.u-bordeaux.fr/
VPATH = @srcdir@

# pari maintainers have been known to break URL's, so we copy their software to another server:
# URL = http://pari.math.u-bordeaux.fr/pub/pari/unix

VERSION = 2.11.2
# PATCHFILE = @abs_srcdir@/patch-$(VERSION)
URL = http://macaulay2.com/Downloads/OtherSourceCode

# uname gives a strange answer on the second command line below, under mac os x.  Pari's configure
# script uses "uname -p", but I'm not sure whether it causes any problems.
#   einsteinium$ uname -m
#   x86_64
#   einsteinium$ uname -p
#   i386

# We (used to) leave out these tests, now we don't test at all
#   (test-all would run them all) :
#   test-ellglobalred - requires data files that we don't download
#   test-ellsea - requires data files "seadata"
#   test-galois - requires galois data files "galdata"
#   test-ploth - needs to pop up a window
#   test-galoisinit test-subfields test-partition - mysterious segmentation fault on Mac, but we don't use these routines
#   test-program - fails under cygwin with this explanatory message after segfault:
#		NOTE: the problem noted in 'program' is that install() does not work in your
#		configuration (gp-sta only), so you will not be able to use this feature.
#		Otherwise you can safely ignore the above warning.
CHECKTARGET = .

# we build only the shared library, because that's the version that is gmp compatible (??)

INSTALLTARGET += install-include

# choose the static library to build and install:
BUILDTARGET += lib-sta
INSTALLTARGET += install-lib-sta
# BUILDTARGET += lib-dyn
# INSTALLTARGET += install-lib-dyn

HOST_OS = @host_os@
HOST_CPU = @host_cpu@
ifeq ($(HOST_OS),mingw32)
HOST_OS = mingw
endif

ifneq (,$(findstring darwin,$(HOST_OS)))
# Pari's configure script gets confused if the host_os contains the version number, e.g., darwin14.0.0:
HOST_OS = darwin
endif

CONFIGURECMD = $(CONFIGENV) dfltlibdir=$(LIBRARIESDIR)/lib ./Configure --prefix=$(LIBRARIESDIR) --with-gmp=$(LIBRARIESDIR) --host=$(HOST_CPU)-$(HOST_OS)

# Pari's configure script is needlessly confusing, since it's almost impossible to figure out what directory is chosen as the build directory.
# We've opted to search for the directory containing the file pari.cfg, hoping it's unique.

GETODIR  = `cd $(BUILDDIR) && find . -name pari.cfg | head -1 | sed 's=/[^/]*$$=='`
GETODIR2 = `find . -name pari.cfg | head -1 | sed 's=/[^/]*$$=='`

INSTALLOPTIONS = -C $(GETODIR2)
BUILDOPTIONS = -C $(GETODIR2)
CHECKOPTIONS = -C $(GETODIR2)

ifeq (@PROFILING@,yes)
CONFIGURECMD += -pg
else
ifeq (@DEBUG@,yes)
CONFIGURECMD += -g
endif
endif

include ../Makefile.library

# get the right binary utilities by putting them on the path, since no
# configure option is offered for specifying them:
CONFIGENV += PATH="/usr/@host@/bin:$(PATH)"

# we have to detect which of these two answers it gives:
#   ### Building without GNU MP support
#   Using GNU MP, version 4.2.1
config-chk: .config-checked-$(VERSION)
clean::; rm -f .config-checked-*
.config-checked-$(VERSION):
	: test whether pari successfully found gmp library during configuration :
	echo 'configfile(s) : '` find . -name pari.cfg `
	. $(GETODIR2)/pari.cfg && echo kernlvl1 = $$kernlvl1 && [ $$kernlvl1 = gmp ]
	: test whether pari found a dynamic library linker during configuration :
	. $(GETODIR2)/pari.cfg && echo DLLD = $$DLLD && [ "$$DLLD" != "" ]
	touch $@

Makefile: @srcdir@/Makefile.in ; cd ../.. && ./config.status libraries/pari/Makefile
run-example: example; ./example
example: example.c -lpari
example: CFLAGS += -Wall -Wno-unused -Werror -UNDEBUG
TAGS : @srcdir@/TAGS
@srcdir@/TAGS: /usr/include/pari/*.h example.c ; etags -o @srcdir@/TAGS $^
# Local Variables:
# compile-command: "make -C $M2BUILDDIR/libraries/pari "
# End:
