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.
 
 
 
 
 
 

1166 lines
35 KiB

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