Skip to content

Instantly share code, notes, and snippets.

@dpo
Created May 4, 2014 17:04
Show Gist options
  • Select an option

  • Save dpo/11520047 to your computer and use it in GitHub Desktop.

Select an option

Save dpo/11520047 to your computer and use it in GitHub Desktop.
require 'formula'
class Asl < Formula
url 'http://www.ampl.com/netlib/ampl/solvers.tgz'
sha1 '3d527e03fff6eea8d0eff43bdc72391d778f0e0b'
version '20140205'
homepage 'http://www.ampl.com/hooking.html'
def install
ENV.universal_binary if OS.mac?
#args = ["CC=#{ENV.cc}", "CFLAGS=-I. -O -fPIC"]
cflags = %w[-I. -O -fPIC]
if OS.mac?
cflags += ["-arch", "#{Hardware::CPU.arch_32_bit}"] if OS.mac?
soname = "dylib"
libtool_args = ["libtool", "-dynamic", "-undefined", "dynamic_lookup",
"-install_name", "#{lib}/libasl.#{soname}"]
else
soname = "so"
libtool_args = ["ld", "-shared"]
end
# Dynamic libraries are more user friendly.
(buildpath / 'makefile.brew').write <<-EOS.undent
include makefile.u
libasl.#{soname}: ${a:.c=.o}
\t#{libtool_args.join(" ")} -o $@ $?
libfuncadd0.#{soname}: funcadd0.o
\t#{libtool_args.join(" ")} -o $@ $?
EOS
ENV.deparallelize
targets = ["arith.h", "stdio1.h"]
libs = ["libasl.#{soname}", "libfuncadd0.#{soname}"]
make_args = targets + libs
system "make", "-f", "makefile.brew", "CFLAGS=#{cflags.join(' ')}", *make_args
lib.install *libs
(include / 'asl').install Dir["*.h"]
(include / 'asl').install Dir["*.hd"]
doc.install 'README'
end
def caveats; <<-EOS.undent
Include files are in #{include}/asl.
To link with the ASL, you may simply use
-L#{lib} -lasl -lfuncadd0
EOS
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment