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

Use make install #17

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
159 changes: 131 additions & 28 deletions Formula/gap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ class Gap < Formula
homepage "https://www.gap-system.org/"
url "https://github.com/gap-system/gap/releases/download/v4.12.2/gap-4.12.2.tar.gz"
sha256 "672308745eb78a222494ee8dd6786edd5bc331456fcc6456ac064bdb28d587a8"
license "GPL-2.0-or-later"


head do
url "https://github.com/gap-system/gap.git", branch: "master"
depends_on "autoconf" => :build # required by packages below
end


depends_on "gmp"
# GAP cannot be built against the native macOS version of readline
Expand All @@ -11,46 +19,141 @@ class Gap < Formula
# So we depend on GNU readline here.
depends_on "readline"

# for zeromqinterface package
depends_on "zeromq"
gvol marked this conversation as resolved.
Show resolved Hide resolved


def install
# XXX: Currently there is no `install` target in `Makefile`.
# According to the manual installation instructions in
#
# https://github.com/gap-system/gap/blob/master/INSTALL.md
#
# the compiled "bundle" is intended to be used "as is," and there is
# no instructions for how to remove the source and other unnecessary
# files after compilation. Moreover, the content of the
# subdirectories with special names, such as `bin` and `lib`, is not
# suitable for merging with the content of the corresponding
# subdirectories of `/usr/local`. The easiest temporary solution seems
# to be to drop the compiled bundle into `<prefix>/libexec` and to
# create a symlink `<prefix>/bin/gap` to the startup script.
# This use of `libexec` seems to contradict Linux Filesystem Hierarchy
# Standard, but is recommended in Homebrew's "Formula Cookbook."

libexec.install Dir["*"]

# GAP does not support "make install" so it has to be compiled in place

cd libexec do
system "./configure", "--with-readline=#{Formula["readline"].opt_prefix}"
system "make"

prerequisites_packages = [
"atlasrep",
"normalizinterface",
"semigroups",
]

no_compilation_packages = [
"atlasrep", "aclib", "agt", "alnuth", "automata", "automgrp",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such a long list seems error prone and annoying because it needs to be updated for each GAP release.

Can't you instead just compute a list of the names of all subdirs of the pkg directory on the fly? Resp. not even use that list, just iterate over them all

"autpgrp", "circle", "classicpres", "congruence", "corelg",
"crime", "crisp", "cryst", "crystcat", "ctbllib", "cubefree",
"design", "difsets", "factint", "fga", "fining", "format",
"forms", "fr", "francy", "fwtree", "gapdoc", "gbnp", "genss",
"groupoids", "grpconst", "guarana", "hap", "hapcryst", "hecke",
"help", "idrel", "images", "intpic", "irredsol", "itc",
"jupyterkernel", "jupyterviz", "kan", "laguna", "liealgdb",
"liepring", "liering", "loops", "lpres", "majoranaalgebras",
"mapclass", "matgrp", "modisom", "nilmat", "nock",
"numericalsgps", "openmath", "packagemanager", "patternclass",
"permut", "polenta", "polycyclic", "polymaking", "primgrp",
"qpa", "quagroup", "radiroot", "rcwa", "rds", "recog",
"repndecomp", "repsn", "resclasses", "scscp", "sglppow",
"sgpviz", "singular", "sl2reps", "sla", "smallgrp", "smallsemi",
"sonata", "sophus", "spinsym", "standardff", "symbcompcc",
"thelma", "tomlib", "toric", "transgrp", "ugaly", "unipot",
"unitlib", "utils", "uuid", "walrus", "wedderga", "xmod",
"xmodalg", "yangbaxter",
]

# make doc and test targets, I don't actually call them
makefile_packages = [
"4ti2interface", "autodoc", "cap", "examplesforhomalg",
"gaussforhomalg", "generalizedmorphismsforcap", "gradedmodules",
"gradedringforhomalg", "homalg", "homalgtocas", "io_forhomalg",
"linearalgebraforcap", "localizeringforhomalg",
"matricesforhomalg", "modulepresentationsforcap", "modules",
"monoidalcategories", "nconvex", "ringsforhomalg", "sco",
"toolsforhomalg", "toricvarieties",
]

# These two packages either don't build or don't work
# "cddinterface", "xgap",
configure_packages = [
"anupq", "caratinterface", "crypting", "curlinterface", "cvec",
"datastructures", "deepthought", "digraphs", "ferret", "float",
"gauss", "grape", "io", "json", "normalizinterface", "nq",
"orb", "profiling", "semigroups", "simpcomp", "zeromqinterface",
]

old_configure_packages = [
"ace", "browse", "cohomolo", "edim", "example", "fplsa",
"guava", "kbmag",
]

# These package have autogen.sh available
# I don't think there is a need to run it, but we could if we wanted
autogen_packages = [
"anupq", "cddinterface", "curlinterface", "digraphs", "ferret",
"float", "guava", "io", "normalizinterface", "nq", "semigroups",
"simpcomp", "xgap", "zeromqinterface",
]

# Run special commands after installation
special_packages = {
# Even with x11 installed, it doesn't seem to work
# "xgap" => "cp bin/xgap.sh $GAPROOT/bin/xgap.sh",
}


# Start actually building GAP
if build.head?
system "./autogen.sh"
end

libexec.install Dir["pkg"]

system "./configure", "--prefix", libexec/"gap", "--with-readline=#{Formula["readline"].opt_prefix}"
if build.head?
system "make", "bootstrap-pkg-full"
# system "make", "doc" # Do we need this?
end
system "make", "install"

# Create a symlink `bin/gap` from the `gap` binary
bin.install_symlink libexec/"gap" => "gap"
bin.install_symlink libexec/"gap/bin/gap" => "gap"

ohai "Building included packages. Please be patient, it may take a while"
pkg_dir = "#{libexec}/pkg"

cd libexec/"pkg" do
# NOTE: This script will build most of the packages that require
# compilation. It is known to produce a number of warnings and
# error messages, possibly failing to build several packages.
system "../bin/BuildPackages.sh", "--with-gaproot=#{libexec}"

system "mkdir", "#{libexec}/gap/lib/gap/pkg/"

# The makefiles appear to only be used for docs...
# The BuildPackages.sh script didn't call them
no_compilation_packages.concat(makefile_packages).each do |pkg|
system "cp", "-R", pkg, "#{libexec}/gap/lib/gap/pkg/"
end

prerequisites_packages.each do |pkg|
fingolfin marked this conversation as resolved.
Show resolved Hide resolved
cd pkg do
system "./prerequisites.sh", "#{libexec}/gap/lib/gap"
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having the configure_packages and configure_packages lists, here you could have a similar check to see if there is a ./configure file. If there is, you can distinguish "old" and "new" style by checking of configure contains the string with-gaproot...

Though actually, with GAP 4.13.0, all but one configure script support --with-gaproot -- the one exception is that of simpcomp, which however happily ignores it. So you could just ditch the whole old_configure_packages part.

end

# autogen_packages.each do |pkg|
# cd pkg do
# system "./autogen.sh"
# end
# end
configure_packages.each do |pkg|
cd pkg do
system "./configure", "--with-gaproot=#{libexec}/gap/lib/gap"
system "make"
system "/usr/bin/rsync", "-aEvL", "bin/", "#{libexec}/gap/lib/gap/pkg/"
fingolfin marked this conversation as resolved.
Show resolved Hide resolved
end
end
old_configure_packages.each do |pkg|
cd pkg do
system "./configure", "#{libexec}/gap/lib/gap"
system "make"
system "/usr/bin/rsync", "-aEvL", "bin/", "#{libexec}/gap/lib/gap/pkg/"
end
end
end
end

test do
ENV["LC_CTYPE"] = "en_GB.UTF-8"
system bin/"gap", "-r", "-A", "#{libexec}/tst/testinstall.g"
end

end