summaryrefslogtreecommitdiff
blob: 5d814b63a3f7003aba5cf559851d75c48e53cb46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-ruby/rqr/rqr-0.2.2.ebuild,v 1.1 2011/07/14 08:32:54 flameeyes Exp $

EAPI=4

# ruby19 → uses old RString interface
# jruby → native extension, unusable
USE_RUBY="ruby18 ree18"

# do not use Rake tasks for this as it requires hoe, newgem, and is
# generally a mess.
RUBY_FAKEGEM_TASK_TEST=""
RUBY_FAKEGEM_TASK_DOC=""

RUBY_FAKEGEM_DOCDIR="doc"
RUBY_FAKEGEM_EXTRADOC="README.txt History.txt"

inherit ruby-fakegem flag-o-matic

DESCRIPTION="A ruby library to create qrcode"
HOMEPAGE="http://rqr.rubyforge.org/"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
IUSE="doc test +jpeg +png +tiff"

ruby_add_bdepend "doc? ( virtual/ruby-rdoc )
	test? ( virtual/ruby-test-unit )"

CDEPEND="jpeg? ( virtual/jpeg )
	png? ( media-libs/libpng )
	tiff? ( media-libs/tiff )"

RDEPEND="${RDEPEND} ${CDEPEND}"
DEPEND="${DEPEND} ${CDEPEND}"

# tests require the presence of all external formats; simply add them as
# a requirement for now.
REQUIRED_USE="test? ( jpeg png tiff )"

each_ruby_configure() {
	cd ext/rqr
	${RUBY} extconf.rb || die "extconf.rb failed"
}

each_ruby_compile() {
	# this should be handled by extconf.rb, but unfortunately it mangles
	# the CFLAGS rather than doing it properly so we have to replicate
	# it here until upstream makes a sense out of it.
	#
	# Note: you can avoid using any of those, but then it would only
	# generate EPS, which might or might not be what you want.
	use jpeg && append-flags -DUSE_JPG
	use png && append-flags -DUSE_PNG
	use tiff && append-flags -DUSE_TIFF

	# extension uses C++, so use CXXFLAGS not CFLAGS
	emake -C ext/rqr \
		CFLAGS="${CXXFLAGS} -fPIC" archflag="${LDFLAGS}" || die "emake failed"
	cp ext/rqr/QR.so lib/rqr || die
}

all_ruby_compile() {
	if use doc; then
		${RUBY} rdoc || die "rdoc failed"
	fi
}

each_ruby_test() {
	${RUBY} -Ilib test/test_rqr.rb || die "tests failed"
}