1################################################################################
2#
3# openocd
4#
5################################################################################
6
7OPENOCD_VERSION = 0.12.0
8OPENOCD_SOURCE = openocd-$(OPENOCD_VERSION).tar.bz2
9OPENOCD_SITE = http://sourceforge.net/projects/openocd/files/openocd/$(OPENOCD_VERSION)
10OPENOCD_LICENSE = \
11	BSD-1-clause, \
12	BSD-2-clause, \
13	BSD-2-Clause-Views, \
14	BSD-3-clause, \
15	BSD-Source-Code, \
16	GFDL-1.2-no-invariants-or-later (docs), \
17	GPL-2.0+ with eCos-exception-2.0 (code), \
18	GPL-3.0+ (stand-alone code), \
19	MIT
20
21OPENOCD_LICENSE_FILES = \
22	COPYING \
23	LICENSES/license-rules.txt \
24	LICENSES/exceptions/eCos-exception-2.0 \
25	LICENSES/preferred/BSD-1-Clause \
26	LICENSES/preferred/BSD-2-Clause \
27	LICENSES/preferred/BSD-2-Clause-Views \
28	LICENSES/preferred/BSD-3-Clause \
29	LICENSES/preferred/BSD-Source-Code \
30	LICENSES/preferred/GFDL-1.2 \
31	LICENSES/preferred/gfdl-1.2.texi.readme \
32	LICENSES/preferred/GPL-2.0 \
33	LICENSES/preferred/MIT \
34	LICENSES/stand-alone/GPL-3.0
35
36# 0001-configure-enable-build-on-uclinux.patch patches configure.ac
37OPENOCD_AUTORECONF = YES
38OPENOCD_CONF_ENV = CFLAGS="$(TARGET_CFLAGS) -std=gnu99"
39
40OPENOCD_CONF_OPTS = \
41	--oldincludedir=$(STAGING_DIR)/usr/include \
42	--includedir=$(STAGING_DIR)/usr/include \
43	--disable-doxygen-html \
44	--disable-internal-jimtcl \
45	--disable-shared \
46	--enable-dummy \
47	--disable-werror
48
49# Rely on the Config.in options of each individual adapter selecting
50# the dependencies they need.
51
52OPENOCD_DEPENDENCIES = \
53	host-pkgconf \
54	jimtcl \
55	$(if $(BR2_PACKAGE_LIBFTDI1),libftdi1) \
56	$(if $(BR2_PACKAGE_LIBUSB),libusb) \
57	$(if $(BR2_PACKAGE_LIBUSB_COMPAT),libusb-compat) \
58	$(if $(BR2_PACKAGE_LIBHID),libhid) \
59	$(if $(BR2_PACKAGE_HIDAPI),hidapi)
60
61ifeq ($(BR2_PACKAGE_LIBGPIOD),y)
62OPENOCD_DEPENDENCIES += libgpiod
63OPENOCD_CONF_OPTS += --enable-linuxgpiod
64else
65OPENOCD_CONF_OPTS += --disable-linuxgpiod
66endif
67
68# Adapters
69OPENOCD_CONF_OPTS += \
70	$(if $(BR2_PACKAGE_OPENOCD_FTDI),--enable-ftdi,--disable-ftdi) \
71	$(if $(BR2_PACKAGE_OPENOCD_STLINK),--enable-stlink,--disable-stlink) \
72	$(if $(BR2_PACKAGE_OPENOCD_TI_ICDI),--enable-ti-icdi,--disable-ti-icdi) \
73	$(if $(BR2_PACKAGE_OPENOCD_ULINK),--enable-ulink,--disable-ulink) \
74	$(if $(BR2_PACKAGE_OPENOCD_UBLASTER2),--enable-usb-blaster-2,--disable-usb-blaster-2) \
75	$(if $(BR2_PACKAGE_OPENOCD_JLINK),--enable-jlink,--disable-jlink) \
76	$(if $(BR2_PACKAGE_OPENOCD_OSDBM),--enable-osbdm,--disable-osbdm) \
77	$(if $(BR2_PACKAGE_OPENOCD_OPENDOUS),--enable-opendous,--disable-opendous) \
78	$(if $(BR2_PACKAGE_OPENOCD_AICE),--enable-aice,--disable-aice) \
79	$(if $(BR2_PACKAGE_OPENOCD_VSLLINK),--enable-vsllink,--disable-vsllink) \
80	$(if $(BR2_PACKAGE_OPENOCD_USBPROG),--enable-usbprog,--disable-usbprog) \
81	$(if $(BR2_PACKAGE_OPENOCD_RLINK),--enable-rlink,--disable-rlink) \
82	$(if $(BR2_PACKAGE_OPENOCD_XDS110),--enable-xds110,--disable-xds110) \
83	$(if $(BR2_PACKAGE_OPENOCD_ARMEW),--enable-armjtagew,--disable-armjtagew) \
84	$(if $(BR2_PACKAGE_OPENOCD_CMSIS_DAP),--enable-cmsis-dap,--disable-cmsis-dap) \
85	$(if $(BR2_PACKAGE_OPENOCD_PARPORT),--enable-parport,--disable-parport) \
86	$(if $(BR2_PACKAGE_OPENOCD_VPI),--enable-jtag_vpi,--disable-jtag_vpi) \
87	$(if $(BR2_PACKAGE_OPENOCD_UBLASTER),--enable-usb-blaster,--disable-usb-blaster) \
88	$(if $(BR2_PACKAGE_OPENOCD_AMTJT),--enable-amtjtagaccel,--disable-amjtagaccel) \
89	$(if $(BR2_PACKAGE_OPENOCD_EP93XX),--enable-ep93xx,--disable-ep93xx) \
90	$(if $(BR2_PACKAGE_OPENOCD_AT91RM),--enable-at91rm9200,--disable-at91rm9200) \
91	$(if $(BR2_PACKAGE_OPENOCD_BCM2835),--enable-bcm2835gpio,--disable-bcm2835gpio) \
92	$(if $(BR2_PACKAGE_OPENOCD_GW16012),--enable-gw16012,--disable-gw16012) \
93	$(if $(BR2_PACKAGE_OPENOCD_PRESTO),--enable-presto,--disable-presto) \
94	$(if $(BR2_PACKAGE_OPENOCD_OPENJTAG),--enable-openjtag,--disable-openjtag) \
95	$(if $(BR2_PACKAGE_OPENOCD_BUSPIRATE),--enable-buspirate,--disable-buspirate) \
96	$(if $(BR2_PACKAGE_OPENOCD_SYSFS),--enable-sysfsgpio,--disable-sysfsgpio)
97
98# Enable all configuration options for host build.
99#
100# Note that deprecated options have been removed. CMSIS_DAP needs
101# hidapi (currently not included in buildroot) and zy1000 stuff fails
102# to build, so they've been removed too.
103#
104HOST_OPENOCD_CONF_OPTS = \
105	--enable-ftdi \
106	--enable-stlink \
107	--enable-ti-icdi \
108	--enable-ulink \
109	--enable-usb-blaster-2 \
110	--enable-jlink \
111	--enable-osbdm \
112	--enable-opendous \
113	--enable-aice \
114	--enable-vsllink \
115	--enable-usbprog \
116	--enable-rlink \
117	--enable-armjtagew \
118	--enable-parport \
119	--enable-jtag_vpi \
120	--enable-usb-blaster \
121	--enable-amtjtagaccel \
122	--enable-gw16012 \
123	--enable-presto \
124	--enable-openjtag \
125	--enable-buspirate \
126	--enable-sysfsgpio \
127	--oldincludedir=$(HOST_DIR)/include \
128	--includedir=$(HOST_DIR)/include \
129	--disable-doxygen-html \
130	--disable-internal-jimtcl \
131	--disable-shared \
132	--enable-dummy \
133	--disable-werror
134
135HOST_OPENOCD_DEPENDENCIES = host-jimtcl host-libftdi host-libusb host-libusb-compat
136
137# Avoid documentation rebuild. On PowerPC64(le), we patch the
138# configure script. Due to this, the version.texi files gets
139# regenerated, and then since it has a newer date than openocd.info,
140# openocd build system rebuilds the documentation. Unfortunately, this
141# documentation rebuild fails on old machines. We work around this by
142# faking the date of the generated version.texi file, to make the
143# build system believe the documentation doesn't need to be
144# regenerated.
145define OPENOCD_FIX_VERSION_TEXI
146	touch -r $(@D)/doc/openocd.info $(@D)/doc/version.texi
147endef
148OPENOCD_POST_BUILD_HOOKS += OPENOCD_FIX_VERSION_TEXI
149HOST_OPENOCD_POST_BUILD_HOOKS += OPENOCD_FIX_VERSION_TEXI
150
151$(eval $(autotools-package))
152$(eval $(host-autotools-package))
153