You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

configure.ac 39 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259
  1. AC_PREREQ(2.60)
  2. AC_INIT([openocd], [0.6.0-dev],
  3. [OpenOCD Mailing List <openocd-devel@lists.sourceforge.net>])
  4. AC_CONFIG_SRCDIR([src/openocd.c])
  5. m4_include([config_subdir.m4])dnl
  6. AM_INIT_AUTOMAKE([-Wall -Wno-portability dist-bzip2 dist-zip])
  7. AM_MAINTAINER_MODE
  8. AM_CONFIG_HEADER([config.h])
  9. AH_BOTTOM([
  10. #include <helper/system.h>
  11. #include <helper/replacements.h>
  12. ])
  13. AC_LANG_C
  14. AC_PROG_CC
  15. AC_PROG_CC_C99
  16. AM_PROG_CC_C_O
  17. AC_PROG_RANLIB
  18. dnl disable checks for C++, Fortran and GNU Java Compiler
  19. m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
  20. m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
  21. m4_defun([_LT_AC_LANG_GCJ_CONFIG], [:])
  22. AC_DISABLE_SHARED
  23. AC_PROG_LIBTOOL
  24. AC_SUBST([LIBTOOL_DEPS])
  25. dnl configure checks required for Jim files (these are obsolete w/ C99)
  26. AC_C_CONST
  27. AC_TYPE_LONG_LONG_INT
  28. AC_SEARCH_LIBS([ioperm], [ioperm])
  29. AC_SEARCH_LIBS([dlopen], [dl])
  30. AC_CHECK_HEADERS([sys/socket.h])
  31. AC_CHECK_HEADERS([arpa/inet.h], [], [], [dnl
  32. #include <stdio.h>
  33. #ifdef STDC_HEADERS
  34. # include <stdlib.h>
  35. # include <stddef.h>
  36. #else
  37. # ifdef HAVE_STDLIB_H
  38. # include <stdlib.h>
  39. # endif
  40. #endif
  41. #ifdef HAVE_SYS_SOCKET_H
  42. # include <sys/socket.h>
  43. #endif
  44. ])
  45. AC_CHECK_HEADERS([elf.h])
  46. AC_CHECK_HEADERS([dirent.h])
  47. AC_CHECK_HEADERS([fcntl.h])
  48. AC_CHECK_HEADERS([ifaddrs.h], [], [], [dnl
  49. #include <stdio.h>
  50. #ifdef STDC_HEADERS
  51. # include <stdlib.h>
  52. # include <stddef.h>
  53. #else
  54. # ifdef HAVE_STDLIB_H
  55. # include <stdlib.h>
  56. # endif
  57. #endif
  58. #ifdef HAVE_SYS_SOCKET_H
  59. # include <sys/socket.h>
  60. #endif
  61. ])
  62. AC_CHECK_HEADERS([malloc.h])
  63. AC_CHECK_HEADERS([netdb.h])
  64. AC_CHECK_HEADERS([netinet/in.h], [], [], [dnl
  65. #include <stdio.h>
  66. #ifdef STDC_HEADERS
  67. # include <stdlib.h>
  68. # include <stddef.h>
  69. #else
  70. # ifdef HAVE_STDLIB_H
  71. # include <stdlib.h>
  72. # endif
  73. #endif
  74. #ifdef HAVE_SYS_SOCKET_H
  75. # include <sys/socket.h>
  76. #endif
  77. ])
  78. AC_CHECK_HEADERS([netinet/tcp.h], [], [], [dnl
  79. #include <stdio.h>
  80. #ifdef STDC_HEADERS
  81. # include <stdlib.h>
  82. # include <stddef.h>
  83. #else
  84. # ifdef HAVE_STDLIB_H
  85. # include <stdlib.h>
  86. # endif
  87. #endif
  88. #ifdef HAVE_SYS_SOCKET_H
  89. # include <sys/socket.h>
  90. #endif
  91. ])
  92. AC_CHECK_HEADERS([pthread.h])
  93. AC_CHECK_HEADERS([strings.h])
  94. AC_CHECK_HEADERS([sys/ioctl.h])
  95. AC_CHECK_HEADERS([sys/param.h])
  96. AC_CHECK_HEADERS([sys/poll.h])
  97. AC_CHECK_HEADERS([sys/select.h])
  98. AC_CHECK_HEADERS([sys/stat.h])
  99. AC_CHECK_HEADERS([sys/time.h])
  100. AC_CHECK_HEADERS([sys/types.h])
  101. AC_CHECK_HEADERS([unistd.h])
  102. AC_CHECK_HEADERS([net/if.h], [], [], [dnl
  103. #include <stdio.h>
  104. #ifdef STDC_HEADERS
  105. # include <stdlib.h>
  106. # include <stddef.h>
  107. #else
  108. # ifdef HAVE_STDLIB_H
  109. # include <stdlib.h>
  110. # endif
  111. #endif
  112. #ifdef HAVE_SYS_SOCKET_H
  113. # include <sys/socket.h>
  114. #endif
  115. ])
  116. AC_HEADER_ASSERT
  117. AC_HEADER_STDBOOL
  118. AC_HEADER_TIME
  119. AC_C_BIGENDIAN
  120. AC_CHECK_FUNCS([strndup])
  121. AC_CHECK_FUNCS([strnlen])
  122. AC_CHECK_FUNCS([gettimeofday])
  123. AC_CHECK_FUNCS([usleep])
  124. AC_CHECK_FUNCS([vasprintf])
  125. build_bitbang=no
  126. build_bitq=no
  127. is_cygwin=no
  128. is_mingw=no
  129. is_win32=no
  130. is_darwin=no
  131. # guess-rev.sh only exists in the repository, not in the released archives
  132. AC_MSG_CHECKING([whether to build a release])
  133. if test -x $srcdir/guess-rev.sh ; then
  134. build_release=no
  135. else
  136. build_release=yes
  137. fi
  138. AC_MSG_RESULT([$build_release])
  139. # We are not *ALWAYS* being installed in the standard place.
  140. # We may be installed in a "tool-build" specific location.
  141. # Normally with other packages - as part of a tool distro.
  142. # Thus - we should search that 'libdir' also.
  143. #
  144. # And - if we are being installed there - the odds are
  145. # The libraries unique to what we are are there too.
  146. #
  147. # Expand nd deal with NONE - just like configure will do later
  148. OCDprefix=$prefix
  149. OCDxprefix=$exec_prefix
  150. test x"$OCDprefix" = xNONE && OCDprefix=$ac_default_prefix
  151. # Let make expand exec_prefix.
  152. test x"$OCDxprefix" = xNONE && OCDxprefix="$OCDprefix"
  153. # what matters is the "exec-prefix"
  154. if test "$OCDxprefix" != "$ac_default_prefix"
  155. then
  156. # We are installing in a non-standard place
  157. # Nonstandard --prefix and/or --exec-prefix
  158. # We have an override of some sort.
  159. # use build specific install library dir
  160. LDFLAGS="$LDFLAGS -L$OCDxprefix/lib"
  161. # RPATH becomes an issue on Linux only
  162. if test $host_os = linux-gnu || test $host_os = linux ; then
  163. LDFLAGS="$LDFLAGS -Wl,-rpath,$OCDxprefix/lib"
  164. fi
  165. # The "INCDIR" is also usable
  166. CFLAGS="$CFLAGS -I$includedir"
  167. fi
  168. AC_ARG_WITH(ftd2xx,
  169. AS_HELP_STRING([--with-ftd2xx=<PATH>],[This option has been removed.]),
  170. [
  171. # Option Given.
  172. cat << __EOF__
  173. The option: --with-ftd2xx=<PATH> has been removed.
  174. On Linux, the new option is:
  175. --with-ftd2xx-linux-tardir=/path/to/files
  176. Where <path> is the path the the directory where the "tar.gz" file
  177. from FTDICHIP.COM was unpacked, for example:
  178. --with-ftd2xx-linux-tardir=${HOME}/libftd2xx0.4.16
  179. On Cygwin/MingW32, the new option is:
  180. --with-ftd2xx-win32-zipdir=/path/to/files
  181. Where <path> is the path to the directory where the "zip" file from
  182. FTDICHIP.COM was unpacked, for example:
  183. --with-ftd2xx-win32-zipdir=${HOME}/ftd2xx.cdm.files
  184. __EOF__
  185. AC_MSG_ERROR([Sorry Cannot continue])
  186. ], [true])
  187. #========================================
  188. # FTD2XXX support comes in 4 forms.
  189. # (1) win32 - via a zip file
  190. # (2) linux - via a tar file
  191. # (3) linux/cygwin/mingw - via libftdi
  192. # (4) darwin - installed under /usr/local
  193. #
  194. # In case (1) and (2) we need to know where the package was unpacked.
  195. AC_ARG_WITH(ftd2xx-win32-zipdir,
  196. AS_HELP_STRING([--with-ftd2xx-win32-zipdir],[Where (CYGWIN/MINGW) the zip file from ftdichip.com was unpacked <default=search>]),
  197. [
  198. # option present
  199. if test -d $with_ftd2xx_win32_zipdir
  200. then
  201. with_ftd2xx_win32_zipdir=`cd $with_ftd2xx_win32_zipdir && pwd`
  202. AC_MSG_NOTICE([Using: ftdichip.com library: $with_ftd2xx_win32_zipdir])
  203. else
  204. AC_MSG_ERROR([Parameter to --with-ftd2xx-win32-zipdir is not a dir: $with_ftd2xx_win32_zipdir])
  205. fi
  206. ], [true])
  207. AC_ARG_WITH(ftd2xx-linux-tardir,
  208. AS_HELP_STRING([--with-ftd2xx-linux-tardir], [Where (Linux/Unix) the tar file from ftdichip.com was unpacked <default=search>]),
  209. [
  210. # Option present
  211. if test $is_win32 = yes ; then
  212. AC_MSG_ERROR([The option: --with-ftd2xx-linux-tardir is only usable on linux])
  213. fi
  214. if test -d $with_ftd2xx_linux_tardir
  215. then
  216. with_ftd2xx_linux_tardir=`cd $with_ftd2xx_linux_tardir && pwd`
  217. AC_MSG_NOTICE([Using: ftdichip.com library: $with_ftd2xx_linux_tardir])
  218. else
  219. AC_MSG_ERROR([Parameter to --with-ftd2xx-linux-tardir is not a dir: $with_ftd2xx_linux_tardir])
  220. fi
  221. ], [true])
  222. AC_ARG_WITH(ftd2xx-lib,
  223. AS_HELP_STRING([--with-ftd2xx-lib],
  224. [Use static or shared ftd2xx libs on default static]),
  225. [
  226. case "$withval" in
  227. static)
  228. with_ftd2xx_lib=$withval
  229. ;;
  230. shared)
  231. with_ftd2xx_lib=$withval
  232. ;;
  233. *)
  234. AC_MSG_ERROR([Option: --with-ftd2xx-lib=static or --with-ftd2xx-lib=shared not, $withval])
  235. ;;
  236. esac
  237. ], [
  238. # Default is static - it is simpler :-(
  239. with_ftd2xx_lib=static
  240. ])
  241. AC_ARG_ENABLE([doxygen-html],
  242. AS_HELP_STRING([--disable-doxygen-html],
  243. [Disable building Doxygen manual as HTML.]),
  244. [doxygen_as_html=$enableval], [doxygen_as_html=yes])
  245. AC_SUBST([doxygen_as_html])
  246. AC_MSG_CHECKING([whether to build Doxygen as HTML])
  247. AC_MSG_RESULT([$doxygen_as_html])
  248. AC_ARG_ENABLE([doxygen-pdf],
  249. AS_HELP_STRING([--enable-doxygen-pdf],
  250. [Enable building Doxygen manual as PDF.]),
  251. [doxygen_as_pdf=$enableval], [doxygen_as_pdf=no])
  252. AC_SUBST([doxygen_as_pdf])
  253. AC_MSG_CHECKING([whether to build Doxygen as PDF])
  254. AC_MSG_RESULT([$doxygen_as_pdf])
  255. AC_ARG_ENABLE([gccwarnings],
  256. AS_HELP_STRING([--disable-gccwarnings], [Disable compiler warnings]),
  257. [gcc_warnings=$enableval], [gcc_warnings=yes])
  258. AC_ARG_ENABLE([wextra],
  259. AS_HELP_STRING([--disable-wextra], [Disable extra compiler warnings]),
  260. [gcc_wextra=$enableval], [gcc_wextra=$gcc_warnings])
  261. AC_ARG_ENABLE([werror],
  262. AS_HELP_STRING([--disable-werror], [Do not treat warnings as errors]),
  263. [gcc_werror=$enableval], [gcc_werror=$gcc_warnings])
  264. # set default verbose options, overridden by following options
  265. debug_jtag_io=no
  266. debug_usb_io=no
  267. debug_usb_comms=no
  268. AC_ARG_ENABLE([verbose],
  269. AS_HELP_STRING([--enable-verbose],
  270. [Enable verbose JTAG I/O messages (for debugging).]),
  271. [
  272. debug_jtag_io=$enableval
  273. debug_usb_io=$enableval
  274. debug_usb_comms=$enableval
  275. ], [])
  276. AC_ARG_ENABLE([verbose_jtag_io],
  277. AS_HELP_STRING([--enable-verbose-jtag-io],
  278. [Enable verbose JTAG I/O messages (for debugging).]),
  279. [debug_jtag_io=$enableval], [])
  280. AC_ARG_ENABLE([verbose_usb_io],
  281. AS_HELP_STRING([--enable-verbose-usb-io],
  282. [Enable verbose USB I/O messages (for debugging)]),
  283. [debug_usb_io=$enableval], [])
  284. AC_ARG_ENABLE([verbose_usb_comms],
  285. AS_HELP_STRING([--enable-verbose-usb-comms],
  286. [Enable verbose USB communication messages (for debugging)]),
  287. [debug_usb_comms=$enableval], [])
  288. AC_MSG_CHECKING([whether to enable verbose JTAG I/O messages]);
  289. AC_MSG_RESULT([$debug_jtag_io])
  290. if test $debug_jtag_io = yes; then
  291. AC_DEFINE([_DEBUG_JTAG_IO_],[1], [Print verbose JTAG I/O messages])
  292. fi
  293. AC_MSG_CHECKING([whether to enable verbose USB I/O messages]);
  294. AC_MSG_RESULT([$debug_usb_io])
  295. if test $debug_usb_io = yes; then
  296. AC_DEFINE([_DEBUG_USB_IO_],[1], [Print verbose USB I/O messages])
  297. fi
  298. AC_MSG_CHECKING([whether to enable verbose USB communication messages]);
  299. AC_MSG_RESULT([$debug_usb_comms])
  300. if test $debug_usb_comms = yes; then
  301. AC_DEFINE([_DEBUG_USB_COMMS_],[1], [Print verbose USB communication messages])
  302. fi
  303. debug_malloc=no
  304. AC_ARG_ENABLE([malloc_logging],
  305. AS_HELP_STRING([--enable-malloc-logging],
  306. [Include free space in logging messages (requires malloc.h).]),
  307. [debug_malloc=$enableval], [])
  308. AC_MSG_CHECKING([whether to enable malloc free space logging]);
  309. AC_MSG_RESULT([$debug_malloc])
  310. if test $debug_malloc = yes; then
  311. AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging])
  312. fi
  313. AC_ARG_ENABLE([dummy],
  314. AS_HELP_STRING([--enable-dummy], [Enable building the dummy port driver]),
  315. [build_dummy=$enableval], [build_dummy=no])
  316. AC_ARG_ENABLE([parport],
  317. AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
  318. [build_parport=$enableval], [build_parport=no])
  319. AC_ARG_ENABLE([parport_ppdev],
  320. AS_HELP_STRING([--disable-parport-ppdev],
  321. [Disable use of ppdev (/dev/parportN) for parport (for x86 only)]),
  322. [parport_use_ppdev=$enableval], [parport_use_ppdev=yes])
  323. AC_ARG_ENABLE([parport_giveio],
  324. AS_HELP_STRING([--enable-parport-giveio],
  325. [Enable use of giveio for parport (for CygWin only)]),
  326. [parport_use_giveio=$enableval], [parport_use_giveio=])
  327. AC_ARG_ENABLE([ft2232_libftdi],
  328. AS_HELP_STRING([--enable-ft2232_libftdi], [Enable building support for FT2232 based devices using the libftdi driver, opensource alternate of FTD2XX]),
  329. [build_ft2232_libftdi=$enableval], [build_ft2232_libftdi=no])
  330. AC_ARG_ENABLE([ft2232_ftd2xx],
  331. AS_HELP_STRING([--enable-ft2232_ftd2xx], [Enable building support for FT2232 based devices using the FTD2XX driver from ftdichip.com]),
  332. [build_ft2232_ftd2xx=$enableval], [build_ft2232_ftd2xx=no])
  333. AC_ARG_ENABLE([usb_blaster_libftdi],
  334. AS_HELP_STRING([--enable-usb_blaster_libftdi], [Enable building support for the Altera USB-Blaster using the libftdi driver, opensource alternate of FTD2XX]),
  335. [build_usb_blaster_libftdi=$enableval], [build_usb_blaster_libftdi=no])
  336. AC_ARG_ENABLE([usb_blaster_ftd2xx],
  337. AS_HELP_STRING([--enable-usb_blaster_ftd2xx], [Enable building support for the Altera USB-Blaster using the FTD2XX driver from ftdichip.com]),
  338. [build_usb_blaster_ftd2xx=$enableval], [build_usb_blaster_ftd2xx=no])
  339. AC_ARG_ENABLE([amtjtagaccel],
  340. AS_HELP_STRING([--enable-amtjtagaccel], [Enable building the Amontec JTAG-Accelerator driver]),
  341. [build_amtjtagaccel=$enableval], [build_amtjtagaccel=no])
  342. AC_ARG_ENABLE([zy1000_master],
  343. AS_HELP_STRING([--enable-zy1000-master], [Use ZY1000 JTAG master registers]),
  344. [build_zy1000_master=$enableval], [build_zy1000_master=no])
  345. AC_ARG_ENABLE([zy1000],
  346. AS_HELP_STRING([--enable-zy1000], [Enable ZY1000 interface]),
  347. [build_zy1000=$enableval], [build_zy1000=no])
  348. AC_ARG_ENABLE([ioutil],
  349. AS_HELP_STRING([--enable-ioutil], [Enable ioutil functions - useful for standalone OpenOCD implementations]),
  350. [build_ioutil=$enableval], [build_ioutil=no])
  351. case "${host_cpu}" in
  352. arm*)
  353. AC_ARG_ENABLE([ep93xx],
  354. AS_HELP_STRING([--enable-ep93xx], [Enable building support for EP93xx based SBCs]),
  355. [build_ep93xx=$enableval], [build_ep93xx=no])
  356. AC_ARG_ENABLE([at91rm9200],
  357. AS_HELP_STRING([--enable-at91rm9200], [Enable building support for AT91RM9200 based SBCs]),
  358. [build_at91rm9200=$enableval], [build_at91rm9200=no])
  359. ;;
  360. *)
  361. build_ep93xx=no
  362. build_at91rm9200=no
  363. ;;
  364. esac
  365. AC_ARG_ENABLE([gw16012],
  366. AS_HELP_STRING([--enable-gw16012], [Enable building support for the Gateworks GW16012 JTAG Programmer]),
  367. [build_gw16012=$enableval], [build_gw16012=no])
  368. AC_ARG_ENABLE([presto_libftdi],
  369. AS_HELP_STRING([--enable-presto_libftdi], [Enable building support for ASIX Presto Programmer using the libftdi driver]),
  370. [build_presto_libftdi=$enableval], [build_presto_libftdi=no])
  371. AC_ARG_ENABLE([presto_ftd2xx],
  372. AS_HELP_STRING([--enable-presto_ftd2xx], [Enable building support for ASIX Presto Programmer using the FTD2XX driver]),
  373. [build_presto_ftd2xx=$enableval], [build_presto_ftd2xx=no])
  374. AC_ARG_ENABLE([usbprog],
  375. AS_HELP_STRING([--enable-usbprog], [Enable building support for the usbprog JTAG Programmer]),
  376. [build_usbprog=$enableval], [build_usbprog=no])
  377. AC_ARG_ENABLE([oocd_trace],
  378. AS_HELP_STRING([--enable-oocd_trace],
  379. [Enable building support for some prototype OpenOCD+trace ETM capture hardware]),
  380. [build_oocd_trace=$enableval], [build_oocd_trace=no])
  381. AC_ARG_ENABLE([jlink],
  382. AS_HELP_STRING([--enable-jlink], [Enable building support for the Segger J-Link JTAG Programmer]),
  383. [build_jlink=$enableval], [build_jlink=no])
  384. AC_ARG_ENABLE([vsllink],
  385. AS_HELP_STRING([--enable-vsllink], [Enable building support for the Versaloon-Link JTAG Programmer]),
  386. [build_vsllink=$enableval], [build_vsllink=no])
  387. AC_ARG_ENABLE([rlink],
  388. AS_HELP_STRING([--enable-rlink], [Enable building support for the Raisonance RLink JTAG Programmer]),
  389. [build_rlink=$enableval], [build_rlink=no])
  390. AC_ARG_ENABLE([ulink],
  391. AS_HELP_STRING([--enable-ulink], [Enable building support for the Keil ULINK JTAG Programmer]),
  392. [build_ulink=$enableval], [build_ulink=no])
  393. AC_ARG_ENABLE([arm-jtag-ew],
  394. AS_HELP_STRING([--enable-arm-jtag-ew], [Enable building support for the Olimex ARM-JTAG-EW Programmer]),
  395. [build_armjtagew=$enableval], [build_armjtagew=no])
  396. AC_ARG_ENABLE([buspirate],
  397. AS_HELP_STRING([--enable-buspirate], [Enable building support for the Buspirate]),
  398. [build_buspirate=$enableval], [build_buspirate=no])
  399. AC_ARG_ENABLE([stlink],
  400. AS_HELP_STRING([--enable-stlink], [Enable building support for the ST-Link JTAG Programmer]),
  401. [build_stlink=$enableval], [build_stlink=no])
  402. AC_ARG_ENABLE([osbdm],
  403. AS_HELP_STRING([--enable-osbdm], [Enable building support for the OSBDM (JTAG only) Programmer]),
  404. [build_osbdm=$enableval], [build_osbdm=no])
  405. AC_ARG_ENABLE([opendous],
  406. AS_HELP_STRING([--enable-opendous], [Enable building support for the estick/opendous JTAG Programmer]),
  407. [build_opendous=$enableval], [build_opendous=no])
  408. AC_ARG_ENABLE([minidriver_dummy],
  409. AS_HELP_STRING([--enable-minidriver-dummy], [Enable the dummy minidriver.]),
  410. [build_minidriver_dummy=$enableval], [build_minidriver_dummy=no])
  411. AC_ARG_ENABLE([internal-jimtcl],
  412. AS_HELP_STRING([--disable-internal-jimtcl], [Disable building internal jimtcl]),
  413. [use_internal_jimtcl=$enableval], [use_internal_jimtcl=yes])
  414. AC_ARG_ENABLE([libusb0],
  415. AS_HELP_STRING([--enable-libusb0], [Use libusb-0.1 library for USB JTAG devices]),
  416. [check_libusb0=$enableval], [check_libusb0=no])
  417. build_minidriver=no
  418. AC_MSG_CHECKING([whether to enable ZY1000 minidriver])
  419. if test $build_zy1000 = yes; then
  420. if test $build_minidriver = yes; then
  421. AC_MSG_ERROR([Multiple minidriver options have been enabled.])
  422. fi
  423. AC_DEFINE([HAVE_JTAG_MINIDRIVER_H], [1],
  424. [Define to 1 if you have the <jtag_minidriver.h> header file.])
  425. build_minidriver=yes
  426. fi
  427. AC_MSG_RESULT([$build_zy1000])
  428. AC_ARG_ENABLE([remote-bitbang],
  429. AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang jtag driver]),
  430. [build_remote_bitbang=$enableval], [build_remote_bitbang=no])
  431. AC_MSG_CHECKING([whether to enable dummy minidriver])
  432. if test $build_minidriver_dummy = yes; then
  433. if test $build_minidriver = yes; then
  434. AC_MSG_ERROR([Multiple minidriver options have been enabled.])
  435. fi
  436. build_minidriver=yes
  437. AC_DEFINE([BUILD_MINIDRIVER_DUMMY], [1], [Use the dummy minidriver.])
  438. AC_DEFINE([HAVE_JTAG_MINIDRIVER_H], [1],
  439. [Define to 1 if you have the <jtag_minidriver.h> header file.])
  440. fi
  441. AC_MSG_RESULT([$build_minidriver_dummy])
  442. AC_MSG_CHECKING([whether standard drivers can be built])
  443. if test "$build_minidriver" = yes; then
  444. AC_MSG_RESULT([no])
  445. AC_MSG_WARN([Using the minidriver disables all other drivers.])
  446. sleep 2
  447. else
  448. AC_MSG_RESULT([yes])
  449. fi
  450. case "${host_cpu}" in
  451. i?86|x86*)
  452. ;;
  453. *)
  454. if test x$parport_use_ppdev = xno; then
  455. AC_MSG_WARN([--disable-parport-ppdev is not supported by the host CPU])
  456. fi
  457. parport_use_ppdev=yes
  458. ;;
  459. esac
  460. case $host in
  461. *-cygwin*)
  462. is_win32=yes
  463. parport_use_ppdev=no
  464. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[return __MINGW32__;]])],
  465. [is_mingw=yes],[is_mingw=no])
  466. if test $is_mingw = yes; then
  467. AC_DEFINE([IS_MINGW], [1], [1 if building for MinGW.])
  468. if test x$parport_use_giveio = xno; then
  469. AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
  470. fi
  471. parport_use_giveio=yes
  472. is_cygwin=no
  473. else
  474. is_cygwin=yes
  475. AC_DEFINE([IS_CYGWIN], [1], [1 if building for Cygwin.])
  476. # sys/io.h needed under cygwin for parport access
  477. if test $build_parport = yes; then
  478. AC_CHECK_HEADERS([sys/io.h],[],AC_MSG_ERROR([Please install the cygwin ioperm package]))
  479. fi
  480. fi
  481. AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
  482. AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
  483. ;;
  484. *-mingw*)
  485. is_mingw=yes
  486. is_win32=yes
  487. parport_use_ppdev=no
  488. if test x$parport_use_giveio = xno; then
  489. AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
  490. fi
  491. parport_use_giveio=yes
  492. if test x$build_buspirate = xyes; then
  493. AC_MSG_ERROR([buspirate currently not supported by MinGW32 hosts])
  494. fi
  495. CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO"
  496. AC_DEFINE([IS_MINGW], [1], [1 if building for MinGW.])
  497. AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
  498. AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
  499. ;;
  500. *darwin*)
  501. is_darwin=yes
  502. if test x$parport_use_giveio = xyes; then
  503. AC_MSG_WARN([--enable-parport-giveio cannot be used by Darwin hosts])
  504. fi
  505. parport_use_giveio=no
  506. AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
  507. AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
  508. AC_DEFINE([IS_DARWIN], [1], [1 if building for Darwin.])
  509. ;;
  510. *)
  511. if test x$parport_use_giveio = xyes; then
  512. AC_MSG_WARN([--enable-parport-giveio cannot be used by ]$host[ hosts])
  513. fi
  514. parport_use_giveio=no
  515. AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
  516. AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
  517. AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
  518. ;;
  519. esac
  520. if test $build_parport = yes; then
  521. build_bitbang=yes
  522. AC_DEFINE([BUILD_PARPORT], [1], [1 if you want parport.])
  523. else
  524. AC_DEFINE([BUILD_PARPORT], [0], [0 if you don't want parport.])
  525. fi
  526. if test $build_dummy = yes; then
  527. build_bitbang=yes
  528. AC_DEFINE([BUILD_DUMMY], [1], [1 if you want dummy driver.])
  529. else
  530. AC_DEFINE([BUILD_DUMMY], [0], [0 if you don't want dummy driver.])
  531. fi
  532. if test $build_ep93xx = yes; then
  533. build_bitbang=yes
  534. AC_DEFINE([BUILD_EP93XX], [1], [1 if you want ep93xx.])
  535. else
  536. AC_DEFINE([BUILD_EP93XX], [0], [0 if you don't want ep93xx.])
  537. fi
  538. if test $build_zy1000 = yes; then
  539. AC_DEFINE([BUILD_ZY1000], [1], [1 if you want ZY1000.])
  540. else
  541. AC_DEFINE([BUILD_ZY1000], [0], [0 if you don't want ZY1000.])
  542. fi
  543. if test $build_zy1000_master = yes; then
  544. AC_DEFINE([BUILD_ZY1000_MASTER], [1], [1 if you want ZY1000 JTAG master registers.])
  545. else
  546. AC_DEFINE([BUILD_ZY1000_MASTER], [0], [0 if you don't want ZY1000 JTAG master registers.])
  547. fi
  548. if test $build_at91rm9200 = yes; then
  549. build_bitbang=yes
  550. AC_DEFINE([BUILD_AT91RM9200], [1], [1 if you want at91rm9200.])
  551. else
  552. AC_DEFINE([BUILD_AT91RM9200], [0], [0 if you don't want at91rm9200.])
  553. fi
  554. if test x$parport_use_ppdev = xyes; then
  555. AC_DEFINE([PARPORT_USE_PPDEV], [1], [1 if you want parport to use ppdev.])
  556. else
  557. AC_DEFINE([PARPORT_USE_PPDEV], [0], [0 if you don't want parport to use ppdev.])
  558. fi
  559. if test x$parport_use_giveio = xyes; then
  560. AC_DEFINE([PARPORT_USE_GIVEIO], [1], [1 if you want parport to use giveio.])
  561. else
  562. AC_DEFINE([PARPORT_USE_GIVEIO], [0], [0 if you don't want parport to use giveio.])
  563. fi
  564. if test $build_bitbang = yes; then
  565. AC_DEFINE([BUILD_BITBANG], [1], [1 if you want a bitbang interface.])
  566. else
  567. AC_DEFINE([BUILD_BITBANG], [0], [0 if you don't want a bitbang interface.])
  568. fi
  569. if test $build_ft2232_libftdi = yes; then
  570. AC_DEFINE([BUILD_FT2232_LIBFTDI], [1], [1 if you want libftdi ft2232.])
  571. else
  572. AC_DEFINE([BUILD_FT2232_LIBFTDI], [0], [0 if you don't want libftdi ft2232.])
  573. fi
  574. if test $build_ft2232_ftd2xx = yes; then
  575. AC_DEFINE([BUILD_FT2232_FTD2XX], [1], [1 if you want ftd2xx ft2232.])
  576. else
  577. AC_DEFINE([BUILD_FT2232_FTD2XX], [0], [0 if you don't want ftd2xx ft2232.])
  578. fi
  579. if test $build_usb_blaster_libftdi = yes; then
  580. build_bitbang=yes
  581. AC_DEFINE([BUILD_USB_BLASTER_LIBFTDI], [1], [1 if you want libftdi usb_blaster.])
  582. else
  583. AC_DEFINE([BUILD_USB_BLASTER_LIBFTDI], [0], [0 if you don't want libftdi usb_blaster.])
  584. fi
  585. if test $build_usb_blaster_ftd2xx = yes; then
  586. build_bitbang=yes
  587. AC_DEFINE([BUILD_USB_BLASTER_FTD2XX], [1], [1 if you want ftd2xx usb_blaster.])
  588. else
  589. AC_DEFINE([BUILD_USB_BLASTER_FTD2XX], [0], [0 if you don't want ftd2xx usb_blaster.])
  590. fi
  591. if test $build_amtjtagaccel = yes; then
  592. AC_DEFINE([BUILD_AMTJTAGACCEL], [1], [1 if you want the Amontec JTAG-Accelerator driver.])
  593. else
  594. AC_DEFINE([BUILD_AMTJTAGACCEL], [0], [0 if you don't want the Amontec JTAG-Accelerator driver.])
  595. fi
  596. if test $build_gw16012 = yes; then
  597. AC_DEFINE([BUILD_GW16012], [1], [1 if you want the Gateworks GW16012 driver.])
  598. else
  599. AC_DEFINE([BUILD_GW16012], [0], [0 if you don't want the Gateworks GW16012 driver.])
  600. fi
  601. if test $build_presto_libftdi = yes; then
  602. build_bitq=yes
  603. AC_DEFINE([BUILD_PRESTO_LIBFTDI], [1], [1 if you want the ASIX PRESTO driver using libftdi.])
  604. else
  605. AC_DEFINE([BUILD_PRESTO_LIBFTDI], [0], [0 if you don't want the ASIX PRESTO driver using libftdi.])
  606. fi
  607. if test $build_presto_ftd2xx = yes; then
  608. build_bitq=yes
  609. AC_DEFINE([BUILD_PRESTO_FTD2XX], [1], [1 if you want the ASIX PRESTO driver using FTD2XX.])
  610. else
  611. AC_DEFINE([BUILD_PRESTO_FTD2XX], [0], [0 if you don't want the ASIX PRESTO driver using FTD2XX.])
  612. fi
  613. if test $build_bitq = yes; then
  614. AC_DEFINE([BUILD_BITQ], [1], [1 if you want a bitq interface.])
  615. else
  616. AC_DEFINE([BUILD_BITQ], [0], [0 if you don't want a bitq interface.])
  617. fi
  618. if test $build_usbprog = yes; then
  619. AC_DEFINE([BUILD_USBPROG], [1], [1 if you want the usbprog JTAG driver.])
  620. else
  621. AC_DEFINE([BUILD_USBPROG], [0], [0 if you don't want the usbprog JTAG driver.])
  622. fi
  623. if test $build_oocd_trace = yes; then
  624. AC_DEFINE([BUILD_OOCD_TRACE], [1], [1 if you want the OpenOCD+trace ETM capture driver.])
  625. else
  626. AC_DEFINE([BUILD_OOCD_TRACE], [0], [0 if you don't want the OpenOCD+trace ETM capture driver.])
  627. fi
  628. if test $build_jlink = yes; then
  629. AC_DEFINE([BUILD_JLINK], [1], [1 if you want the J-Link JTAG driver.])
  630. else
  631. AC_DEFINE([BUILD_JLINK], [0], [0 if you don't want the J-Link JTAG driver.])
  632. fi
  633. if test $build_vsllink = yes; then
  634. AC_DEFINE([BUILD_VSLLINK], [1], [1 if you want the Versaloon-Link JTAG driver.])
  635. else
  636. AC_DEFINE([BUILD_VSLLINK], [0], [0 if you don't want the Versaloon-Link JTAG driver.])
  637. fi
  638. if test $build_rlink = yes; then
  639. AC_DEFINE([BUILD_RLINK], [1], [1 if you want the RLink JTAG driver.])
  640. else
  641. AC_DEFINE([BUILD_RLINK], [0], [0 if you don't want the RLink JTAG driver.])
  642. fi
  643. if test $build_ulink = yes; then
  644. AC_DEFINE([BUILD_ULINK], [1], [1 if you want the ULINK JTAG driver.])
  645. else
  646. AC_DEFINE([BUILD_ULINK], [0], [0 if you don't want the ULINK JTAG driver.])
  647. fi
  648. if test $build_armjtagew = yes; then
  649. AC_DEFINE([BUILD_ARMJTAGEW], [1], [1 if you want the ARM-JTAG-EW JTAG driver.])
  650. else
  651. AC_DEFINE([BUILD_ARMJTAGEW], [0], [0 if you don't want the ARM-JTAG-EW JTAG driver.])
  652. fi
  653. if test $build_buspirate = yes; then
  654. AC_DEFINE([BUILD_BUSPIRATE], [1], [1 if you want the Buspirate JTAG driver.])
  655. else
  656. AC_DEFINE([BUILD_BUSPIRATE], [0], [0 if you don't want the Buspirate JTAG driver.])
  657. fi
  658. if test $build_stlink = yes; then
  659. AC_DEFINE([BUILD_STLINK], [1], [1 if you want the ST-Link JTAG driver.])
  660. else
  661. AC_DEFINE([BUILD_STLINK], [0], [0 if you don't want the ST-Link JTAG driver.])
  662. fi
  663. if test $build_osbdm = yes; then
  664. AC_DEFINE([BUILD_OSBDM], [1], [1 if you want the OSBDM driver.])
  665. else
  666. AC_DEFINE([BUILD_OSBDM], [0], [0 if you don't want the OSBDM driver.])
  667. fi
  668. if test $build_opendous = yes; then
  669. AC_DEFINE([BUILD_OPENDOUS], [1], [1 if you want the estick/opendous JTAG driver.])
  670. else
  671. AC_DEFINE([BUILD_OPENDOUS], [0], [0 if you don't want the estick/opendous JTAG driver.])
  672. fi
  673. if test "$use_internal_jimtcl" = yes; then
  674. if test -f "$srcdir/jimtcl/configure.ac"; then
  675. AX_CONFIG_SUBDIR_OPTION([jimtcl], [--disable-install-jim])
  676. else
  677. AC_MSG_ERROR([jimtcl not found, run git submodule init and git submodule update.])
  678. fi
  679. fi
  680. if test $build_remote_bitbang = yes; then
  681. build_bitbang=yes
  682. AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang JTAG driver.])
  683. else
  684. AC_DEFINE([BUILD_REMOTE_BITBNAG], [0], [0 if you don't want the Remote Bitbang JTAG driver.])
  685. fi
  686. #-- Deal with MingW/Cygwin FTD2XX issues
  687. if test $is_win32 = yes; then
  688. if test "${with_ftd2xx_linux_tardir+set}" = set
  689. then
  690. AC_MSG_ERROR([The option: with_ftd2xx_linux_tardir is for LINUX only.])
  691. fi
  692. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o $build_usb_blaster_ftd2xx = yes ; then
  693. AC_MSG_CHECKING([for ftd2xx.lib exists (win32)])
  694. # if we are given a zipdir...
  695. if test "${with_ftd2xx_win32_zipdir+set}" = set
  696. then
  697. # Set the CFLAGS for "ftd2xx.h"
  698. f=$with_ftd2xx_win32_zipdir/ftd2xx.h
  699. if test ! -f $f ; then
  700. AC_MSG_ERROR([File: $f cannot be found])
  701. fi
  702. CFLAGS="$CFLAGS -I$with_ftd2xx_win32_zipdir"
  703. # And calculate the LDFLAGS for the machine
  704. case "$host_cpu" in
  705. i?86|x86_32)
  706. LDFLAGS="$LDFLAGS -L$with_ftd2xx_win32_zipdir/i386"
  707. LIBS="$LIBS -lftd2xx"
  708. f=$with_ftd2xx_win32_zipdir/i386/ftd2xx.lib
  709. ;;
  710. amd64|x86_64)
  711. LDFLAGS="$LDFLAGS -L$with_ftd2xx_win32_zipdir/amd64"
  712. LIBS="$LIBS -lftd2xx"
  713. f=$with_ftd2xx_win32_zipdir/amd64/ftd2xx.lib
  714. ;;
  715. *)
  716. AC_MSG_ERROR([Unknown Win32 host cpu: $host_cpu])
  717. ;;
  718. esac
  719. if test ! -f $f ; then
  720. AC_MSG_ERROR([Library: $f not found])
  721. fi
  722. else
  723. LIBS="$LIBS -lftd2xx"
  724. AC_MSG_WARN([ASSUMPTION: The (win32) FTDICHIP.COM files: ftd2xx.h and ftd2xx.lib are in a proper place])
  725. fi
  726. fi
  727. fi # win32
  728. if test $is_darwin = yes ; then
  729. if test "${with_ftd2xx_win32_zipdir+set}" = set
  730. then
  731. AC_MSG_ERROR([The option: --with-ftd2xx-win32-zipdir is for win32 only])
  732. fi
  733. if test "${with_ftd2xx_linux_tardir+set}" = set
  734. then
  735. AC_MSG_ERROR([The option: with_ftd2xx_linux_tardir is for LINUX only.])
  736. fi
  737. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes ; then
  738. AC_MSG_CHECKING([for libftd2xx.a (darwin)])
  739. if test ! -f /usr/local/include/ftd2xx.h ; then
  740. AC_MSG_ERROR([ftd2xx library from FTDICHIP.com seems to be missing, cannot find: /usr/local/include/ftd2xx.h])
  741. fi
  742. CFLAGS="$CFLAGS -I/usr/local/include"
  743. LDFLAGS="$LDFLAGS -L/usr/local/lib"
  744. LIBS="$LIBS -lftd2xx"
  745. AC_MSG_RESULT([-L/usr/local/lib -lftd2xx])
  746. fi
  747. fi # darwin
  748. if test $is_win32 = no && test $is_darwin = no ; then
  749. if test "${with_ftd2xx_win32_zipdir+set}" = set
  750. then
  751. AC_MSG_ERROR([The option: --with-ftd2xx-win32-zipdir is for win32 only])
  752. fi
  753. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes ; then
  754. # Must be linux
  755. if test $host_os != linux-gnu && test $host_os != linux ; then
  756. AC_MSG_ERROR([The (linux) ftd2xx library from FTDICHIP.com is linux only. Try --enable-ft2232-libftdi instead])
  757. fi
  758. # Are we given a TAR directory?
  759. if test "${with_ftd2xx_linux_tardir+set}" = set
  760. then
  761. AC_MSG_CHECKING([uninstalled ftd2xx distribution])
  762. # The .H file is simple..
  763. FTD2XX_H=$with_ftd2xx_linux_tardir/ftd2xx.h
  764. if test ! -f "${FTD2XX_H}"; then
  765. AC_MSG_ERROR([Option: --with-ftd2xx-linux-tardir appears wrong, cannot find: ${FTD2XX_H}])
  766. fi
  767. CFLAGS="$CFLAGS -I$with_ftd2xx_linux_tardir"
  768. if test $with_ftd2xx_lib = shared; then
  769. FTD2XX_LDFLAGS="-L$with_ftd2xx_linux_tardir"
  770. FTD2XX_LIB="-lftd2xx"
  771. else
  772. # Test #1 - v1.0.x
  773. case "$host_cpu" in
  774. i?86|x86_32)
  775. dir=build/i386;;
  776. amd64|x86_64)
  777. dir=build/x86_64;;
  778. *)
  779. dir=none;;
  780. esac
  781. if test -f "$with_ftd2xx_linux_tardir/$dir/libftd2xx.a"; then
  782. FTD2XX_LDFLAGS="-L$with_ftd2xx_linux_tardir/$dir"
  783. # Also needs -lrt
  784. FTD2XX_LIB="-lftd2xx -lrt"
  785. else
  786. # Test Number2.
  787. # Grr.. perhaps it exists as a version number?
  788. FTD2XX_LIB="$with_ftd2xx_linux_tardir/static_lib/libftd2xx.a.*.*.*"
  789. count=`ls ${FTD2XX_LIB} | wc -l`
  790. if test $count -gt 1 ; then
  791. AC_MSG_ERROR([Multiple libftd2xx.a files found in: $with_ftd2xx_linux_tardir/static_lib sorry cannot handle this yet])
  792. fi
  793. if test $count -ne 1 ; then
  794. AC_MSG_ERROR([Not found: $f, option: --with-ftd2xx-linux-tardir appears to be wrong])
  795. fi
  796. # Because the "-l" rules do not understand version numbers...
  797. # we will just stuff the absolute path onto the LIBS variable
  798. FTD2XX_LIB="`ls ${FTD2XX_LIB}` -lpthread"
  799. FTD2XX_LDFLAGS=""
  800. fi
  801. fi
  802. LDFLAGS="${LDFLAGS} ${FTD2XX_LDFLAGS}"
  803. LIBS="${LIBS} ${FTD2XX_LIB}"
  804. AC_MSG_RESULT([${FTD2XX_LDFLAGS} ${FTD2XX_LIB}])
  805. else
  806. AC_CHECK_HEADER([ftd2xx.h],[],[
  807. AC_MSG_ERROR([You seem to be missing the FTD2xx driver header file.])
  808. ])
  809. AC_SEARCH_LIBS([FT_GetLibraryVersion],[ftd2xx],,[
  810. AC_MSG_ERROR([You appear to be missing the FTD2xx driver library.])
  811. ],[])
  812. fi
  813. fi
  814. fi # linux
  815. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes; then
  816. # Before we go any further - make sure we can *BUILD* and *RUN*
  817. # a simple app with the "ftd2xx.lib" file - in what ever form we where given
  818. # We should be able to compile, link and run this test program now
  819. AC_MSG_CHECKING([whether ftd2xx library works])
  820. #
  821. # Save the LDFLAGS for later..
  822. LDFLAGS_SAVE=$LDFLAGS
  823. CFLAGS_SAVE=$CFLAGS
  824. _LDFLAGS=`eval echo $LDFLAGS`
  825. _CFLAGS=`eval echo $CFLAGS`
  826. LDFLAGS=$_LDFLAGS
  827. CFLAGS=$_CFLAGS
  828. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  829. #include "confdefs.h"
  830. #if IS_WIN32
  831. #include "windows.h"
  832. #endif
  833. #include <stdio.h>
  834. #include <ftd2xx.h>
  835. ]], [[
  836. DWORD x;
  837. FT_GetLibraryVersion( &x );
  838. ]])], [
  839. AC_MSG_RESULT([Success!])
  840. ], [
  841. AC_MSG_ERROR([Cannot build & run test program using ftd2xx.lib])
  842. ], [
  843. AC_MSG_RESULT([Skipping as we are cross-compiling])
  844. ])
  845. AC_MSG_CHECKING([for ftd2xx highspeed device support])
  846. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  847. #include "confdefs.h"
  848. #if IS_WIN32
  849. #include "windows.h"
  850. #endif
  851. #include <stdio.h>
  852. #include <ftd2xx.h>
  853. DWORD x = FT_DEVICE_4232H;
  854. ]], [])], [
  855. AC_DEFINE([BUILD_FT2232_HIGHSPEED], [1],
  856. [Support FT2232H/FT4232HS with FTD2XX or libftdi.])
  857. build_ft2232_highspeed=yes
  858. ], [
  859. build_ft2232_highspeed=no
  860. ])
  861. AC_MSG_RESULT([$build_ft2232_highspeed])
  862. if test $build_ft2232_highspeed = no; then
  863. AC_MSG_WARN([You need a newer FTD2XX driver (version 2.04.16 or later).])
  864. fi
  865. LDFLAGS=$LDFLAGS_SAVE
  866. CFLAGS=$CFLAGS_SAVE
  867. fi
  868. if test $build_ft2232_libftdi = yes ; then
  869. # We assume: the package is preinstalled in the proper place
  870. # these present as 2 libraries..
  871. LIBS="$LIBS -lftdi -lusb"
  872. #
  873. # Try to build a small program.
  874. AC_MSG_CHECKING([Build & Link with libftdi...])
  875. LDFLAGS_SAVE=$LDFLAGS
  876. CFLAGS_SAVE=$CFLAGS
  877. _LDFLAGS=`eval echo $LDFLAGS`
  878. _CFLAGS=`eval echo $CFLAGS`
  879. LDFLAGS=$_LDFLAGS
  880. CFLAGS=$_CFLAGS
  881. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  882. #include <stdio.h>
  883. #include <ftdi.h>
  884. ]], [[
  885. struct ftdi_context *p;
  886. p = ftdi_new();
  887. if( p != NULL ){
  888. return 0;
  889. } else {
  890. fprintf( stderr, "calling ftdi_new() failed\n");
  891. return 1;
  892. }
  893. ]])], [
  894. AC_MSG_RESULT([Success])
  895. ], [
  896. AC_MSG_ERROR([Cannot build & run test program using libftdi])
  897. ], [
  898. AC_MSG_RESULT([Skipping as we are cross-compiling])
  899. ])
  900. AC_MSG_CHECKING([for libftdi highspeed device support])
  901. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  902. #include <stdio.h>
  903. #include <ftdi.h>
  904. ]], [[
  905. enum ftdi_chip_type x = TYPE_2232H;
  906. ]])], [
  907. AC_DEFINE([BUILD_FT2232_HIGHSPEED], [1],
  908. [Support FT2232H/FT4232HS with FTD2XX or libftdi.])
  909. build_ft2232_highspeed=yes
  910. ], [
  911. build_ft2232_highspeed=no
  912. ])
  913. AC_MSG_RESULT([$build_ft2232_highspeed])
  914. if test $build_ft2232_highspeed = no; then
  915. AC_MSG_WARN([You need a newer libftdi version (0.16 or later).])
  916. fi
  917. # Restore the 'unexpanded ldflags'
  918. LDFLAGS=$LDFLAGS_SAVE
  919. CFLAGS=$CFLAGS_SAVE
  920. fi
  921. # check for usb.h when a driver will require it
  922. build_usb=no
  923. if test $build_vsllink = yes -o $build_usbprog = yes -o \
  924. $build_rlink = yes -o $build_ulink = yes -o $build_armjtagew = yes
  925. then
  926. build_usb=yes
  927. fi
  928. # Check for libusb1 ported drivers.
  929. build_usb_ng=no
  930. if test $build_jlink = yes -o $build_stlink = yes -o $build_osbdm = yes -o \
  931. $build_opendous = yes
  932. then
  933. build_usb_ng=yes
  934. fi
  935. # check for libusb library if necessary
  936. use_libusb0=no
  937. use_libusb1=no
  938. if test $build_usb = yes -o $build_usb_ng = yes; then
  939. if test $check_libusb0 = no -a $build_usb_ng = yes; then
  940. AC_CHECK_HEADER([libusb-1.0/libusb.h],
  941. [AC_DEFINE(HAVE_LIBUSB1, 1, [Define if you have libusb-1.0]) check_libusb0=no use_libusb1=yes ],
  942. [ check_libusb0=yes use_libusb1=no ])
  943. fi
  944. if test $check_libusb0 = yes -o $build_usb = yes; then
  945. AC_CHECK_HEADERS([usb.h], [use_libusb0=yes],
  946. [AC_MSG_ERROR([libusb or libusb-1.0 are required to build some OpenOCD driver(s)])])
  947. fi
  948. fi
  949. AM_CONDITIONAL([RELEASE], [test $build_release = yes])
  950. AM_CONDITIONAL([PARPORT], [test $build_parport = yes])
  951. AM_CONDITIONAL([DUMMY], [test $build_dummy = yes])
  952. AM_CONDITIONAL([GIVEIO], [test x$parport_use_giveio = xyes])
  953. AM_CONDITIONAL([EP93XX], [test $build_ep93xx = yes])
  954. AM_CONDITIONAL([ZY1000], [test $build_zy1000 = yes])
  955. AM_CONDITIONAL([ZY1000_MASTER], [test $build_zy1000_master = yes])
  956. AM_CONDITIONAL([IOUTIL], [test $build_ioutil = yes])
  957. AM_CONDITIONAL([AT91RM9200], [test $build_at91rm9200 = yes])
  958. AM_CONDITIONAL([BITBANG], [test $build_bitbang = yes])
  959. AM_CONDITIONAL([FT2232_LIBFTDI], [test $build_ft2232_libftdi = yes])
  960. AM_CONDITIONAL([FT2232_DRIVER], [test $build_ft2232_ftd2xx = yes -o $build_ft2232_libftdi = yes])
  961. AM_CONDITIONAL([USB_BLASTER_LIBFTDI], [test $build_usb_blaster_libftdi = yes])
  962. AM_CONDITIONAL([USB_BLASTER_DRIVER], [test $build_usb_blaster_ftd2xx = yes -o $build_usb_blaster_libftdi = yes])
  963. AM_CONDITIONAL([AMTJTAGACCEL], [test $build_amtjtagaccel = yes])
  964. AM_CONDITIONAL([GW16012], [test $build_gw16012 = yes])
  965. AM_CONDITIONAL([PRESTO_LIBFTDI], [test $build_presto_libftdi = yes])
  966. AM_CONDITIONAL([PRESTO_DRIVER], [test $build_presto_ftd2xx = yes -o $build_presto_libftdi = yes])
  967. AM_CONDITIONAL([USBPROG], [test $build_usbprog = yes])
  968. AM_CONDITIONAL([OOCD_TRACE], [test $build_oocd_trace = yes])
  969. AM_CONDITIONAL([JLINK], [test $build_jlink = yes])
  970. AM_CONDITIONAL([VSLLINK], [test $build_vsllink = yes])
  971. AM_CONDITIONAL([RLINK], [test $build_rlink = yes])
  972. AM_CONDITIONAL([ULINK], [test $build_ulink = yes])
  973. AM_CONDITIONAL([ARMJTAGEW], [test $build_armjtagew = yes])
  974. AM_CONDITIONAL([REMOTE_BITBANG], [test $build_remote_bitbang = yes])
  975. AM_CONDITIONAL([BUSPIRATE], [test $build_buspirate = yes])
  976. AM_CONDITIONAL([STLINK], [test $build_stlink = yes])
  977. AM_CONDITIONAL([OSBDM], [test $build_osbdm = yes])
  978. AM_CONDITIONAL([OPENDOUS], [test $build_opendous = yes])
  979. AM_CONDITIONAL([USB], [test $build_usb = yes])
  980. AM_CONDITIONAL([USB_NG], [test $build_usb_ng = yes])
  981. AM_CONDITIONAL([USE_LIBUSB0], [test $use_libusb0 = yes])
  982. AM_CONDITIONAL([USE_LIBUSB1], [test $use_libusb1 = yes])
  983. AM_CONDITIONAL([IS_CYGWIN], [test $is_cygwin = yes])
  984. AM_CONDITIONAL([IS_MINGW], [test $is_mingw = ye]s)
  985. AM_CONDITIONAL([IS_WIN32], [test $is_win32 = ye]s)
  986. AM_CONDITIONAL([IS_DARWIN], [test $is_darwin = ye]s)
  987. AM_CONDITIONAL([BITQ], [test $build_bitq = yes])
  988. AM_CONDITIONAL([MINIDRIVER], [test $build_minidriver = ye]s)
  989. AM_CONDITIONAL([MINIDRIVER_DUMMY], [test $build_minidriver_dummy = yes])
  990. AM_CONDITIONAL([INTERNAL_JIMTCL], [test $use_internal_jimtcl = yes])
  991. # Look for environ alternatives. Possibility #1: is environ in unistd.h or stdlib.h?
  992. AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])
  993. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  994. #define _GNU_SOURCE
  995. #include <unistd.h>
  996. #include <stdlib.h>
  997. ]], [[char **ep = environ;]]
  998. )], [
  999. AC_MSG_RESULT([yes])
  1000. has_environ=yes
  1001. ], [
  1002. AC_MSG_RESULT([no])
  1003. # Possibility #2: can environ be found in an available library?
  1004. AC_MSG_CHECKING([for extern environ])
  1005. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  1006. extern char **environ;
  1007. ]], [[char **ep = environ;]]
  1008. )], [
  1009. AC_DEFINE(NEED_ENVIRON_EXTERN, [1], [Must declare 'environ' to use it.])
  1010. has_environ=yes
  1011. ], [
  1012. has_environ=no
  1013. ])
  1014. AC_MSG_RESULT([${has_environ}])
  1015. ])
  1016. if test "${has_environ}" != "yes" ; then
  1017. AC_MSG_FAILURE([Could not find 'environ' in unistd.h or available libraries.])
  1018. fi
  1019. AC_DEFINE([_GNU_SOURCE],[1],[Use GNU C library extensions (e.g. stdndup).])
  1020. # set default gcc warnings
  1021. GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security -Wshadow"
  1022. if test "${gcc_wextra}" = yes; then
  1023. GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter"
  1024. GCC_WARNINGS="${GCC_WARNINGS} -Wbad-function-cast"
  1025. GCC_WARNINGS="${GCC_WARNINGS} -Wcast-align"
  1026. GCC_WARNINGS="${GCC_WARNINGS} -Wredundant-decls"
  1027. fi
  1028. if test "${gcc_werror}" = yes; then
  1029. GCC_WARNINGS="${GCC_WARNINGS} -Werror"
  1030. fi
  1031. # overide default gcc cflags
  1032. if test $gcc_warnings = yes; then
  1033. CFLAGS="$CFLAGS $GCC_WARNINGS"
  1034. fi
  1035. # Setup for compiling build tools
  1036. AC_MSG_CHECKING([for a C compiler for build tools])
  1037. if test $cross_compiling = yes; then
  1038. AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
  1039. CFLAGS_FOR_BUILD="-g -O2 $GCC_WARNINGS"
  1040. else
  1041. CC_FOR_BUILD=$CC
  1042. CFLAGS_FOR_BUILD=$CFLAGS
  1043. fi
  1044. AC_MSG_RESULT([$CC_FOR_BUILD])
  1045. AC_SUBST([CC_FOR_BUILD])
  1046. AC_SUBST([CFLAGS_FOR_BUILD])
  1047. AC_MSG_CHECKING([for suffix of executable build tools])
  1048. if test $cross_compiling = yes; then
  1049. cat >conftest.c <<\_______EOF
  1050. int main ()
  1051. {
  1052. exit (0);
  1053. }
  1054. _______EOF
  1055. for i in .exe ""; do
  1056. compile="$CC_FOR_BUILD conftest.c -o conftest$i"
  1057. if AC_TRY_EVAL(compile); then
  1058. if (./conftest) 2>&AC_FD_CC; then
  1059. EXEEXT_FOR_BUILD=$i
  1060. break
  1061. fi
  1062. fi
  1063. done
  1064. rm -f conftest*
  1065. if test "${EXEEXT_FOR_BUILD+set}" != set; then
  1066. AC_MSG_ERROR([Cannot determine suffix of executable build tools])
  1067. fi
  1068. else
  1069. EXEEXT_FOR_BUILD=$EXEEXT
  1070. fi
  1071. AC_MSG_RESULT([$EXEEXT_FOR_BUILD])
  1072. AC_SUBST([EXEEXT_FOR_BUILD])
  1073. AC_CONFIG_FILES([
  1074. Makefile
  1075. src/Makefile
  1076. src/helper/Makefile
  1077. src/jtag/Makefile
  1078. src/jtag/drivers/Makefile
  1079. src/jtag/stlink/Makefile
  1080. src/transport/Makefile
  1081. src/xsvf/Makefile
  1082. src/svf/Makefile
  1083. src/target/Makefile
  1084. src/rtos/Makefile
  1085. src/server/Makefile
  1086. src/flash/Makefile
  1087. src/flash/nor/Makefile
  1088. src/flash/nand/Makefile
  1089. src/pld/Makefile
  1090. doc/Makefile
  1091. ])
  1092. AC_OUTPUT