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.
 
 
 
 
 
 

1139 lines
34 KiB

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