diff --git a/Formula/gap.rb b/Formula/gap.rb index a11bdb4..74b2ef5 100644 --- a/Formula/gap.rb +++ b/Formula/gap.rb @@ -3,6 +3,13 @@ class Gap < Formula homepage "https://www.gap-system.org/" url "https://github.com/gap-system/gap/releases/download/v4.13.0/gap-4.13.0.tar.gz" sha256 "cc76ecbe33d6719450a593e613fb87e9e4247faa876f632dd0f97c398f92265d" + 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 @@ -11,41 +18,121 @@ class Gap < Formula # So we depend on GNU readline here. depends_on "readline" + # for packages + depends_on "cddlib" # CddInterface + depends_on "curl" # curlInterface + depends_on "fplll" # float + depends_on "libmpc" # float + depends_on "mpfi" # float + depends_on "mpfr" # float, normalizinterface + depends_on "ncurses" # browse + depends_on "zeromq" # ZeroMQInterface + depends_on "singular" # many packages + depends_on "pari" # many packages + 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 `/libexec` and to - # create a symlink `/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" + + + no_compilation_packages = [ + "atlasrep", "aclib", "agt", "alnuth", "automata", "automgrp", + "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", + # These packages have `doc` and `test` make targets, but we + # don't actually call them + "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", + ] + + + + all_packages = no_compilation_packages + .concat(configure_packages) + .concat(configure_packages) + + # 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 + all_packages.each do |pkg| + system "cp", "-R", pkg, "#{libexec}/gap/lib/gap/pkg/" + cd pkg do + if File.exist?("./prerequisites.sh") + system "./prerequisites.sh", "#{libexec}/gap/lib/gap" + end + end + end + + configure_packages.each do |pkg| + cd pkg do + system "./configure", "--with-gaproot=#{libexec}/gap/lib/gap" + system "make" + system "cp", "-R", "bin/", "#{libexec}/gap/lib/gap/pkg/#{pkg}" + end + end + old_configure_packages.each do |pkg| + cd pkg do + system "./configure", "#{libexec}/gap/lib/gap" + system "make" + system "cp", "-R", "bin/", "#{libexec}/gap/lib/gap/pkg/#{pkg}" + end + end end end @@ -53,4 +140,5 @@ def install ENV["LC_CTYPE"] = "en_GB.UTF-8" system bin/"gap", "-r", "-A", "#{libexec}/tst/testinstall.g" end + end