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

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