1# 2# avrdude - A Downloader/Uploader for AVR device programmers 3# Copyright (C) 2003, 2004 Theodore A. Roth <troth@openavr.org> 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 2 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see <http://www.gnu.org/licenses/>. 17# 18 19# 20# $Id: configure.ac 1523 2021-12-16 21:02:35Z joerg_wunsch $ 21# 22 23# Process this file with autoconf to produce a configure script. 24 25AC_PREREQ(2.60) 26AC_INIT(avrdude, 6.4, avrdude-dev@nongnu.org) 27 28AC_CANONICAL_BUILD 29AC_CANONICAL_HOST 30AC_CANONICAL_TARGET 31 32AC_CONFIG_SRCDIR([main.c]) 33AM_INIT_AUTOMAKE 34AC_CONFIG_HEADERS(ac_cfg.h) 35AC_CONFIG_MACRO_DIR([m4]) 36 37LT_INIT() 38 39m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 40 41# Checks for programs. 42AC_PROG_CC 43AC_PROG_INSTALL 44AC_PROG_SED 45AC_PROG_YACC 46AC_PROG_LEX 47AN_MAKEVAR([AR], [AC_PROG_AR]) 48AN_PROGRAM([ar], [AC_PROG_AR]) 49AC_DEFUN([AC_PROG_AR], [AC_CHECK_TARGET_TOOL(AR, ar, :)]) 50AC_PROG_AR 51AH_TEMPLATE([HAVE_YYLEX_DESTROY], 52 [Define if lex/flex has yylex_destroy]) 53# flex should have this 54if test "x$LEX" == xflex; then 55 AC_MSG_CHECKING([whether yylex_destroy is generated by flex]) 56 flex_version=`$LEX -V -v --version 2>/dev/null | $SED -e 's/^.* //'` 57 case $flex_version in 58 [[0-1].*)] 59 AC_MSG_RESULT([version $flex_version => no]) 60 ;; 61 [2.[0-4].*)] 62 AC_MSG_RESULT([version $flex_version => no]) 63 ;; 64 [2.5.[0-8])] 65 AC_MSG_RESULT([version $flex_version => no]) 66 ;; 67 [2.5.[0-8][A-Za-z]*)] 68 AC_MSG_RESULT([version $flex_version => no]) 69 ;; 70 *) 71 AC_MSG_RESULT([version $flex_version => yes]) 72 AC_DEFINE([HAVE_YYLEX_DESTROY]) 73 ;; 74 esac 75fi 76 77dnl Makefile.am:77: compiling `config_gram.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac' 78AM_PROG_CC_C_O 79 80# Checks for libraries. 81AC_CHECK_LIB([termcap], [tputs]) 82AC_CHECK_LIB([ncurses], [tputs]) 83AC_CHECK_LIB([readline], [readline]) 84AH_TEMPLATE([HAVE_LIBELF], 85 [Define if ELF support is enabled via libelf]) 86AC_CHECK_LIB([elf], [elf_getshdrstrndx], [have_libelf=yes]) 87if test x$have_libelf = xyes; then 88 case $target in 89 *) 90 LIBELF="-lelf" 91 ;; 92 esac 93 AC_DEFINE([HAVE_LIBELF]) 94 AC_CHECK_HEADERS([libelf.h libelf/libelf.h]) 95fi 96AC_SUBST(LIBELF, $LIBELF) 97 98AC_SEARCH_LIBS([gethostent], [nsl]) 99AC_SEARCH_LIBS([setsockopt], [socket]) 100AH_TEMPLATE([HAVE_LIBUSB], 101 [Define if USB support is enabled via libusb]) 102AC_CHECK_LIB([usb], [usb_get_string_simple], [have_libusb=yes]) 103if test x$have_libusb = xyes; then 104 case $target in 105 *-*-darwin*) 106 LIBUSB="-lusb -framework CoreFoundation -framework IOKit" 107 ;; 108 *) 109 LIBUSB="-lusb" 110 ;; 111 esac 112 AC_DEFINE([HAVE_LIBUSB]) 113 AC_CHECK_HEADERS([usb.h]) 114 AC_CHECK_HEADERS([lusb0_usb.h]) 115fi 116AC_SUBST(LIBUSB, $LIBUSB) 117 118AC_ARG_ENABLE( 119 [libusb_1_0], 120 AC_HELP_STRING( 121 [--disable-libusb_1_0], 122 [Allow to build with libusb instead of libusb_1_0 if both are present]), 123 [case "${enableval}" in 124 yes) enabled_libusb_1_0=yes ;; 125 no) enabled_libusb_1_0=no ;; 126 *) AC_MSG_ERROR(bad value ${enableval} for enable-libusb_1_0 option) ;; 127 esac], 128 [enabled_libusb_1_0=yes]) 129 130AH_TEMPLATE([HAVE_LIBUSB_1_0], 131 [Define if USB support is enabled via libusb 1.0]) 132AC_CHECK_LIB([usb-1.0], [libusb_init], [have_libusb_1_0=yes]) 133if test x$have_libusb_1_0 = xyes && test x$enabled_libusb_1_0 = xyes; then 134 case $target in 135 *-*-darwin*) 136 LIBUSB_1_0="-lusb-1.0 -framework CoreFoundation -framework IOKit" 137 ;; 138 *) 139 LIBUSB_1_0="-lusb-1.0" 140 ;; 141 esac 142 AC_DEFINE([HAVE_LIBUSB_1_0]) 143 AC_CHECK_HEADERS([libusb-1.0/libusb.h]) 144 AC_CHECK_HEADERS([libusb.h]) 145fi 146AH_TEMPLATE([HAVE_LIBUSB_1_0], 147 [Define if USB support is enabled via a libusb-1.0 compatible libusb]) 148AC_CHECK_LIB([usb], [libusb_init], [have_libusb_1_0=yes]) 149if test x$have_libusb_1_0 = xyes && test x$enabled_libusb_1_0 = xyes; then 150 case $target in 151 *-*-freebsd*) 152 # FreeBSD 8+ has a native libusb-1.0 API compatible 153 # library offered by -lusb (which is also libusb-0.1 154 # compatible). FreeBSD <8 does not have a libusb-1.0 155 # at all so probing will fail but we do not have to 156 # special-case that. 157 LIBUSB_1_0="-lusb" 158 ;; 159 *) 160 LIBUSB_1_0="-lusb-1.0" 161 ;; 162 esac 163 AC_DEFINE([HAVE_LIBUSB_1_0]) 164 AC_CHECK_HEADERS([libusb.h]) 165fi 166AC_SUBST(LIBUSB_1_0, $LIBUSB_1_0) 167 168AH_TEMPLATE([HAVE_LIBHIDAPI], 169 [Define if HID support is enabled via libhidapi]) 170AC_SEARCH_LIBS([hid_init], [hidapi hidapi-libusb hidapi-hidraw], [have_libhidapi=yes]) 171if test x$have_libhidapi = xyes; then 172 case $target in 173 *-*-darwin*) 174 LIBHIDAPI="-lhidapi -iframework CoreFoundation -framework IOKit" 175 ;; 176 *) 177 LIBHIDAPI="$ac_cv_lib_hid_init" 178 ;; 179 esac 180 AC_DEFINE([HAVE_LIBHIDAPI]) 181 AC_CHECK_HEADERS([hidapi/hidapi.h]) 182fi 183AC_SUBST(LIBHIDAPI, $LIBHIDAPI) 184 185 186AH_TEMPLATE([HAVE_LIBFTDI1], 187 [Define if FTDI support is enabled via libftdi1]) 188AH_TEMPLATE([HAVE_LIBFTDI], 189 [Define if FTDI support is enabled via libftdi]) 190AH_TEMPLATE([HAVE_LIBFTDI_TYPE_232H], 191 [Define if libftdi supports FT232H, libftdi version >= 0.20]) 192AC_CHECK_LIB([ftdi1], [ftdi_new], [have_libftdi1=yes], [], [$LIBUSB_1_0]) 193AC_CHECK_LIB([ftdi], [ftdi_usb_get_strings], [have_libftdi=yes], [], [-lusb]) 194if test x$have_libftdi1 = xyes; then 195 LIBFTDI1="-lftdi1" 196 AC_DEFINE([HAVE_LIBFTDI1]) 197 AC_SUBST(LIBFTDI1, $LIBFTDI1) 198else 199 if test x$have_libftdi = xyes; then 200 LIBFTDI="-lftdi -lusb" 201 AC_DEFINE([HAVE_LIBFTDI]) 202 AC_SUBST(LIBFTDI, $LIBFTDI) 203 AC_CHECK_DECL(TYPE_232H,[have_libftdi_FT232H=yes], [], [[#include <ftdi.h>]]) 204 if test x$have_libftdi_FT232H = xyes; then 205 AC_DEFINE([HAVE_LIBFTDI_TYPE_232H]) 206 fi 207 fi 208fi 209AC_CHECK_HEADERS([pthread.h]) 210# as there exits header file only pthread implementations for Windows, check if we have a library 211AC_CHECK_LIB([pthread], [pthread_create], [have_pthread=yes]) 212if test x$have_pthread = xyes; then 213 LIBPTHREAD="-lpthread" 214fi 215AC_SUBST(LIBPTHREAD, $LIBPTHREAD) 216# Checks for header files. 217AC_CHECK_HEADERS([limits.h stdlib.h string.h]) 218AC_CHECK_HEADERS([fcntl.h sys/ioctl.h sys/time.h termios.h unistd.h]) 219AC_CHECK_HEADERS([ddk/hidsdi.h],,,[#include <windows.h> 220#include <setupapi.h>]) 221 222 223# Checks for typedefs, structures, and compiler characteristics. 224AC_C_CONST 225AC_HEADER_TIME 226 227AC_CHECK_HEADERS([netinet/in.h]) 228 229# WinSock2 230AC_CHECK_LIB([ws2_32], [puts]) 231 232# Checks for library functions. 233AC_CHECK_FUNCS([memset select strcasecmp strdup strerror strncasecmp strtol strtoul gettimeofday usleep getaddrinfo]) 234 235AC_MSG_CHECKING([for a Win32 HID libray]) 236SAVED_LIBS="${LIBS}" 237case $target in 238 *-*-mingw32* | *-*-cygwin* | *-*-windows*) 239 LIBHID="-lhid -lsetupapi" 240 if test $ac_cv_header_ddk_hidsdi_h = yes 241 then 242 HIDINCLUDE="#include <ddk/hidsdi.h>" 243 else 244 HIDINCLUDE="#include \"my_ddk_hidsdi.h\"" 245 fi 246 ;; 247 *) 248 LIBHID="" 249 ;; 250esac 251LIBS="${LIBS} ${LIBHID}" 252 253AH_TEMPLATE([HAVE_LIBHID], 254 [Define if HID support is enabled via the Win32 DDK]) 255AC_TRY_LINK([#include <windows.h> 256#include <setupapi.h> 257$HIDINCLUDE], 258[int 259main(void) 260{ 261 GUID hidGuid; 262 HidD_GetHidGuid(&hidGuid); 263 264 return 0; 265} 266], [have_libhid=yes], [have_libhid=no]) 267AC_MSG_RESULT([$have_libhid]) 268if test x$have_libhid = xyes; then 269 AC_DEFINE([HAVE_LIBHID]) 270else 271 LIBHID="" 272fi 273LIBS="${SAVED_LIBS}" 274AC_SUBST(LIBHID, $LIBHID) 275 276# Check for types 277 278# Solaris has uint_t and ulong_t typedefs in <sys/types.h>, avoid 279# the redeclaration in usbtiny.c. 280AC_CHECK_TYPES([uint_t], [], [], [#include <sys/types.h>]) 281AC_CHECK_TYPES([ulong_t], [], [], [#include <sys/types.h>]) 282 283# Checks for misc stuff. 284 285AC_ARG_ENABLE( 286 [versioned-doc], 287 AC_HELP_STRING( 288 [--enable-versioned-doc], 289 [install docs in directory with version name (default)]), 290 [case "${enableval}" in 291 yes) versioned_doc=yes ;; 292 no) versioned_doc=no ;; 293 *) AC_MSG_ERROR(bad value ${enableval} for versioned-doc option) ;; 294 esac], 295 [versioned_doc=yes]) 296 297if test "$versioned_doc" = "yes"; then 298 DOC_INST_DIR='$(DESTDIR)$(datadir)/doc/avrdude-$(VERSION)' 299else 300 DOC_INST_DIR='$(DESTDIR)$(datadir)/doc/avrdude' 301fi 302 303AC_ARG_ENABLE( 304 [doc], 305 AC_HELP_STRING( 306 [--enable-doc], 307 [Enable building documents]), 308 [case "${enableval}" in 309 yes) enabled_doc=yes ;; 310 no) enabled_doc=no ;; 311 *) AC_MSG_ERROR(bad value ${enableval} for disable-doc option) ;; 312 esac], 313 [enabled_doc=no]) 314 315AC_ARG_ENABLE( 316 [parport], 317 AC_HELP_STRING( 318 [--enable-parport], 319 [Enable accessing parallel ports(default)]), 320 [case "${enableval}" in 321 yes) enabled_parport=yes ;; 322 no) enabled_parport=no ;; 323 *) AC_MSG_ERROR(bad value ${enableval} for enable-parport option) ;; 324 esac], 325 [enabled_parport=no]) 326 327AC_ARG_ENABLE( 328 [linuxgpio], 329 AC_HELP_STRING( 330 [--enable-linuxgpio], 331 [Enable the Linux sysfs GPIO interface programmer type]), 332 [case "${enableval}" in 333 yes) enabled_linuxgpio=yes ;; 334 no) enabled_linuxgpio=no ;; 335 *) AC_MSG_ERROR(bad value ${enableval} for enable-linuxgpio option) ;; 336 esac], 337 [enabled_linuxgpio=no]) 338 339AC_ARG_ENABLE( 340 [linuxspi], 341 AC_HELP_STRING( 342 [--enable-linuxspi], 343 [Enable the Linux SPIDEV interface programmer type]), 344 [case "${enableval}" in 345 yes) enabled_linuxspi=yes ;; 346 no) enabled_linuxspi=no ;; 347 *) AC_MSG_ERROR(bad value ${enableval} for enable-linuxspi option) ;; 348 esac], 349 [enabled_linuxspi=no]) 350 351DIST_SUBDIRS_AC='doc windows' 352 353if test "$enabled_doc" = "yes"; then 354 SUBDIRS_AC='doc' 355else 356 SUBDIRS_AC='' 357fi 358 359AC_SUBST(DOC_INST_DIR, $DOC_INST_DIR) 360AC_SUBST(SUBDIRS_AC, $SUBDIRS_AC) 361AC_SUBST(DIST_SUBDIRS_AC, $DIST_SUBDIRS_AC) 362 363 364# Find the parallel serial device files based on target system 365# If a system doesn't have a PC style parallel, mark it as unknown. 366case $target in 367 i[[3456]]86-*-linux*|x86_64-*-linux*) 368 DEFAULT_PAR_PORT="/dev/parport0" 369 DEFAULT_SER_PORT="/dev/ttyS0" 370 ;; 371 *-*-linux*) 372 DEFAULT_PAR_PORT="unknown" 373 DEFAULT_SER_PORT="/dev/ttyS0" 374 ;; 375 i[[3456]]86-*-*freebsd*|amd64-*-*freebsd*) 376 DEFAULT_PAR_PORT="/dev/ppi0" 377 DEFAULT_SER_PORT="/dev/cuad0" 378 ;; 379 *-*-*freebsd*) 380 DEFAULT_PAR_PORT="unknown" 381 DEFAULT_SER_PORT="/dev/cuad0" 382 ;; 383 *-*-solaris*) 384 DEFAULT_PAR_PORT="/dev/printers/0" 385 DEFAULT_SER_PORT="/dev/term/a" 386 ;; 387 *-*-msdos* | *-*-mingw32* | *-*-cygwin* | *-*-windows*) 388 DEFAULT_PAR_PORT="lpt1" 389 DEFAULT_SER_PORT="com1" 390 ;; 391 *) 392 DEFAULT_PAR_PORT="unknown" 393 DEFAULT_SER_PORT="unknown" 394 ;; 395esac 396 397if test "$enabled_parport" = "yes"; then 398 AC_MSG_CHECKING([for parallel device]) 399 if test "$DEFAULT_PAR_PORT" = "unknown"; then 400 AC_MSG_NOTICE([parallel port access disabled for this system]) 401 enabled_parport=no 402 else 403 AC_MSG_RESULT([$DEFAULT_PAR_PORT]) 404 fi 405 AC_SUBST(DEFAULT_PAR_PORT, $DEFAULT_PAR_PORT) 406fi 407 408AC_MSG_CHECKING([for serial device]) 409AC_MSG_RESULT([$DEFAULT_SER_PORT]) 410AC_SUBST(DEFAULT_SER_PORT, $DEFAULT_SER_PORT) 411 412if test "$enabled_parport" = "yes"; then 413 AC_DEFINE(HAVE_PARPORT, 1, [parallel port access enabled]) 414 confsubst="-e /^@HAVE_PARPORT_/d" 415else 416 confsubst="-e /^@HAVE_PARPORT_BEGIN@/,/^@HAVE_PARPORT_END@/d" 417fi 418 419 420if test "$enabled_linuxgpio" = "yes"; then 421 AC_DEFINE(HAVE_LINUXGPIO, 1, [Linux sysfs GPIO support enabled]) 422 confsubst="$confsubst -e /^@HAVE_LINUXGPIO_/d" 423else 424 confsubst="$confsubst -e /^@HAVE_LINUXGPIO_BEGIN@/,/^@HAVE_LINUXGPIO_END@/d" 425fi 426 427 428if test "$enabled_linuxspi" = "yes"; then 429 AC_DEFINE(HAVE_LINUXSPI, 1, [Linux SPI support enabled]) 430 confsubst="$confsubst -e /^@HAVE_LINUXSPI_/d" 431else 432 confsubst="$confsubst -e /^@HAVE_LINUXSPI_BEGIN@/,/^@HAVE_LINUXSPI_END@/d" 433fi 434 435 436# If we are compiling with gcc, enable all warning and make warnings errors. 437if test "$GCC" = yes; then 438 ENABLE_WARNINGS="-Wall" 439 440 # does this compiler support -Wno-pointer-sign ? 441 AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign ]) 442 443 safe_CFLAGS=$CFLAGS 444 CFLAGS="$ENABLE_WARNINGS -Wno-pointer-sign" 445 446 AC_TRY_COMPILE(, [ int main () { return 0 ; } ], [ 447 no_pointer_sign=yes 448 AC_MSG_RESULT([yes]) 449 ], [ 450 no_pointer_sign=no 451 AC_MSG_RESULT([no]) 452 ]) 453 CFLAGS=$safe_CFLAGS 454 455 if test x$no_pointer_sign = xyes; then 456 ENABLE_WARNINGS="$ENABLE_WARNINGS -Wno-pointer-sign" 457 fi 458fi 459AC_SUBST(ENABLE_WARNINGS,$ENABLE_WARNINGS) 460 461# See if we need to drop into the windows subdir. 462case $target in 463 *-*-mingw32* | *-*-cygwin* | *-*-windows*) 464 if test "$GCC" = yes -a \( "$CC" = "cc" -o "$CC" = "gcc" \); then 465 # does this compiler support -mno-cygwin? 466 AC_MSG_CHECKING([if $CC accepts -mno-cygwin]) 467 468 safe_CFLAGS="$CFLAGS" 469 CFLAGS="$ENABLE_WARNINGS -mno-cygwin" 470 471 AC_TRY_COMPILE(, [ int main () { return 0 ; } ], [ 472 no_cygwin=yes 473 AC_MSG_RESULT([yes]) 474 ], [ 475 no_cygwin=no 476 AC_MSG_RESULT([no]) 477 ]) 478 CFLAGS="$safe_CFLAGS" 479 480 if test x$no_cygwin = xyes; then 481 CFLAGS="${CFLAGS} -mno-cygwin" 482 else 483 AC_MSG_NOTICE([Your compiler does not understand the -mno-cygwin option.]) 484 AC_MSG_NOTICE([You might want to select an alternative compiler, like]) 485 AC_MSG_NOTICE([]) 486 AC_MSG_NOTICE([CC=mingw32-gcc ./configure]) 487 AC_MSG_NOTICE([]) 488 fi 489 fi 490 491 AC_MSG_CHECKING([if linker accepts -static]) 492 493 safe_LDFLAGS="$LDFLAGS" 494 LDFLAGS="${LDFLAGS} -static" 495 AC_TRY_LINK(, [ int main () { return 0 ; } ], [ 496 can_link_static=yes 497 AC_MSG_RESULT([yes]) 498 ], [ 499 can_link_static_cygwin=no 500 AC_MSG_RESULT([no]) 501 ]) 502 LDFLAGS="$safe_LDFLAGS" 503 504 if test x$can_link_static = xyes; then 505 LDFLAGS="${LDFLAGS} -static" 506 fi 507 508 WINDOWS_DIRS="windows" 509 CFLAGS="${CFLAGS} -DWIN32NATIVE" 510 ;; 511esac 512AC_SUBST(WINDOWS_DIRS,$WINDOWS_DIRS) 513 514AC_CONFIG_FILES([ 515 doc/Makefile 516 windows/Makefile 517 avrdude.spec 518 Makefile 519]) 520 521# The procedure to create avrdude.conf involves two steps. First, 522# normal autoconf substitution will be applied, resulting in 523# avrdude.conf.tmp. Finally, a sed command will be applied to filter 524# out unwanted parts (currently the parallel port programmer types) 525# based on previous configuration results, thereby producing the final 526# avrdude.conf file. 527 528AC_CONFIG_FILES([avrdude.conf.tmp:avrdude.conf.in], 529 [sed $confsubst avrdude.conf.tmp > avrdude.conf], 530 [confsubst="$confsubst"]) 531 532AC_OUTPUT 533 534echo "" 535echo "" 536echo "Configuration summary:" 537echo "----------------------" 538 539if test x$have_libelf = xyes; then 540 echo "DO HAVE libelf" 541else 542 echo "DON'T HAVE libelf" 543fi 544 545if test x$have_libusb = xyes; then 546 echo "DO HAVE libusb" 547else 548 echo "DON'T HAVE libusb" 549fi 550 551if test x$have_libusb_1_0 = xyes; then 552 if test x$enabled_libusb_1_0 = xyes; then 553 echo "DO HAVE libusb_1_0" 554 else 555 echo "DISABLED libusb_1_0" 556 fi 557else 558 echo "DON'T HAVE libusb_1_0" 559fi 560 561if test x$have_libftdi1 = xyes; then 562 echo "DO HAVE libftdi1" 563else 564 echo "DON'T HAVE libftdi1" 565fi 566 567if test x$have_libftdi = xyes; then 568 if test x$have_libftdi1 = xyes; then 569 echo "DO HAVE libftdi (but prefer to use libftdi1)" 570 else 571 echo "DO HAVE libftdi" 572 fi 573else 574 echo "DON'T HAVE libftdi" 575fi 576 577if test x$have_libhid = xyes; then 578 echo "DO HAVE libhid" 579else 580 echo "DON'T HAVE libhid" 581fi 582 583if test x$have_libhidapi = xyes; then 584 echo "DO HAVE libhidapi" 585else 586 echo "DON'T HAVE libhidapi" 587fi 588 589if test x$have_pthread = xyes; then 590 echo "DO HAVE pthread" 591else 592 echo "DON'T HAVE pthread" 593fi 594 595if test x$enabled_doc = xyes; then 596 echo "ENABLED doc" 597else 598 echo "DISABLED doc" 599fi 600 601if test x$enabled_parport = xyes; then 602 echo "ENABLED parport" 603else 604 echo "DISABLED parport" 605fi 606 607if test x$enabled_linuxgpio = xyes; then 608 echo "ENABLED linuxgpio" 609else 610 echo "DISABLED linuxgpio" 611fi 612 613if test x$enabled_linuxspi = xyes; then 614 echo "ENABLED linuxspi" 615else 616 echo "DISABLED linuxspi" 617fi 618 619