summaryrefslogtreecommitdiff
blob: 846e660e5a3219c11d694597bf816734a6693097 (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
74
75
76
77
78
79
80
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-embedded/arduino/arduino-1.0.ebuild,v 1.1 2012/02/10 00:09:27 miknix Exp $

EAPI=3
inherit eutils

DESCRIPTION="Arduino is an open-source AVR electronics prototyping platform"
HOMEPAGE="http://arduino.cc/"
SRC_URI="x86?   ( http://arduino.googlecode.com/files/${P}-linux.tgz )
		 amd64? ( http://arduino.googlecode.com/files/${P}-linux64.tgz )"

LICENSE="GPL-2 LGPL-2 CCPL-Attribution-ShareAlike-3.0"
SLOT="0"
KEYWORDS="~x86 ~amd64"
RESTRICT="strip binchecks"
IUSE="+java"
RDEPEND="dev-embedded/avrdude
	sys-devel/crossdev"
DEPEND="${RDEPEND} java? (
	virtual/jre
	dev-embedded/uisp
	dev-java/jikes
	dev-java/jna
	>=dev-java/rxtx-2.2_pre2 )"

pkg_postinst() {
	ewarn "PLEASE NOTICE:"
	if [ ! -x /usr/bin/avr-g++ ]; then
		ewarn "avr-g++ is missing, if you need a toolchain please see"
		ewarn "http://en.gentoo-wiki.com/wiki/Crossdev#AVR_Architecture"
		ewarn ""
	fi
	ewarn "You will need >=cross-avr/gcc-4.4.1 if you intend to use the new"
	ewarn "Arduino Mega 2560."
}

src_prepare() {
	# avrdude has it's own ebuild
	rm -rf hardware/tools/avrdude*

	# fix deprecated prog_char usage in Print.cpp (#303043)
	epatch "${FILESDIR}"/${P}-prog_char-fix.patch

	# -java don't build IDE
	if ! use java; then
		rm -rf lib
		rm -f arduino
	else
		# fix the provided arduino script to call out the right
		# libraries, remove resetting of $PATH, and fix its
		# reference to LD_LIBRARY_PATH (see bug #189249)
		epatch "${FILESDIR}"/${P}-script.patch
	fi
}

src_install() {
	mkdir -p "${D}/usr/share/${P}/" "${D}/usr/bin"
	cp -a "${S}" "${D}/usr/share/" || die "Copying failed"

	if use java; then
		sed -e s@__PN__@${P}@g < "${FILESDIR}"/arduino \
			> "${D}/usr/bin/arduino" && chmod +x "${D}/usr/bin/arduino" \
			|| die "Creating run script failed"

		# get rid of libraries provided by other packages
		rm -f "${D}/usr/share/${P}/lib/RXTXcomm.jar"
		rm -f "${D}/usr/share/${P}/lib/jna.jar"
		rm -f "${D}/usr/share/${P}/lib/librxtxSerial.so"
		rm -f "${D}/usr/share/${P}/lib/librxtxSerial64.so"
		rm -f "${D}/usr/share/${P}/lib/ecj.jar"

		# use system avrdude
		# patching class files is too hard
		dosym /usr/bin/avrdude "/usr/share/${P}/hardware/tools/avrdude" \
			|| die "Couldn't symlink system avrdude files"
		dosym /etc/avrdude.conf "/usr/share/${P}/hardware/tools/avrdude.conf" \
			|| die "Couldn't symlink system avrdude files"
	fi
}