Skip to content

Commit

Permalink
Fix some issues with generated pc files
Browse files Browse the repository at this point in the history
 - Use #opt_prefix instead of #prefix or HOMEBREW_PREFIX
 - Use #version rather than hardcoded strings or @Version
 - Unify pc file method naming
 - Use String#undent

Closes Homebrew/legacy-homebrew#18695.
  • Loading branch information
jacknagel committed Mar 25, 2013
1 parent 128e226 commit 9a39338
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 74 deletions.
34 changes: 17 additions & 17 deletions Formula/gd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ def install
args << "--without-freetype" unless build.with? 'freetype'
system "./configure", *args
system "make install"
(lib+'pkgconfig/gdlib.pc').write pkg_file
(lib+'pkgconfig/gdlib.pc').write pc_file
end

def pkg_file; <<-EOF
prefix=#{prefix}
exec_prefix=${prefix}
libdir=/${exec_prefix}/lib
includedir=/${prefix}/include
bindir=/${prefix}/bin
ldflags= -L/${prefix}/lib
Name: gd
Description: A graphics library for quick creation of PNG or JPEG images
Version: 2.0.36RC1
Requires:
Libs: -L${libdir} -lgd
Libs.private: -ljpeg -lpng12 -lz -lm
Cflags: -I${includedir}
EOF
def pc_file; <<-EOS.undent
prefix=#{opt_prefix}
exec_prefix=${prefix}
libdir=/${exec_prefix}/lib
includedir=/${prefix}/include
bindir=/${prefix}/bin
ldflags= -L/${prefix}/lib
Name: gd
Description: A graphics library for quick creation of PNG or JPEG images
Version: #{version}
Requires:
Libs: -L${libdir} -lgd
Libs.private: -ljpeg -lpng12 -lz -lm
Cflags: -I${includedir}
EOS
end

test do
Expand Down
41 changes: 18 additions & 23 deletions Formula/libid3tag.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
require 'formula'

class Libid3tag < Formula
homepage 'http://www.underbit.com/products/mad/'
url 'http://downloads.sourceforge.net/project/mad/libid3tag/0.15.1b/libid3tag-0.15.1b.tar.gz'
sha1 '4d867e8a8436e73cd7762fe0e85958e35f1e4306'

def id3tag_pc
return <<-EOS
prefix=#{HOMEBREW_PREFIX}
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: id3tag
Description: ID3 tag reading library
Version: #{@version}
Requires:
Conflicts:
Libs: -L${libdir} -lid3tag -lz
Cflags: -I${includedir}
EOS
end


def homepage
Formula.factory('mad').homepage
end

# Fixes serious memory leaks; see https://bugs.launchpad.net/mixxx/+bug/403586
def patches
base = "http://mirror.ovh.net/gentoo-portage/media-libs/libid3tag/files/0.15.1b/"
Expand All @@ -52,6 +31,22 @@ def install
system "./configure", "--prefix=#{prefix}", "--disable-debug", "--disable-dependency-tracking"
system "make install"

(lib+'pkgconfig/id3tag.pc').write id3tag_pc
(lib+'pkgconfig/id3tag.pc').write pc_file
end

def pc_file; <<-EOS.undent
prefix=#{opt_prefix}
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: id3tag
Description: ID3 tag reading library
Version: #{version}
Requires:
Conflicts:
Libs: -L${libdir} -lid3tag -lz
Cflags: -I${includedir}
EOS
end
end
6 changes: 3 additions & 3 deletions Formula/libspotify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def install
ln_s "libspotify.12.1.51.dylib", "libspotify.12.dylib"
end

(lib+'pkgconfig/libspotify.pc').write pc_content
(lib+'pkgconfig/libspotify.pc').write pc_file
end

def pc_content; <<-EOS.undent
prefix=#{HOMEBREW_PREFIX}
def pc_file; <<-EOS.undent
prefix=#{opt_prefix}
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Expand Down
27 changes: 13 additions & 14 deletions Formula/mad.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,22 @@ def install
fpm = MacOS.prefer_64_bit? ? '64bit': 'intel'
system "./configure", "--disable-debugging", "--enable-fpm=#{fpm}", "--prefix=#{prefix}"
system "make", "CFLAGS=#{ENV.cflags}", "LDFLAGS=#{ENV.ldflags}", "install"
(lib+'pkgconfig/mad.pc').write mad_pc
(lib+'pkgconfig/mad.pc').write pc_file
end

def mad_pc
return <<-EOS
prefix=#{HOMEBREW_PREFIX}
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
def pc_file; <<-EOS.undent
prefix=#{opt_prefix}
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: mad
Description: MPEG Audio Decoder
Version: #{@version}
Requires:
Conflicts:
Libs: -L${libdir} -lmad -lm
Cflags: -I${includedir}
Name: mad
Description: MPEG Audio Decoder
Version: #{version}
Requires:
Conflicts:
Libs: -L${libdir} -lmad -lm
Cflags: -I${includedir}
EOS
end
end
26 changes: 13 additions & 13 deletions Formula/nss.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def install
cp file, lib
end

(lib+'pkgconfig/nss.pc').write pkg_file
(lib+'pkgconfig/nss.pc').write pc_file
end

test do
Expand All @@ -62,18 +62,18 @@ def install
system "#{bin}/certutil", "-L", "-d", pwd
end

def pkg_file; <<-EOF
prefix=#{HOMEBREW_PREFIX}
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/nss
def pc_file; <<-EOS.undent
prefix=#{opt_prefix}
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/nss
Name: NSS
Description: Mozilla Network Security Services
Version: 3.14.1
Requires: nspr
Libs: -L${libdir} -lnss3 -lnssutil3 -lsmime3 -lssl3
Cflags: -I${includedir}
EOF
Name: NSS
Description: Mozilla Network Security Services
Version: #{version}
Requires: nspr
Libs: -L${libdir} -lnss3 -lnssutil3 -lsmime3 -lssl3
Cflags: -I${includedir}
EOS
end
end
8 changes: 4 additions & 4 deletions Formula/squirrel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def install
doc.install Dir['doc/*.pdf']
doc.install %w[etc samples]
# See: https://github.com/mxcl/homebrew/pull/9977
(lib+'pkgconfig/libsquirrel.pc').write pkg_file
(lib+'pkgconfig/libsquirrel.pc').write pc_file
end

def pkg_file; <<-EOS.undent
prefix=#{prefix}
def pc_file; <<-EOS.undent
prefix=#{opt_prefix}
exec_prefix=${prefix}
libdir=/${exec_prefix}/lib
includedir=/${prefix}/include
Expand All @@ -26,7 +26,7 @@ def pkg_file; <<-EOS.undent
Name: libsquirrel
Description: squirrel library
Version: 3.0.2
Version: #{version}
Requires:
Libs: -L${libdir} -lsquirrel -lsqstdlib
Expand Down

0 comments on commit 9a39338

Please sign in to comment.