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.in 21 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. AC_PREREQ(2.59)
  2. AC_INIT(configure.in)
  3. AC_CANONICAL_HOST
  4. AC_SEARCH_LIBS([ioperm], [ioperm])
  5. AC_SEARCH_LIBS([dlopen], [dl])
  6. AC_CHECK_HEADERS(jtag_minidriver.h)
  7. AC_CHECK_HEADERS(sys/param.h)
  8. AC_CHECK_HEADERS(sys/time.h)
  9. AC_CHECK_HEADERS(elf.h)
  10. AC_CHECK_HEADERS(strings.h)
  11. AC_HEADER_TIME
  12. AC_C_BIGENDIAN
  13. AC_CHECK_FUNCS(strndup)
  14. AC_CHECK_FUNCS(strnlen)
  15. AC_CHECK_FUNCS(gettimeofday)
  16. AC_CHECK_FUNCS(usleep)
  17. AC_CHECK_FUNCS(vasprintf)
  18. build_bitbang=no
  19. build_bitq=no
  20. is_cygwin=no
  21. is_mingw=no
  22. is_win32=no
  23. # We are not *ALWAYS* being installed in the standard place.
  24. # We may be installed in a "tool-build" specific location.
  25. # Normally with other packages - as part of a tool distro.
  26. # Thus - we should search that 'libdir' also.
  27. #
  28. # And - if we are being installed there - the odds are
  29. # The libraries unique to what we are are there too.
  30. #
  31. # Expand nd deal with NONE - just like configure will do later
  32. OCDprefix=$prefix
  33. OCDxprefix=$exec_prefix
  34. test x"$OCDprefix" = xNONE && OCDprefix=$ac_default_prefix
  35. # Let make expand exec_prefix.
  36. test x"$OCDxprefix" = xNONE && OCDxprefix="$OCDprefix"
  37. # what matters is the "exec-prefix"
  38. if test "$OCDxprefix" != "$ac_default_prefix"
  39. then
  40. # We are installing in a non-standard place
  41. # Nonstandard --prefix and/or --exec-prefix
  42. # We have an override of some sort.
  43. # use build specific install library dir
  44. LDFLAGS="$LDFLAGS -L$OCDxprefix/lib"
  45. # RPATH becomes an issue on Linux only
  46. if test $host_os = linux-gnu || $host_os = linux
  47. then
  48. LDFLAGS="$LDFLAGS -Wl,-rpath,$OCDxprefix/lib"
  49. fi
  50. # The "INCDIR" is also usable
  51. CFLAGS="$CFLAGS -I$includedir"
  52. fi
  53. AC_ARG_WITH(ftd2xx,
  54. AS_HELP_STRING([--with-ftd2xx=<PATH>],[This option has been removed.]),
  55. [
  56. # Option Given.
  57. cat << __EOF__
  58. The option: --with-ftd2xx=<PATH> has been removed replaced.
  59. On Linux, the new option is:
  60. --with-ftd2xx-linux-tardir=/path/to/files
  61. Where <path> is the path the the directory where the "tar.gz" file
  62. from FTDICHIP.COM was unpacked, for example:
  63. --with-ftd2xx-linux-tardir=/home/duane/libftd2xx-linux-tardir=/home/duane/libftd2xx0.4.16
  64. On Cygwin/MingW32, the new option is:
  65. --with-ftd2xx-win32-zipdir=/path/to/files
  66. Where <path> is the path to the directory where the "zip" file from
  67. FTDICHIP.COM was unpacked, for example:
  68. --with-ftd2xx-win32-zipdir=/home/duane/ftd2xx.cdm.files
  69. __EOF__
  70. AC_MSG_ERROR([Sorry Cannot continue])
  71. ],
  72. [
  73. # Option not given
  74. true
  75. ]
  76. )
  77. #========================================
  78. # FTD2XXX support comes in 3 forms.
  79. # (1) win32 - via a zip file
  80. # (2) linux - via a tar file
  81. # (3) linux/cygwin/mingw - via libftdi
  82. #
  83. # In case (1) and (2) we need to know where the package was unpacked.
  84. AC_ARG_WITH(ftd2xx-win32-zipdir,
  85. AS_HELP_STRING([--with-ftd2xx-win32-zipdir],[Where (CYGWIN/MINGW) the zip file from ftdichip.com was unpacked <default=search>]),
  86. [
  87. # option present
  88. if test -d $with_ftd2xx_win32_zipdir
  89. then
  90. with_ftd2xx_win32_zipdir=`cd $with_ftd2xx_win32_zipdir && pwd`
  91. AC_MSG_NOTICE([Using: ftdichip.com library: $with_ftd2xx_win32_zipdir])
  92. else
  93. AC_MSG_ERROR([Parameter to --with-ftd2xx-win32-zipdir is not a dir: $with_ftd2xx_win32_zipdir])
  94. fi
  95. ],
  96. [
  97. # not given
  98. true
  99. ]
  100. )
  101. AC_ARG_WITH(ftd2xx-linux-tardir,
  102. AS_HELP_STRING([--with-ftd2xx-linux-tardir], [Where (Linux/Unix) the tar file from ftdichip.com was unpacked <default=search>]),
  103. [
  104. # Option present
  105. if test $is_win32 = yes ; then
  106. AC_MSG_ERROR([The option: --with-ftd2xx-linux-tardir is only usable on linux])
  107. fi
  108. if test -d $with_ftd2xx_linux_tardir
  109. then
  110. with_ftd2xx_linux_tardir=`cd $with_ftd2xx_linux_tardir && pwd`
  111. AC_MSG_NOTICE([Using: ftdichip.com library: $with_ftd2xx_linux_tardir])
  112. else
  113. AC_MSG_ERROR([Parameter to --with-ftd2xx-linux-tardir is not a dir: $with_ftd2xx_linux_tardir])
  114. fi
  115. ],
  116. [
  117. # Not given
  118. true
  119. ]
  120. )
  121. AC_ARG_WITH(ftd2xx-lib,
  122. AS_HELP_STRING([--with-ftd2xx-lib], [Use static or shared ftd2xx libs on default static]),
  123. [
  124. case "$withval" in
  125. static)
  126. with_ftd2xx_lib=$withval
  127. ;;
  128. shared)
  129. with_ftd2xx_lib=$withval
  130. ;;
  131. *)
  132. AC_MSG_ERROR([Option: --with-ftd2xx-lib=static or --with-ftd2xx-lib=shared not, $withval])
  133. ;;
  134. esac
  135. ],
  136. [
  137. # Default is static - it is simpler :-(
  138. with_ftd2xx_lib=static
  139. ]
  140. )
  141. AC_ARG_ENABLE(gccwarnings,
  142. AS_HELP_STRING([--enable-gccwarnings], [Enable compiler warnings, default yes]),
  143. [gcc_warnings=$enableval], [gcc_warnings=yes])
  144. AC_ARG_ENABLE(parport,
  145. AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
  146. [build_parport=$enableval], [build_parport=no])
  147. AC_ARG_ENABLE(dummy,
  148. AS_HELP_STRING([--enable-dummy], [Enable building the dummy port driver]),
  149. [build_dummy=$enableval], [build_dummy=no])
  150. case "${host_cpu}" in
  151. i?86|x86*)
  152. AC_ARG_ENABLE(parport_ppdev,
  153. AS_HELP_STRING([--enable-parport_ppdev], [Enable use of ppdev (/dev/parportN) for parport]),
  154. [parport_use_ppdev=$enableval], [parport_use_ppdev=no])
  155. ;;
  156. *)
  157. parport_use_ppdev=yes
  158. ;;
  159. esac
  160. AC_ARG_ENABLE(ft2232_libftdi,
  161. AS_HELP_STRING([--enable-ft2232_libftdi], [Enable building support for FT2232 based devices using the libftdi driver, opensource alternate of FTD2XX]),
  162. [build_ft2232_libftdi=$enableval], [build_ft2232_libftdi=no])
  163. AC_ARG_ENABLE(ft2232_ftd2xx,
  164. AS_HELP_STRING([--enable-ft2232_ftd2xx], [Enable building support for FT2232 based devices using the FTD2XX driver from ftdichip.com]),
  165. [build_ft2232_ftd2xx=$enableval], [build_ft2232_ftd2xx=no])
  166. AC_ARG_ENABLE(amtjtagaccel,
  167. AS_HELP_STRING([--enable-amtjtagaccel], [Enable building the Amontec JTAG-Accelerator driver]),
  168. [build_amtjtagaccel=$enableval], [build_amtjtagaccel=no])
  169. AC_ARG_ENABLE(ecosboard,
  170. AS_HELP_STRING([--enable-ecosboard], [Enable building support for eCosBoard based JTAG debugger]),
  171. [build_ecosboard=$enableval], [build_ecosboard=no])
  172. AC_ARG_ENABLE(ioutil,
  173. AS_HELP_STRING([--enable-ioutil], [Enable ioutil functions - useful for standalone OpenOCD implementations]),
  174. [build_ioutil=$enableval], [build_ioutil=no])
  175. AC_ARG_ENABLE(httpd,
  176. AS_HELP_STRING([--enable-httpd], [Enable builtin httpd server - useful for standalone OpenOCD implementations]),
  177. [build_httpd=$enableval], [build_httpd=no])
  178. case "${host_cpu}" in
  179. arm*)
  180. AC_ARG_ENABLE(ep93xx,
  181. AS_HELP_STRING([--enable-ep93xx], [Enable building support for EP93xx based SBCs]),
  182. [build_ep93xx=$enableval], [build_ep93xx=no])
  183. AC_ARG_ENABLE(at91rm9200,
  184. AS_HELP_STRING([--enable-at91rm9200], [Enable building support for AT91RM9200 based SBCs]),
  185. [build_at91rm9200=$enableval], [build_at91rm9200=no])
  186. ;;
  187. *)
  188. build_ep93xx=no
  189. build_at91rm9200=no
  190. ;;
  191. esac
  192. AC_ARG_ENABLE(gw16012,
  193. AS_HELP_STRING([--enable-gw16012], [Enable building support for the Gateworks GW16012 JTAG Programmer]),
  194. [build_gw16012=$enableval], [build_gw16012=no])
  195. AC_ARG_ENABLE(presto_libftdi,
  196. AS_HELP_STRING([--enable-presto_libftdi], [Enable building support for ASIX Presto Programmer using the libftdi driver]),
  197. [build_presto_libftdi=$enableval], [build_presto_libftdi=no])
  198. AC_ARG_ENABLE(presto_ftd2xx,
  199. AS_HELP_STRING([--enable-presto_ftd2xx], [Enable building support for ASIX Presto Programmer using the FTD2XX driver]),
  200. [build_presto_ftd2xx=$enableval], [build_presto_ftd2xx=no])
  201. AC_ARG_ENABLE(usbprog,
  202. AS_HELP_STRING([--enable-usbprog], [Enable building support for the usbprog JTAG Programmer]),
  203. [build_usbprog=$enableval], [build_usbprog=no])
  204. AC_ARG_ENABLE(oocd_trace,
  205. AS_HELP_STRING([--enable-oocd_trace], [Enable building support for the OpenOCD+trace ETM capture device]),
  206. [build_oocd_trace=$enableval], [build_oocd_trace=no])
  207. AC_ARG_ENABLE(jlink,
  208. AS_HELP_STRING([--enable-jlink], [Enable building support for the Segger J-Link JTAG Programmer]),
  209. [build_jlink=$enableval], [build_jlink=no])
  210. AC_ARG_ENABLE(vsllink,
  211. AS_HELP_STRING([--enable-vsllink], [Enable building support for the Versaloon-Link JTAG Programmer]),
  212. [build_vsllink=$enableval], [build_vsllink=no])
  213. AC_ARG_ENABLE(rlink,
  214. AS_HELP_STRING([--enable-rlink], [Enable building support for the Raisonance RLink JTAG Programmer]),
  215. [build_rlink=$enableval], [build_rlink=no])
  216. case $host in
  217. *-cygwin*)
  218. is_win32=yes
  219. AC_ARG_ENABLE(parport_giveio,
  220. AS_HELP_STRING([--enable-parport_giveio], [Enable use of giveio for parport instead of ioperm]),
  221. [parport_use_giveio=$enableval], [parport_use_giveio=no])
  222. AC_COMPILE_IFELSE(AC_LANG_PROGRAM([],[return __MINGW32__;]),[is_mingw=yes],[is_mingw=no])
  223. if test $is_mingw = yes; then
  224. AC_DEFINE(IS_MINGW, 1, [1 if building for MinGW.])
  225. parport_use_giveio=yes
  226. is_cygwin=no
  227. else
  228. is_cygwin=yes
  229. AC_DEFINE(IS_CYGWIN, 1, [1 if building for Cygwin.])
  230. fi
  231. AC_DEFINE(IS_WIN32, 1, [1 if building for Win32.])
  232. ;;
  233. *-mingw*)
  234. is_mingw=yes
  235. is_win32=yes
  236. parport_use_giveio=yes
  237. AC_DEFINE(IS_MINGW, 1, [1 if building for MinGW.])
  238. AC_DEFINE(IS_WIN32, 1, [1 if building for Win32.])
  239. ;;
  240. *)
  241. parport_use_giveio=no
  242. AC_DEFINE(IS_CYGWIN, 0, [0 if not building for Cygwin.])
  243. AC_DEFINE(IS_WIN32, 0, [0 if not building for Win32.])
  244. ;;
  245. esac
  246. if test $build_parport = yes; then
  247. build_bitbang=yes
  248. AC_DEFINE(BUILD_PARPORT, 1, [1 if you want parport.])
  249. else
  250. AC_DEFINE(BUILD_PARPORT, 0, [0 if you don't want parport.])
  251. fi
  252. if test $build_dummy = yes; then
  253. build_bitbang=yes
  254. AC_DEFINE(BUILD_DUMMY, 1, [1 if you want dummy driver.])
  255. else
  256. AC_DEFINE(BUILD_DUMMY, 0, [0 if you don't want dummy driver.])
  257. fi
  258. if test $build_ep93xx = yes; then
  259. build_bitbang=yes
  260. AC_DEFINE(BUILD_EP93XX, 1, [1 if you want ep93xx.])
  261. else
  262. AC_DEFINE(BUILD_EP93XX, 0, [0 if you don't want ep93xx.])
  263. fi
  264. if test $build_ecosboard = yes; then
  265. build_bitbang=yes
  266. AC_DEFINE(BUILD_ECOSBOARD, 1, [1 if you want eCosBoard.])
  267. else
  268. AC_DEFINE(BUILD_ECOSBOARD, 0, [0 if you don't want eCosBoard.])
  269. fi
  270. if test $build_ioutil = yes; then
  271. AC_DEFINE(BUILD_IOUTIL, 1, [1 if you want ioutils.])
  272. else
  273. AC_DEFINE(BUILD_IOUTIL, 0, [0 if you don't want ioutils.])
  274. fi
  275. if test $build_httpd = yes; then
  276. AC_DEFINE(BUILD_HTTPD, 1, [1 if you want httpd.])
  277. else
  278. AC_DEFINE(BUILD_HTTPD, 0, [0 if you don't want httpd.])
  279. fi
  280. if test $build_at91rm9200 = yes; then
  281. build_bitbang=yes
  282. AC_DEFINE(BUILD_AT91RM9200, 1, [1 if you want at91rm9200.])
  283. else
  284. AC_DEFINE(BUILD_AT91RM9200, 0, [0 if you don't want at91rm9200.])
  285. fi
  286. if test $parport_use_ppdev = yes; then
  287. AC_DEFINE(PARPORT_USE_PPDEV, 1, [1 if you want parport to use ppdev.])
  288. else
  289. AC_DEFINE(PARPORT_USE_PPDEV, 0, [0 if you don't want parport to use ppdev.])
  290. fi
  291. if test $parport_use_giveio = yes; then
  292. AC_DEFINE(PARPORT_USE_GIVEIO, 1, [1 if you want parport to use giveio.])
  293. else
  294. AC_DEFINE(PARPORT_USE_GIVEIO, 0, [0 if you don't want parport to use giveio.])
  295. fi
  296. if test $build_bitbang = yes; then
  297. AC_DEFINE(BUILD_BITBANG, 1, [1 if you want a bitbang interface.])
  298. else
  299. AC_DEFINE(BUILD_BITBANG, 0, [0 if you don't want a bitbang interface.])
  300. fi
  301. if test $build_ft2232_libftdi = yes; then
  302. AC_DEFINE(BUILD_FT2232_LIBFTDI, 1, [1 if you want libftdi ft2232.])
  303. else
  304. AC_DEFINE(BUILD_FT2232_LIBFTDI, 0, [0 if you don't want libftdi ft2232.])
  305. fi
  306. if test $build_ft2232_ftd2xx = yes; then
  307. AC_DEFINE(BUILD_FT2232_FTD2XX, 1, [1 if you want ftd2xx ft2232.])
  308. else
  309. AC_DEFINE(BUILD_FT2232_FTD2XX, 0, [0 if you don't want ftd2xx ft2232.])
  310. fi
  311. if test $build_amtjtagaccel = yes; then
  312. AC_DEFINE(BUILD_AMTJTAGACCEL, 1, [1 if you want the Amontec JTAG-Accelerator driver.])
  313. else
  314. AC_DEFINE(BUILD_AMTJTAGACCEL, 0, [0 if you don't want the Amontec JTAG-Accelerator driver.])
  315. fi
  316. if test $build_gw16012 = yes; then
  317. AC_DEFINE(BUILD_GW16012, 1, [1 if you want the Gateworks GW16012 driver.])
  318. else
  319. AC_DEFINE(BUILD_GW16012, 0, [0 if you don't want the Gateworks GW16012 driver.])
  320. fi
  321. if test $build_presto_libftdi = yes; then
  322. build_bitq=yes
  323. AC_DEFINE(BUILD_PRESTO_LIBFTDI, 1, [1 if you want the ASIX PRESTO driver using libftdi.])
  324. else
  325. AC_DEFINE(BUILD_PRESTO_LIBFTDI, 0, [0 if you don't want the ASIX PRESTO driver using libftdi.])
  326. fi
  327. if test $build_presto_ftd2xx = yes; then
  328. build_bitq=yes
  329. AC_DEFINE(BUILD_PRESTO_FTD2XX, 1, [1 if you want the ASIX PRESTO driver using FTD2XX.])
  330. else
  331. AC_DEFINE(BUILD_PRESTO_FTD2XX, 0, [0 if you don't want the ASIX PRESTO driver using FTD2XX.])
  332. fi
  333. if test $build_bitq = yes; then
  334. AC_DEFINE(BUILD_BITQ, 1, [1 if you want a bitq interface.])
  335. else
  336. AC_DEFINE(BUILD_BITQ, 0, [0 if you don't want a bitq interface.])
  337. fi
  338. if test $build_usbprog = yes; then
  339. AC_DEFINE(BUILD_USBPROG, 1, [1 if you want the usbprog JTAG driver.])
  340. else
  341. AC_DEFINE(BUILD_USBPROG, 0, [0 if you don't want the usbprog JTAG driver.])
  342. fi
  343. if test $build_oocd_trace = yes; then
  344. AC_DEFINE(BUILD_OOCD_TRACE, 1, [1 if you want the OpenOCD+trace ETM capture driver.])
  345. else
  346. AC_DEFINE(BUILD_OOCD_TRACE, 0, [0 if you don't want the OpenOCD+trace ETM capture driver.])
  347. fi
  348. if test $build_jlink = yes; then
  349. AC_DEFINE(BUILD_JLINK, 1, [1 if you want the J-Link JTAG driver.])
  350. else
  351. AC_DEFINE(BUILD_JLINK, 0, [0 if you don't want the J-Link JTAG driver.])
  352. fi
  353. if test $build_vsllink = yes; then
  354. AC_DEFINE(BUILD_VSLLINK, 1, [1 if you want the Versaloon-Link JTAG driver.])
  355. else
  356. AC_DEFINE(BUILD_VSLLINK, 0, [0 if you don't want the Versaloon-Link JTAG driver.])
  357. fi
  358. if test $build_rlink = yes; then
  359. AC_DEFINE(BUILD_RLINK, 1, [1 if you want the RLink JTAG driver.])
  360. else
  361. AC_DEFINE(BUILD_RLINK, 0, [0 if you don't want the RLink JTAG driver.])
  362. fi
  363. #-- Deal with MingW/Cygwin FTD2XX issues
  364. if test $is_win32 = yes; then
  365. if test "${with_ftd2xx_linux_tardir+set}" = set
  366. then
  367. AC_MSG_ERROR([The option: with_ftd2xx_linux_tardir is for LINUX only.])
  368. fi
  369. if test $build_ft2232_ftd2xx = yes ; then
  370. AC_MSG_CHECKING([for ftd2xx.lib exists (win32)])
  371. # if we are given a zipdir...
  372. if test "${with_ftd2xx_win32_zipdir+set}" = set
  373. then
  374. # Set the CFLAGS for "ftd2xx.h"
  375. f=$with_ftd2xx_win32_zipdir/ftd2xx.h
  376. if test ! -f $f ; then
  377. AC_MSG_ERROR([File: $f cannot be found])
  378. fi
  379. CFLAGS="$CFLAGS -I$with_ftd2xx_win32_zipdir"
  380. # And calculate the LDFLAGS for the machine
  381. case "$host_cpu" in
  382. i?86|x86_*)
  383. LDFLAGS="$LFLAGS -L$with_ftd2xx_win32_zipdir/i386"
  384. LIBS="$LIBS -lftd2xx"
  385. f=$with_ftd2xx_win32_zipdir/i386/ftd2xx.lib
  386. ;;
  387. amd64)
  388. LDFLAGS="$LFLAGS -L$with_ftd2xx_win32_zipdir/amd64"
  389. LIBS="$LIBS -lftd2xx"
  390. f=$with_ftd2xx_win32_zipdir/amd64/ftd2xx.lib
  391. ;;
  392. *)
  393. AC_MSG_ERROR([Unknown Win32 host cpu: $host_cpu])
  394. ;;
  395. esac
  396. if test ! -f $f ; then
  397. AC_MSG_ERROR([Library: $f not found])
  398. fi
  399. else
  400. LIBS="$LIBS -lftd2xx"
  401. AC_MSG_WARN([ASSUMPTION: The (win32) FTDICHIP.COM files: ftd2xx.h and ftd2xx.lib are in a proper place])
  402. fi
  403. fi
  404. fi
  405. if test $is_win32 = no; then
  406. if test "${with_ftd2xx_win32_zipdir+set}" = set
  407. then
  408. AC_MSG_ERROR([The option: --with-ftd2xx-win32-zipdir is for win32 only])
  409. fi
  410. if test $build_ft2232_ftd2xx = yes ; then
  411. AC_MSG_CHECKING([for libftd2xx.a (linux)])
  412. # Must be linux -
  413. # Cause FTDICHIP does not supply a MAC-OS version
  414. if test $host_os != linux-gnu && $host_os != linux ; then
  415. AC_MSG_ERROR([The (linux) ftd2xx library from FTDICHIP.com is linux only. Try --enable-ft2232-libftdi instead])
  416. fi
  417. # Are we given a TAR directory?
  418. if test "${with_ftd2xx_linux_tardir+set}" = set
  419. then
  420. # The .H file is simple..
  421. f=$with_ftd2xx_linux_tardir/ftd2xx.h
  422. if test ! -f $f ; then
  423. AC_MSG_ERROR([Option: --with-ftd2xx-linux-tardir appears wrong, cannot find: $f])
  424. fi
  425. CFLAGS="$CFLAGS -I$with_ftd2xx_linux_tardir"
  426. if test $with_ftd2xx_lib = shared
  427. then
  428. LDFLAGS="$LDFLAGS -L$with_ftd2xx_linux_tardir"
  429. LIBS="$LIBS -lftd2xx"
  430. AC_MSG_RESULT([ Assuming: -L$with_ftd2xx_linux_tardir -lftd2xx])
  431. else
  432. # Test #1 - Future proof - if/when ftdichip fixes their distro.
  433. # Try it with the simple ".a" suffix.
  434. f=$with_ftd2xx_linux_tardir/static_lib/libftd2xx.a
  435. if test -f $f ; then
  436. # Yea we are done
  437. LDFLAGS="$LDFLAGS -L$with_ftd2xx_linux_tardir/static_lib"
  438. LIBS="$LIBS -lftd2xx"
  439. else
  440. # Test Number2.
  441. # Grr.. perhaps it exists as a version number?
  442. f="$with_ftd2xx_linux_tardir/static_lib/libftd2xx.a.*.*.*"
  443. count=`ls $f | wc -l`
  444. if test $count -gt 1 ; then
  445. AC_MSG_ERROR([Multiple libftd2xx.a files found in: $with_ftd2xx_linux_tardir/static_lib sorry cannot handle this yet])
  446. fi
  447. if test $count -ne 1 ; then
  448. AC_MSG_ERROR([Not found: $f, option: --with-ftd2xx-linux-tardir appears to be wrong])
  449. fi
  450. # Because the "-l" rules do not understand version numbers...
  451. # we will just stuff the absolute path onto the LIBS variable
  452. f=`ls $f`
  453. #
  454. LIBS="$LIBS $f -lpthread"
  455. # No need to bother with LDFLAGS...
  456. fi
  457. AC_MSG_RESULT([Found: $f])
  458. fi
  459. else
  460. LIBS="$LIBS -lftd2xx"
  461. AC_MSG_RESULT([Assumed: installed])
  462. AC_MSG_WARN([The (linux) FTDICHIP.COM files ftd2xx.h and libftd2xx.so are assumed to be in a proper place])
  463. fi
  464. fi
  465. fi
  466. if test $build_ft2232_ftd2xx = yes; then
  467. # Before we go any further - make sure we can *BUILD* and *RUN*
  468. # a simple app with the "ftd2xx.lib" file - in what ever form we where given
  469. # We should be able to compile, link and run this test program now
  470. AC_MSG_CHECKING([Test: Build & Link with ftd2xx])
  471. #
  472. # Save the LDFLAGS for later..
  473. LDFLAGS_SAVE=$LDFLAGS
  474. CFLAGS_SAVE=$CFLAGS
  475. _LDFLAGS=`eval echo $LDFLAGS`
  476. _CFLAGS=`eval echo $CFLAGS`
  477. LDFLAGS=$_LDFLAGS
  478. CFLAGS=$_CFLAGS
  479. AC_RUN_IFELSE(
  480. [
  481. #include "confdefs.h"
  482. #if IS_WIN32
  483. #include "windows.h"
  484. #endif
  485. #include <stdio.h>
  486. #include <ftd2xx.h>
  487. int
  488. main( int argc, char **argv )
  489. {
  490. DWORD x;
  491. FT_GetLibraryVersion( &x );
  492. return 0;
  493. }
  494. ], [ AC_MSG_RESULT([Success!])] , [ AC_MSG_ERROR([Cannot build & run test program using ftd2xx.lib]) ] )
  495. LDFLAGS=$LDFLAGS_SAVE
  496. CFLAGS=$CFLAGS_SAVE
  497. fi
  498. if test $build_ft2232_libftdi = yes ; then
  499. # We assume: the package is preinstalled in the proper place
  500. # these present as 2 libraries..
  501. LIBS="$LIBS -lftdi -lusb"
  502. #
  503. # Try to build a small program.
  504. AC_MSG_CHECKING([Build & Link with libftdi...])
  505. LDFLAGS_SAVE=$LDFLAGS
  506. CFLAGS_SAVE=$CFLAGS
  507. _LDFLAGS=`eval echo $LDFLAGS`
  508. _CFLAGS=`eval echo $CFLAGS`
  509. LDFLAGS=$_LDFLAGS
  510. CFLAGS=$_CFLAGS
  511. AC_RUN_IFELSE(
  512. [
  513. #include <stdio.h>
  514. #include <ftdi.h>
  515. int
  516. main( int argc, char **argv )
  517. {
  518. struct ftdi_context *p;
  519. p = ftdi_new();
  520. if( p != NULL ){
  521. return 0;
  522. } else {
  523. fprintf( stderr, "calling ftdi_new() failed\n");
  524. return 1;
  525. }
  526. }
  527. ]
  528. ,
  529. [ AC_MSG_RESULT([Success]) ]
  530. ,
  531. [ AC_MSG_ERROR([Cannot build & run test program using libftdi]) ] )
  532. # Restore the 'unexpanded ldflags'
  533. LDFLAGS=$LDFLAGS_SAVE
  534. CFLAGS=$CFLAGS_SAVE
  535. fi
  536. AM_CONFIG_HEADER(config.h)
  537. AM_INIT_AUTOMAKE(openocd, 1.0)
  538. AM_CONDITIONAL(PARPORT, test $build_parport = yes)
  539. AM_CONDITIONAL(DUMMY, test $build_dummy = yes)
  540. AM_CONDITIONAL(GIVEIO, test $parport_use_giveio = yes)
  541. AM_CONDITIONAL(EP93XX, test $build_ep93xx = yes)
  542. AM_CONDITIONAL(ECOSBOARD, test $build_ecosboard = yes)
  543. AM_CONDITIONAL(IOUTIL, test $build_ioutil = yes)
  544. AM_CONDITIONAL(HTTPD, test $build_httpd = yes)
  545. AM_CONDITIONAL(AT91RM9200, test $build_at91rm9200 = yes)
  546. AM_CONDITIONAL(BITBANG, test $build_bitbang = yes)
  547. AM_CONDITIONAL(FT2232_LIBFTDI, test $build_ft2232_libftdi = yes)
  548. AM_CONDITIONAL(FT2232_FTD2XX, test $build_ft2232_ftd2xx = yes)
  549. AM_CONDITIONAL(AMTJTAGACCEL, test $build_amtjtagaccel = yes)
  550. AM_CONDITIONAL(GW16012, test $build_gw16012 = yes)
  551. AM_CONDITIONAL(PRESTO_LIBFTDI, test $build_presto_libftdi = yes)
  552. AM_CONDITIONAL(PRESTO_FTD2XX, test $build_presto_ftd2xx = yes)
  553. AM_CONDITIONAL(USBPROG, test $build_usbprog = yes)
  554. AM_CONDITIONAL(OOCD_TRACE, test $build_oocd_trace = yes)
  555. AM_CONDITIONAL(JLINK, test $build_jlink = yes)
  556. AM_CONDITIONAL(VSLLINK, test $build_vsllink = yes)
  557. AM_CONDITIONAL(RLINK, test $build_rlink = yes)
  558. AM_CONDITIONAL(IS_CYGWIN, test $is_cygwin = yes)
  559. AM_CONDITIONAL(IS_MINGW, test $is_mingw = yes)
  560. AM_CONDITIONAL(IS_WIN32, test $is_win32 = yes)
  561. AM_CONDITIONAL(BITQ, test $build_bitq = yes)
  562. AC_LANG_C
  563. AC_PROG_CC
  564. AC_PROG_RANLIB
  565. # set default gcc warnings
  566. GCC_WARNINGS="-Wall -Wstrict-prototypes"
  567. # overide default gcc cflags
  568. if test $gcc_warnings = yes; then
  569. CFLAGS="$CFLAGS $GCC_WARNINGS"
  570. fi
  571. # Setup for compiling build tools
  572. AC_MSG_CHECKING([for a C compiler for build tools])
  573. if test $cross_compiling = yes; then
  574. AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
  575. CFLAGS_FOR_BUILD="-g -O2 $GCC_WARNINGS"
  576. else
  577. CC_FOR_BUILD=$CC
  578. CFLAGS_FOR_BUILD=$CFLAGS
  579. fi
  580. AC_MSG_RESULT([$CC_FOR_BUILD])
  581. AC_SUBST(CC_FOR_BUILD)
  582. AC_SUBST(CFLAGS_FOR_BUILD)
  583. AC_MSG_CHECKING([for suffix of executable build tools])
  584. if test $cross_compiling = yes; then
  585. cat >conftest.c <<\_______EOF
  586. int main ()
  587. {
  588. exit (0);
  589. }
  590. _______EOF
  591. for i in .exe ""; do
  592. compile="$CC_FOR_BUILD conftest.c -o conftest$i"
  593. if AC_TRY_EVAL(compile); then
  594. if (./conftest) 2>&AC_FD_CC; then
  595. EXEEXT_FOR_BUILD=$i
  596. break
  597. fi
  598. fi
  599. done
  600. rm -f conftest*
  601. if test "${EXEEXT_FOR_BUILD+set}" != set; then
  602. AC_MSG_ERROR([Cannot determine suffix of executable build tools])
  603. fi
  604. else
  605. EXEEXT_FOR_BUILD=$EXEEXT
  606. fi
  607. AC_MSG_RESULT([$EXEEXT_FOR_BUILD])
  608. AC_SUBST(EXEEXT_FOR_BUILD)
  609. #AC_SUBST(WITH_FTD2XX, $with_ftd2xx)
  610. AC_OUTPUT(Makefile src/Makefile src/helper/Makefile src/jtag/Makefile src/xsvf/Makefile src/target/Makefile src/server/Makefile src/flash/Makefile src/pld/Makefile doc/Makefile)