summaryrefslogtreecommitdiff
blob: 5f112f41e5482e22815e7b3d7342322a1b38c413 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

inherit eutils multilib flag-o-matic toolchain-funcs udev autotools git-r3
EGIT_REPO_URI="https://git.code.sf.net/p/${PN}/code"
EGIT_SUBMODULES=("-*libjaylink" "-jimtcl")

DESCRIPTION="OpenOCD - Open On-Chip Debugger"
HOMEPAGE="http://openocd.sourceforge.net"

LICENSE="GPL-2+"
SLOT="0"
IUSE="+cmsis-dap dummy +ftdi +jlink parport +usb verbose-io"
RESTRICT="strip" # includes non-native binaries

RDEPEND="
	>=dev-lang/jimtcl-0.76
	cmsis-dap? ( dev-libs/hidapi )
	jlink? ( >=dev-embedded/libjaylink-0.1.0 )
	usb? (
		virtual/libusb:0
		virtual/libusb:1
	)
	ftdi? ( dev-embedded/libftdi )
"

DEPEND="
	${RDEPEND}
	virtual/pkgconfig
	>=sys-apps/texinfo-5
"

src_prepare() {
	default

	AT_NO_RECURSIVE=yes eautoreconf
}

src_configure() {
	# Here are some defaults
	local myconf=(
		--enable-buspirate
		--disable-werror
		--disable-internal-jimtcl
		--disable-internal-libjaylink
		--enable-amtjtagaccel
		--enable-ep93xx
		--enable-at91rm9200
		--enable-gw16012
		--enable-arm-jtag-ew
		--enable-sysfsgpio
		--enable-bcm2835gpio
	)

	# Adapters requiring usb/libusb-1.X support
	if use usb; then
		myconf+=(
			--enable-aice
			--enable-usb-blaster-2
			--enable-ftdi
			--enable-ti-icdi
			--enable-ulink
			--enable-osbdm
			--enable-opendous
			--enable-usbprog
			--enable-rlink
			--enable-stlink
			--enable-vsllink
			--enable-armjtagew
			$(use_enable verbose-io verbose-usb-io)
			$(use_enable verbose-io verbose_usb_comms)
		)
	else
		myconf+=(
			--disable-aice
			--disable-usb-blaster-2
			--disable-ftdi
			--disable-ti-icdi
			--disable-ulink
			--disable-osbdm
			--disable-opendous
			--disable-usbprog
			--disable-jlink
			--disable-rlink
			--disable-stlink
			--disable-vsllink
			--disable-armjtagew
		)
	fi

	if use jlink; then
		myconf+=(
			--enable-jlink
		)
	else
		myconf+=(
			--disable-jlink
		)
	fi

	if use ftdi; then
		myconf+=(
			--enable-usb_blaster
			--enable-openjtag
			--enable-presto
		)
	else
		myconf+=(
			--disable-openjtag
			--disable-presto
			--disable-usb_blaster
		)
	fi

	econf \
		$(use_enable dummy) \
		$(use_enable cmsis-dap) \
		$(use_enable parport) \
		$(use_enable parport parport_ppdev) \
		$(use_enable verbose-io verbose-jtag-io) \
		"${myconf[@]}"
}

src_install() {
	default
	env -uRESTRICT prepstrip "${ED}"/usr/bin
	udev_dorules ${D}/usr/share/${PN}/contrib/*.rules
}

pkg_postinst() {
    elog "To access openocd devices as user you must be in the plugdev group"
}