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.
 
 
 
 
 
 

1155 lines
35 KiB

  1. AC_PREREQ(2.60)
  2. AC_INIT([openocd], [0.4.0-rc1-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(minidriver_dummy,
  401. AS_HELP_STRING([--enable-minidriver-dummy], [Enable the dummy minidriver.]),
  402. [build_minidriver_dummy=$enableval], [build_minidriver_dummy=no])
  403. build_minidriver=no
  404. AC_MSG_CHECKING([whether to enable ZY1000 minidriver])
  405. if test $build_zy1000 = yes; then
  406. if test $build_minidriver = yes; then
  407. AC_MSG_ERROR([Multiple minidriver options have been enabled.])
  408. fi
  409. AC_DEFINE(HAVE_JTAG_MINIDRIVER_H, 1,
  410. [Define to 1 if you have the <jtag_minidriver.h> header file.])
  411. build_minidriver=yes
  412. fi
  413. AC_MSG_RESULT($build_zy1000)
  414. AC_MSG_CHECKING([whether to enable dummy minidriver])
  415. if test $build_minidriver_dummy = yes; then
  416. if test $build_minidriver = yes; then
  417. AC_MSG_ERROR([Multiple minidriver options have been enabled.])
  418. fi
  419. build_minidriver=yes
  420. AC_DEFINE(BUILD_MINIDRIVER_DUMMY, 1, [Use the dummy minidriver.])
  421. AC_DEFINE(HAVE_JTAG_MINIDRIVER_H, 1,
  422. [Define to 1 if you have the <jtag_minidriver.h> header file.])
  423. fi
  424. AC_MSG_RESULT($build_minidriver_dummy)
  425. AC_MSG_CHECKING([whether standard drivers can be built])
  426. if test "$build_minidriver" = yes; then
  427. AC_MSG_RESULT([no])
  428. AC_MSG_WARN([Using the minidriver disables all other drivers.])
  429. sleep 2
  430. else
  431. AC_MSG_RESULT([yes])
  432. fi
  433. case "${host_cpu}" in
  434. i?86|x86*)
  435. ;;
  436. *)
  437. if test x$parport_use_ppdev = xno; then
  438. AC_MSG_WARN([--disable-parport-ppdev is not supported by the host CPU])
  439. fi
  440. parport_use_ppdev=yes
  441. ;;
  442. esac
  443. case $host in
  444. *-cygwin*)
  445. is_win32=yes
  446. parport_use_ppdev=no
  447. AC_COMPILE_IFELSE(AC_LANG_PROGRAM([],[return __MINGW32__;]),
  448. [is_mingw=yes],[is_mingw=no])
  449. if test $is_mingw = yes; then
  450. AC_DEFINE(IS_MINGW, 1, [1 if building for MinGW.])
  451. if test x$parport_use_giveio = xno; then
  452. AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
  453. fi
  454. parport_use_giveio=yes
  455. is_cygwin=no
  456. else
  457. is_cygwin=yes
  458. AC_DEFINE(IS_CYGWIN, 1, [1 if building for Cygwin.])
  459. # sys/io.h needed under cygwin for parport access
  460. if test $build_parport = yes; then
  461. AC_CHECK_HEADERS(sys/io.h,[],AC_MSG_ERROR([Please install the cygwin ioperm package]))
  462. fi
  463. fi
  464. AC_DEFINE(IS_WIN32, 1, [1 if building for Win32.])
  465. AC_DEFINE(IS_DARWIN, 0, [0 if not building for Darwin.])
  466. ;;
  467. *-mingw*)
  468. is_mingw=yes
  469. is_win32=yes
  470. parport_use_ppdev=no
  471. if test x$parport_use_giveio = xno; then
  472. AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
  473. fi
  474. parport_use_giveio=yes
  475. CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO"
  476. AC_DEFINE(IS_MINGW, 1, [1 if building for MinGW.])
  477. AC_DEFINE(IS_WIN32, 1, [1 if building for Win32.])
  478. AC_DEFINE(IS_DARWIN, 0, [0 if not building for Darwin.])
  479. ;;
  480. *darwin*)
  481. is_darwin=yes
  482. if test x$parport_use_giveio = xyes; then
  483. AC_MSG_WARN([--enable-parport-giveio cannot be used by Darwin hosts])
  484. fi
  485. parport_use_giveio=no
  486. AC_DEFINE(IS_CYGWIN, 0, [0 if not building for Cygwin.])
  487. AC_DEFINE(IS_WIN32, 0, [0 if not building for Win32.])
  488. AC_DEFINE(IS_DARWIN, 1, [1 if building for Darwin.])
  489. ;;
  490. *)
  491. if test x$parport_use_giveio = xyes; then
  492. AC_MSG_WARN([--enable-parport-giveio cannot be used by ]$host[ hosts])
  493. fi
  494. parport_use_giveio=no
  495. AC_DEFINE(IS_CYGWIN, 0, [0 if not building for Cygwin.])
  496. AC_DEFINE(IS_WIN32, 0, [0 if not building for Win32.])
  497. AC_DEFINE(IS_DARWIN, 0, [0 if not building for Darwin.])
  498. ;;
  499. esac
  500. if test $build_parport = yes; then
  501. build_bitbang=yes
  502. AC_DEFINE(BUILD_PARPORT, 1, [1 if you want parport.])
  503. else
  504. AC_DEFINE(BUILD_PARPORT, 0, [0 if you don't want parport.])
  505. fi
  506. if test $build_dummy = yes; then
  507. build_bitbang=yes
  508. AC_DEFINE(BUILD_DUMMY, 1, [1 if you want dummy driver.])
  509. else
  510. AC_DEFINE(BUILD_DUMMY, 0, [0 if you don't want dummy driver.])
  511. fi
  512. if test $build_ep93xx = yes; then
  513. build_bitbang=yes
  514. AC_DEFINE(BUILD_EP93XX, 1, [1 if you want ep93xx.])
  515. else
  516. AC_DEFINE(BUILD_EP93XX, 0, [0 if you don't want ep93xx.])
  517. fi
  518. if test $build_ecosboard = yes; then
  519. AC_DEFINE(BUILD_ECOSBOARD, 1, [1 if you want eCosBoard.])
  520. else
  521. AC_DEFINE(BUILD_ECOSBOARD, 0, [0 if you don't want eCosBoard.])
  522. fi
  523. if test $build_zy1000 = yes; then
  524. AC_DEFINE(BUILD_ZY1000, 1, [1 if you want ZY1000.])
  525. else
  526. AC_DEFINE(BUILD_ZY1000, 0, [0 if you don't want ZY1000.])
  527. fi
  528. if test $build_at91rm9200 = yes; then
  529. build_bitbang=yes
  530. AC_DEFINE(BUILD_AT91RM9200, 1, [1 if you want at91rm9200.])
  531. else
  532. AC_DEFINE(BUILD_AT91RM9200, 0, [0 if you don't want at91rm9200.])
  533. fi
  534. if test x$parport_use_ppdev = xyes; then
  535. AC_DEFINE(PARPORT_USE_PPDEV, 1, [1 if you want parport to use ppdev.])
  536. else
  537. AC_DEFINE(PARPORT_USE_PPDEV, 0, [0 if you don't want parport to use ppdev.])
  538. fi
  539. if test x$parport_use_giveio = xyes; then
  540. AC_DEFINE(PARPORT_USE_GIVEIO, 1, [1 if you want parport to use giveio.])
  541. else
  542. AC_DEFINE(PARPORT_USE_GIVEIO, 0, [0 if you don't want parport to use giveio.])
  543. fi
  544. if test $build_bitbang = yes; then
  545. AC_DEFINE(BUILD_BITBANG, 1, [1 if you want a bitbang interface.])
  546. else
  547. AC_DEFINE(BUILD_BITBANG, 0, [0 if you don't want a bitbang interface.])
  548. fi
  549. if test $build_ft2232_libftdi = yes; then
  550. AC_DEFINE(BUILD_FT2232_LIBFTDI, 1, [1 if you want libftdi ft2232.])
  551. else
  552. AC_DEFINE(BUILD_FT2232_LIBFTDI, 0, [0 if you don't want libftdi ft2232.])
  553. fi
  554. if test $build_ft2232_ftd2xx = yes; then
  555. AC_DEFINE(BUILD_FT2232_FTD2XX, 1, [1 if you want ftd2xx ft2232.])
  556. else
  557. AC_DEFINE(BUILD_FT2232_FTD2XX, 0, [0 if you don't want ftd2xx ft2232.])
  558. fi
  559. if test $build_usb_blaster_libftdi = yes; then
  560. build_bitbang=yes
  561. AC_DEFINE(BUILD_USB_BLASTER_LIBFTDI, 1, [1 if you want libftdi usb_blaster.])
  562. else
  563. AC_DEFINE(BUILD_USB_BLASTER_LIBFTDI, 0, [0 if you don't want libftdi usb_blaster.])
  564. fi
  565. if test $build_usb_blaster_ftd2xx = yes; then
  566. build_bitbang=yes
  567. AC_DEFINE(BUILD_USB_BLASTER_FTD2XX, 1, [1 if you want ftd2xx usb_blaster.])
  568. else
  569. AC_DEFINE(BUILD_USB_BLASTER_FTD2XX, 0, [0 if you don't want ftd2xx usb_blaster.])
  570. fi
  571. if test $build_amtjtagaccel = yes; then
  572. AC_DEFINE(BUILD_AMTJTAGACCEL, 1, [1 if you want the Amontec JTAG-Accelerator driver.])
  573. else
  574. AC_DEFINE(BUILD_AMTJTAGACCEL, 0, [0 if you don't want the Amontec JTAG-Accelerator driver.])
  575. fi
  576. if test $build_gw16012 = yes; then
  577. AC_DEFINE(BUILD_GW16012, 1, [1 if you want the Gateworks GW16012 driver.])
  578. else
  579. AC_DEFINE(BUILD_GW16012, 0, [0 if you don't want the Gateworks GW16012 driver.])
  580. fi
  581. if test $build_presto_libftdi = yes; then
  582. build_bitq=yes
  583. AC_DEFINE(BUILD_PRESTO_LIBFTDI, 1, [1 if you want the ASIX PRESTO driver using libftdi.])
  584. else
  585. AC_DEFINE(BUILD_PRESTO_LIBFTDI, 0, [0 if you don't want the ASIX PRESTO driver using libftdi.])
  586. fi
  587. if test $build_presto_ftd2xx = yes; then
  588. build_bitq=yes
  589. AC_DEFINE(BUILD_PRESTO_FTD2XX, 1, [1 if you want the ASIX PRESTO driver using FTD2XX.])
  590. else
  591. AC_DEFINE(BUILD_PRESTO_FTD2XX, 0, [0 if you don't want the ASIX PRESTO driver using FTD2XX.])
  592. fi
  593. if test $build_bitq = yes; then
  594. AC_DEFINE(BUILD_BITQ, 1, [1 if you want a bitq interface.])
  595. else
  596. AC_DEFINE(BUILD_BITQ, 0, [0 if you don't want a bitq interface.])
  597. fi
  598. if test $build_usbprog = yes; then
  599. AC_DEFINE(BUILD_USBPROG, 1, [1 if you want the usbprog JTAG driver.])
  600. else
  601. AC_DEFINE(BUILD_USBPROG, 0, [0 if you don't want the usbprog JTAG driver.])
  602. fi
  603. if test $build_oocd_trace = yes; then
  604. AC_DEFINE(BUILD_OOCD_TRACE, 1, [1 if you want the OpenOCD+trace ETM capture driver.])
  605. else
  606. AC_DEFINE(BUILD_OOCD_TRACE, 0, [0 if you don't want the OpenOCD+trace ETM capture driver.])
  607. fi
  608. if test $build_jlink = yes; then
  609. AC_DEFINE(BUILD_JLINK, 1, [1 if you want the J-Link JTAG driver.])
  610. else
  611. AC_DEFINE(BUILD_JLINK, 0, [0 if you don't want the J-Link JTAG driver.])
  612. fi
  613. if test $build_vsllink = yes; then
  614. AC_DEFINE(BUILD_VSLLINK, 1, [1 if you want the Versaloon-Link JTAG driver.])
  615. else
  616. AC_DEFINE(BUILD_VSLLINK, 0, [0 if you don't want the Versaloon-Link JTAG driver.])
  617. fi
  618. if test $build_rlink = yes; then
  619. AC_DEFINE(BUILD_RLINK, 1, [1 if you want the RLink JTAG driver.])
  620. else
  621. AC_DEFINE(BUILD_RLINK, 0, [0 if you don't want the RLink JTAG driver.])
  622. fi
  623. if test $build_armjtagew = yes; then
  624. AC_DEFINE(BUILD_ARMJTAGEW, 1, [1 if you want the ARM-JTAG-EW JTAG driver.])
  625. else
  626. AC_DEFINE(BUILD_ARMJTAGEW, 0, [0 if you don't want the ARM-JTAG-EW JTAG driver.])
  627. fi
  628. #-- Deal with MingW/Cygwin FTD2XX issues
  629. if test $is_win32 = yes; then
  630. if test "${with_ftd2xx_linux_tardir+set}" = set
  631. then
  632. AC_MSG_ERROR([The option: with_ftd2xx_linux_tardir is for LINUX only.])
  633. fi
  634. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o $build_usb_blaster_ftd2xx = yes ; then
  635. AC_MSG_CHECKING([for ftd2xx.lib exists (win32)])
  636. # if we are given a zipdir...
  637. if test "${with_ftd2xx_win32_zipdir+set}" = set
  638. then
  639. # Set the CFLAGS for "ftd2xx.h"
  640. f=$with_ftd2xx_win32_zipdir/ftd2xx.h
  641. if test ! -f $f ; then
  642. AC_MSG_ERROR([File: $f cannot be found])
  643. fi
  644. CFLAGS="$CFLAGS -I$with_ftd2xx_win32_zipdir"
  645. # And calculate the LDFLAGS for the machine
  646. case "$host_cpu" in
  647. i?86|x86_32)
  648. LDFLAGS="$LDFLAGS -L$with_ftd2xx_win32_zipdir/i386"
  649. LIBS="$LIBS -lftd2xx"
  650. f=$with_ftd2xx_win32_zipdir/i386/ftd2xx.lib
  651. ;;
  652. amd64|x86_64)
  653. LDFLAGS="$LDFLAGS -L$with_ftd2xx_win32_zipdir/amd64"
  654. LIBS="$LIBS -lftd2xx"
  655. f=$with_ftd2xx_win32_zipdir/amd64/ftd2xx.lib
  656. ;;
  657. *)
  658. AC_MSG_ERROR([Unknown Win32 host cpu: $host_cpu])
  659. ;;
  660. esac
  661. if test ! -f $f ; then
  662. AC_MSG_ERROR([Library: $f not found])
  663. fi
  664. else
  665. LIBS="$LIBS -lftd2xx"
  666. AC_MSG_WARN([ASSUMPTION: The (win32) FTDICHIP.COM files: ftd2xx.h and ftd2xx.lib are in a proper place])
  667. fi
  668. fi
  669. fi # win32
  670. if test $is_darwin = yes ; then
  671. if test "${with_ftd2xx_win32_zipdir+set}" = set
  672. then
  673. AC_MSG_ERROR([The option: --with-ftd2xx-win32-zipdir is for win32 only])
  674. fi
  675. if test "${with_ftd2xx_linux_tardir+set}" = set
  676. then
  677. AC_MSG_ERROR([The option: with_ftd2xx_linux_tardir is for LINUX only.])
  678. fi
  679. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes ; then
  680. AC_MSG_CHECKING([for libftd2xx.a (darwin)])
  681. if test ! -f /usr/local/include/ftd2xx.h ; then
  682. AC_MSG_ERROR([ftd2xx library from FTDICHIP.com seems to be missing, cannot find: /usr/local/include/ftd2xx.h])
  683. fi
  684. CFLAGS="$CFLAGS -I/usr/local/include"
  685. LDFLAGS="$LDFLAGS -L/usr/local/lib"
  686. LIBS="$LIBS -lftd2xx"
  687. AC_MSG_RESULT([-L/usr/local/lib -lftd2xx])
  688. fi
  689. fi # darwin
  690. if test $is_win32 = no && test $is_darwin = no ; then
  691. if test "${with_ftd2xx_win32_zipdir+set}" = set
  692. then
  693. AC_MSG_ERROR([The option: --with-ftd2xx-win32-zipdir is for win32 only])
  694. fi
  695. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes ; then
  696. # Must be linux
  697. if test $host_os != linux-gnu && test $host_os != linux ; then
  698. AC_MSG_ERROR([The (linux) ftd2xx library from FTDICHIP.com is linux only. Try --enable-ft2232-libftdi instead])
  699. fi
  700. # Are we given a TAR directory?
  701. if test "${with_ftd2xx_linux_tardir+set}" = set
  702. then
  703. AC_MSG_CHECKING([uninstalled ftd2xx distribution])
  704. # The .H file is simple..
  705. FTD2XX_H=$with_ftd2xx_linux_tardir/ftd2xx.h
  706. if test ! -f "${FTD2XX_H}"; then
  707. AC_MSG_ERROR([Option: --with-ftd2xx-linux-tardir appears wrong, cannot find: ${FTD2XX_H}])
  708. fi
  709. CFLAGS="$CFLAGS -I$with_ftd2xx_linux_tardir"
  710. FTD2XX_LDFLAGS="-L$with_ftd2xx_linux_tardir"
  711. FTD2XX_LIB="-lftd2xx"
  712. if test $with_ftd2xx_lib != shared; then
  713. # Test #1 - Future proof - if/when ftdichip fixes their distro.
  714. # Try it with the simple ".a" suffix.
  715. FTD2XX_LIB="$with_ftd2xx_linux_tardir/static_lib/libftd2xx.a"
  716. if test -f "${FTD2XX_LIB}"; then
  717. FTD2XX_LDFLAGS="${FTD2XX_LDFLAGS}/static_lib"
  718. else
  719. # Test Number2.
  720. # Grr.. perhaps it exists as a version number?
  721. FTD2XX_LIB="$with_ftd2xx_linux_tardir/static_lib/libftd2xx.a.*.*.*"
  722. count=`ls ${FTD2XX_LIB} | wc -l`
  723. if test $count -gt 1 ; then
  724. AC_MSG_ERROR([Multiple libftd2xx.a files found in: $with_ftd2xx_linux_tardir/static_lib sorry cannot handle this yet])
  725. fi
  726. if test $count -ne 1 ; then
  727. AC_MSG_ERROR([Not found: $f, option: --with-ftd2xx-linux-tardir appears to be wrong])
  728. fi
  729. # Because the "-l" rules do not understand version numbers...
  730. # we will just stuff the absolute path onto the LIBS variable
  731. FTD2XX_LIB="`ls ${FTD2XX_LIB}` -lpthread"
  732. FTD2XX_LDFLAGS=""
  733. fi
  734. fi
  735. LDFLAGS="${LDFLAGS} ${FTD2XX_LDFLAGS}"
  736. LIBS="${LIBS} ${FTD2XX_LIB}"
  737. AC_MSG_RESULT([${FTD2XX_LDFLAGS} ${FTD2XX_LIB}])
  738. else
  739. AC_CHECK_HEADER([ftd2xx.h],[],[
  740. AC_MSG_ERROR([You seem to be missing the FTD2xx driver header file.])
  741. ])
  742. AC_SEARCH_LIBS([FT_GetLibraryVersion],[ftd2xx],,[
  743. AC_MSG_ERROR([You appear to be missing the FTD2xx driver library.])
  744. ],[])
  745. fi
  746. fi
  747. fi # linux
  748. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes; then
  749. # Before we go any further - make sure we can *BUILD* and *RUN*
  750. # a simple app with the "ftd2xx.lib" file - in what ever form we where given
  751. # We should be able to compile, link and run this test program now
  752. AC_MSG_CHECKING([whether ftd2xx library works])
  753. #
  754. # Save the LDFLAGS for later..
  755. LDFLAGS_SAVE=$LDFLAGS
  756. CFLAGS_SAVE=$CFLAGS
  757. _LDFLAGS=`eval echo $LDFLAGS`
  758. _CFLAGS=`eval echo $CFLAGS`
  759. LDFLAGS=$_LDFLAGS
  760. CFLAGS=$_CFLAGS
  761. AC_RUN_IFELSE([
  762. #include "confdefs.h"
  763. #if IS_WIN32
  764. #include "windows.h"
  765. #endif
  766. #include <stdio.h>
  767. #include <ftd2xx.h>
  768. int
  769. main( int argc, char **argv )
  770. {
  771. DWORD x;
  772. FT_GetLibraryVersion( &x );
  773. return 0;
  774. }
  775. ], [
  776. AC_MSG_RESULT([Success!])
  777. ], [
  778. AC_MSG_ERROR([Cannot build & run test program using ftd2xx.lib])
  779. ], [
  780. AC_MSG_RESULT([Skipping as we are cross-compiling])
  781. ])
  782. AC_MSG_CHECKING([for ftd2xx highspeed device support])
  783. AC_COMPILE_IFELSE([
  784. #include "confdefs.h"
  785. #if IS_WIN32
  786. #include "windows.h"
  787. #endif
  788. #include <stdio.h>
  789. #include <ftd2xx.h>
  790. DWORD x = FT_DEVICE_4232H;
  791. ], [
  792. AC_DEFINE(BUILD_FT2232_HIGHSPEED, [1],
  793. [Support FT2232H/FT4232HS with FTD2XX or libftdi.])
  794. build_ft2232_highspeed=yes
  795. ], [
  796. build_ft2232_highspeed=no
  797. ])
  798. AC_MSG_RESULT([$build_ft2232_highspeed])
  799. if test $build_ft2232_highspeed = no; then
  800. AC_MSG_WARN([You need a newer FTD2XX driver (version 2.04.16 or later).])
  801. fi
  802. LDFLAGS=$LDFLAGS_SAVE
  803. CFLAGS=$CFLAGS_SAVE
  804. fi
  805. if test $build_ft2232_libftdi = yes ; then
  806. # We assume: the package is preinstalled in the proper place
  807. # these present as 2 libraries..
  808. LIBS="$LIBS -lftdi -lusb"
  809. #
  810. # Try to build a small program.
  811. AC_MSG_CHECKING([Build & Link with libftdi...])
  812. LDFLAGS_SAVE=$LDFLAGS
  813. CFLAGS_SAVE=$CFLAGS
  814. _LDFLAGS=`eval echo $LDFLAGS`
  815. _CFLAGS=`eval echo $CFLAGS`
  816. LDFLAGS=$_LDFLAGS
  817. CFLAGS=$_CFLAGS
  818. AC_RUN_IFELSE([
  819. #include <stdio.h>
  820. #include <ftdi.h>
  821. int
  822. main( int argc, char **argv )
  823. {
  824. struct ftdi_context *p;
  825. p = ftdi_new();
  826. if( p != NULL ){
  827. return 0;
  828. } else {
  829. fprintf( stderr, "calling ftdi_new() failed\n");
  830. return 1;
  831. }
  832. }
  833. ], [
  834. AC_MSG_RESULT([Success])
  835. ], [
  836. AC_MSG_ERROR([Cannot build & run test program using libftdi])
  837. ], [
  838. AC_MSG_RESULT([Skipping as we are cross-compiling])
  839. ])
  840. AC_MSG_CHECKING([for libftdi highspeed device support])
  841. AC_COMPILE_IFELSE([
  842. #include <stdio.h>
  843. #include <ftdi.h>
  844. enum ftdi_chip_type x = TYPE_2232H;
  845. ], [
  846. AC_DEFINE(BUILD_FT2232_HIGHSPEED, [1],
  847. [Support FT2232H/FT4232HS with FTD2XX or libftdi.])
  848. build_ft2232_highspeed=yes
  849. ], [
  850. build_ft2232_highspeed=no
  851. ])
  852. AC_MSG_RESULT([$build_ft2232_highspeed])
  853. if test $build_ft2232_highspeed = no; then
  854. AC_MSG_WARN([You need a newer libftdi version (0.16 or later).])
  855. fi
  856. # Restore the 'unexpanded ldflags'
  857. LDFLAGS=$LDFLAGS_SAVE
  858. CFLAGS=$CFLAGS_SAVE
  859. fi
  860. # check for usb.h when a driver will require it
  861. build_usb=no
  862. if test $build_jlink = yes -o $build_vsllink = yes -o $build_usbprog = yes -o \
  863. $build_rlink = yes -o $build_armjtagew = yes
  864. then
  865. AC_CHECK_HEADERS([usb.h],[],
  866. [AC_MSG_ERROR([usb.h is required to build some OpenOCD driver(s)])])
  867. build_usb=yes
  868. fi
  869. AM_CONDITIONAL(RELEASE, test $build_release = yes)
  870. AM_CONDITIONAL(PARPORT, test $build_parport = yes)
  871. AM_CONDITIONAL(DUMMY, test $build_dummy = yes)
  872. AM_CONDITIONAL(GIVEIO, test x$parport_use_giveio = xyes)
  873. AM_CONDITIONAL(EP93XX, test $build_ep93xx = yes)
  874. AM_CONDITIONAL(ECOSBOARD, test $build_ecosboard = yes)
  875. AM_CONDITIONAL(ZY1000, test $build_zy1000 = yes)
  876. AM_CONDITIONAL(IOUTIL, test $build_ioutil = yes)
  877. AM_CONDITIONAL(HTTPD, test $build_httpd = yes)
  878. AM_CONDITIONAL(AT91RM9200, test $build_at91rm9200 = yes)
  879. AM_CONDITIONAL(BITBANG, test $build_bitbang = yes)
  880. AM_CONDITIONAL(FT2232_LIBFTDI, test $build_ft2232_libftdi = yes)
  881. AM_CONDITIONAL(FT2232_DRIVER, test $build_ft2232_ftd2xx = yes -o $build_ft2232_libftdi = yes)
  882. AM_CONDITIONAL(USB_BLASTER_LIBFTDI, test $build_usb_blaster_libftdi = yes)
  883. AM_CONDITIONAL(USB_BLASTER_DRIVER, test $build_usb_blaster_ftd2xx = yes -o $build_usb_blaster_libftdi = yes)
  884. AM_CONDITIONAL(AMTJTAGACCEL, test $build_amtjtagaccel = yes)
  885. AM_CONDITIONAL(GW16012, test $build_gw16012 = yes)
  886. AM_CONDITIONAL(PRESTO_LIBFTDI, test $build_presto_libftdi = yes)
  887. AM_CONDITIONAL(PRESTO_DRIVER, test $build_presto_ftd2xx = yes -o $build_presto_libftdi = yes)
  888. AM_CONDITIONAL(USBPROG, test $build_usbprog = yes)
  889. AM_CONDITIONAL(OOCD_TRACE, test $build_oocd_trace = yes)
  890. AM_CONDITIONAL(JLINK, test $build_jlink = yes)
  891. AM_CONDITIONAL(VSLLINK, test $build_vsllink = yes)
  892. AM_CONDITIONAL(RLINK, test $build_rlink = yes)
  893. AM_CONDITIONAL(ARMJTAGEW, test $build_armjtagew = yes)
  894. AM_CONDITIONAL(USB, test $build_usb = yes)
  895. AM_CONDITIONAL(IS_CYGWIN, test $is_cygwin = yes)
  896. AM_CONDITIONAL(IS_MINGW, test $is_mingw = yes)
  897. AM_CONDITIONAL(IS_WIN32, test $is_win32 = yes)
  898. AM_CONDITIONAL(IS_DARWIN, test $is_darwin = yes)
  899. AM_CONDITIONAL(BITQ, test $build_bitq = yes)
  900. AM_CONDITIONAL(MINIDRIVER, test $build_minidriver = yes)
  901. AM_CONDITIONAL(MINIDRIVER_DUMMY, test $build_minidriver_dummy = yes)
  902. # Look for environ alternatives. Possibility #1: is environ in unistd.h or stdlib.h?
  903. AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])
  904. AC_COMPILE_IFELSE([
  905. #define _GNU_SOURCE
  906. #include <unistd.h>
  907. #include <stdlib.h>
  908. int main(int argc, char **argv) { char **ep = environ; }
  909. ], [
  910. AC_MSG_RESULT([yes])
  911. has_environ=yes
  912. ], [
  913. AC_MSG_RESULT([no])
  914. # Possibility #2: can environ be found in an available library?
  915. AC_MSG_CHECKING([for extern environ])
  916. AC_LINK_IFELSE([
  917. extern char **environ;
  918. int main(int argc, char **argv) { char **ep = environ; }
  919. ], [
  920. AC_DEFINE(NEED_ENVIRON_EXTERN, [1], [Must declare 'environ' to use it.])
  921. has_environ=yes
  922. ], [
  923. has_environ=no
  924. ])
  925. AC_MSG_RESULT([${has_environ}])
  926. ])
  927. if test "${has_environ}" != "yes" ; then
  928. AC_MSG_FAILURE([Could not find 'environ' in unistd.h or available libraries.])
  929. fi
  930. AC_DEFINE([_GNU_SOURCE],[1],[Use GNU C library extensions (e.g. stdndup).])
  931. # set default gcc warnings
  932. GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security"
  933. if test "${gcc_wextra}" = yes; then
  934. GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter"
  935. GCC_WARNINGS="${GCC_WARNINGS} -Wbad-function-cast"
  936. GCC_WARNINGS="${GCC_WARNINGS} -Wcast-align"
  937. GCC_WARNINGS="${GCC_WARNINGS} -Wredundant-decls"
  938. fi
  939. if test "${gcc_werror}" = yes; then
  940. GCC_WARNINGS="${GCC_WARNINGS} -Werror"
  941. fi
  942. # overide default gcc cflags
  943. if test $gcc_warnings = yes; then
  944. CFLAGS="$CFLAGS $GCC_WARNINGS"
  945. fi
  946. # Setup for compiling build tools
  947. AC_MSG_CHECKING([for a C compiler for build tools])
  948. if test $cross_compiling = yes; then
  949. AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
  950. CFLAGS_FOR_BUILD="-g -O2 $GCC_WARNINGS"
  951. else
  952. CC_FOR_BUILD=$CC
  953. CFLAGS_FOR_BUILD=$CFLAGS
  954. fi
  955. AC_MSG_RESULT([$CC_FOR_BUILD])
  956. AC_SUBST(CC_FOR_BUILD)
  957. AC_SUBST(CFLAGS_FOR_BUILD)
  958. AC_MSG_CHECKING([for suffix of executable build tools])
  959. if test $cross_compiling = yes; then
  960. cat >conftest.c <<\_______EOF
  961. int main ()
  962. {
  963. exit (0);
  964. }
  965. _______EOF
  966. for i in .exe ""; do
  967. compile="$CC_FOR_BUILD conftest.c -o conftest$i"
  968. if AC_TRY_EVAL(compile); then
  969. if (./conftest) 2>&AC_FD_CC; then
  970. EXEEXT_FOR_BUILD=$i
  971. break
  972. fi
  973. fi
  974. done
  975. rm -f conftest*
  976. if test "${EXEEXT_FOR_BUILD+set}" != set; then
  977. AC_MSG_ERROR([Cannot determine suffix of executable build tools])
  978. fi
  979. else
  980. EXEEXT_FOR_BUILD=$EXEEXT
  981. fi
  982. AC_MSG_RESULT([$EXEEXT_FOR_BUILD])
  983. AC_SUBST(EXEEXT_FOR_BUILD)
  984. AC_OUTPUT(dnl
  985. Makefile dnl
  986. src/Makefile dnl
  987. src/helper/Makefile dnl
  988. src/jtag/Makefile dnl
  989. src/jtag/drivers/Makefile dnl
  990. src/xsvf/Makefile dnl
  991. src/svf/Makefile dnl
  992. src/target/Makefile dnl
  993. src/server/Makefile dnl
  994. src/flash/Makefile dnl
  995. src/flash/nor/Makefile dnl
  996. src/flash/nand/Makefile dnl
  997. src/pld/Makefile dnl
  998. doc/Makefile dnl
  999. )