Skip to content

Commit fcc63f7

Browse files
committed
m4 quote macro args and set variable defaults
This m4 quotes many more macro arguments and deals with the setting of variables. * Set variable default values to avoid accidental use of env vars from the caller of the configure script * rewrap some longer lines * Remove AC_SUBST([FOO], [$FOO]) type no-ops. AC_SUBST([FOO]) does the same.
1 parent 1a85ec1 commit fcc63f7

File tree

1 file changed

+55
-36
lines changed

1 file changed

+55
-36
lines changed

src/configure.ac

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ AC_CHECK_LIB([readline], [readline], [dnl
169169
AH_TEMPLATE([HAVE_LIBELF],
170170
[Define if ELF support is enabled via libelf])
171171
AC_CHECK_LIB([elf], [elf_getshdrstrndx], [have_libelf=yes])
172+
LIBELF=""
172173
if test "x$have_libelf" = xyes; then
173174
case $target in
174175
*)
@@ -178,13 +179,14 @@ if test "x$have_libelf" = xyes; then
178179
AC_DEFINE([HAVE_LIBELF])
179180
AC_CHECK_HEADERS([libelf.h libelf/libelf.h])
180181
fi
181-
AC_SUBST(LIBELF, $LIBELF)
182+
AC_SUBST([LIBELF])
182183

183184
AC_SEARCH_LIBS([gethostent], [nsl])
184185
AC_SEARCH_LIBS([setsockopt], [socket])
185186
AH_TEMPLATE([HAVE_LIBUSB],
186187
[Define if USB support is enabled via libusb])
187188
AC_CHECK_LIB([usb], [usb_get_string_simple], [have_libusb=yes])
189+
LIBUSB=""
188190
if test "x$have_libusb" = xyes; then
189191
case $target in
190192
*-*-darwin*)
@@ -198,7 +200,7 @@ if test "x$have_libusb" = xyes; then
198200
AC_CHECK_HEADERS([usb.h])
199201
AC_CHECK_HEADERS([lusb0_usb.h])
200202
fi
201-
AC_SUBST(LIBUSB, $LIBUSB)
203+
AC_SUBST([LIBUSB])
202204

203205
AC_ARG_ENABLE(
204206
[libusb_1_0],
@@ -207,13 +209,15 @@ AC_ARG_ENABLE(
207209
[case "${enableval}" in
208210
yes) enabled_libusb_1_0=yes ;;
209211
no) enabled_libusb_1_0=no ;;
210-
*) AC_MSG_ERROR(bad value ${enableval} for enable-libusb_1_0 option) ;;
212+
*) AC_MSG_ERROR([bad value ${enableval} for enable-libusb_1_0 option]) ;;
211213
esac],
212214
[enabled_libusb_1_0=yes])
213215

216+
have_libusb_1_0=no
214217
AH_TEMPLATE([HAVE_LIBUSB_1_0],
215218
[Define if USB support is enabled via libusb 1.0])
216219
AC_CHECK_LIB([usb-1.0], [libusb_init], [have_libusb_1_0=yes])
220+
LIBUSB_1_0=""
217221
if test "x$have_libusb_1_0" = xyes && test "x$enabled_libusb_1_0" = xyes; then
218222
case $target in
219223
*-*-darwin*)
@@ -247,11 +251,13 @@ if test "x$have_libusb_1_0" = xyes && test "x$enabled_libusb_1_0" = xyes; then
247251
AC_DEFINE([HAVE_LIBUSB_1_0])
248252
AC_CHECK_HEADERS([libusb.h])
249253
fi
250-
AC_SUBST(LIBUSB_1_0, $LIBUSB_1_0)
254+
AC_SUBST([LIBUSB_1_0])
251255

252256
AH_TEMPLATE([HAVE_LIBHIDAPI],
253257
[Define if HID support is enabled via libhidapi])
254-
AC_SEARCH_LIBS([hid_init], [hidapi hidapi-libusb hidapi-hidraw], [have_libhidapi=yes])
258+
AC_SEARCH_LIBS([hid_init], [hidapi hidapi-libusb hidapi-hidraw],
259+
[have_libhidapi=yes], [have_libhidapi=no])
260+
LIBHIDAPI=""
255261
if test "x$have_libhidapi" = xyes; then
256262
case $target in
257263
*-*-darwin*)
@@ -264,11 +270,13 @@ if test "x$have_libhidapi" = xyes; then
264270
AC_DEFINE([HAVE_LIBHIDAPI])
265271
AC_CHECK_HEADERS([hidapi/hidapi.h])
266272
fi
267-
AC_SUBST(LIBHIDAPI, $LIBHIDAPI)
273+
AC_SUBST([LIBHIDAPI])
268274

269275
AH_TEMPLATE([HAVE_LIBSERIALPORT],
270276
[Define if libserialport is found])
271-
AC_CHECK_LIB([serialport], [sp_open], [have_libserialport=yes])
277+
AC_CHECK_LIB([serialport], [sp_open],
278+
[have_libserialport=yes], [have_libserialport=no])
279+
LIBSERIALPORT=""
272280
if test "x$have_libserialport" = xyes; then
273281
case $target in
274282
*)
@@ -278,40 +286,50 @@ if test "x$have_libserialport" = xyes; then
278286
AC_DEFINE([HAVE_LIBSERIALPORT])
279287
AC_CHECK_HEADERS([libserialport.h])
280288
fi
281-
AC_SUBST(LIBSERIALPORT, $LIBSERIALPORT)
289+
AC_SUBST([LIBSERIALPORT])
282290

283291
AH_TEMPLATE([HAVE_LIBFTDI1],
284292
[Define if FTDI support is enabled via libftdi1])
285293
AH_TEMPLATE([HAVE_LIBFTDI],
286294
[Define if FTDI support is enabled via libftdi])
287295
AH_TEMPLATE([HAVE_LIBFTDI_TYPE_232H],
288296
[Define if libftdi supports FT232H, libftdi version >= 0.20])
289-
AC_CHECK_LIB([ftdi1], [ftdi_new], [have_libftdi1=yes], [], [$LIBUSB_1_0])
290-
AC_CHECK_LIB([ftdi], [ftdi_usb_get_strings], [have_libftdi=yes], [], [-lusb])
297+
AC_CHECK_LIB([ftdi1], [ftdi_new],
298+
[have_libftdi1=yes], [have_libftdi1=no], [$LIBUSB_1_0])
299+
AC_CHECK_LIB([ftdi], [ftdi_usb_get_strings],
300+
[have_libftdi=yes], [have_libftdi=no], [-lusb])
301+
LIBFTDI=""
302+
LIBFTDI1=""
291303
if test "x$have_libftdi1" = xyes; then
292304
LIBFTDI1="-lftdi1"
293305
AC_DEFINE([HAVE_LIBFTDI1])
294-
AC_SUBST(LIBFTDI1, $LIBFTDI1)
306+
AC_SUBST([LIBFTDI1])
295307
LIBS="${LIBS} ${LIBFTDI1}"
296-
AC_CHECK_FUNCS(ftdi_tcioflush)
308+
AC_CHECK_FUNCS([ftdi_tcioflush])
297309
else
298310
if test "x$have_libftdi" = xyes; then
299311
LIBFTDI="-lftdi -lusb"
300312
AC_DEFINE([HAVE_LIBFTDI])
301-
AC_SUBST(LIBFTDI, $LIBFTDI)
302-
AC_CHECK_DECL(TYPE_232H,[have_libftdi_FT232H=yes], [], [[#include <ftdi.h>]])
313+
AC_SUBST([LIBFTDI])
314+
AC_CHECK_DECL([TYPE_232H],
315+
[have_libftdi_FT232H=yes],
316+
[have_libftdi_FT232H=no],
317+
[[#include <ftdi.h>]])
303318
if test "x$have_libftdi_FT232H" = xyes; then
304319
AC_DEFINE([HAVE_LIBFTDI_TYPE_232H])
305320
fi
306321
fi
307322
fi
323+
308324
AC_CHECK_HEADERS([pthread.h])
309-
# as there exits header file only pthread implementations for Windows, check if we have a library
310-
AC_CHECK_LIB([pthread], [pthread_create], [have_pthread=yes])
325+
# as there exist header file only pthread implementations for Windows, check if we have a library
326+
AC_CHECK_LIB([pthread], [pthread_create], [have_pthread=yes], [have_pthread=no])
327+
LIBPTHREAD=""
311328
if test "x$have_pthread" = xyes; then
312329
LIBPTHREAD="-lpthread"
313330
fi
314-
AC_SUBST(LIBPTHREAD, $LIBPTHREAD)
331+
AC_SUBST([LIBPTHREAD])
332+
315333
# Checks for header files.
316334
AC_CHECK_HEADERS([limits.h stdlib.h string.h])
317335
AC_CHECK_HEADERS([fcntl.h sys/ioctl.h sys/time.h termios.h unistd.h])
@@ -330,6 +348,8 @@ AC_CHECK_FUNCS([memset select strcasecmp strdup strerror strncasecmp strtol strt
330348

331349
AC_MSG_CHECKING([for a Win32 HID library])
332350
SAVED_LIBS="${LIBS}"
351+
LIBHID=""
352+
HIDINCLUDE=""
333353
case $target in
334354
*-*-mingw32* | *-*-cygwin* | *-*-windows*)
335355
LIBHID="-lhid -lsetupapi"
@@ -361,7 +381,7 @@ else
361381
LIBHID=""
362382
fi
363383
LIBS="${SAVED_LIBS}"
364-
AC_SUBST(LIBHID, $LIBHID)
384+
AC_SUBST([LIBHID])
365385

366386
# Check for types
367387

@@ -379,7 +399,7 @@ AC_ARG_ENABLE(
379399
[case "${enableval}" in
380400
yes) versioned_doc=yes ;;
381401
no) versioned_doc=no ;;
382-
*) AC_MSG_ERROR(bad value ${enableval} for versioned-doc option) ;;
402+
*) AC_MSG_ERROR([bad value ${enableval} for versioned-doc option]) ;;
383403
esac],
384404
[versioned_doc=yes])
385405

@@ -388,6 +408,7 @@ if test "x$versioned_doc" = "xyes"; then
388408
else
389409
DOC_INST_DIR='$(DESTDIR)$(datadir)/doc/avrdude'
390410
fi
411+
AC_SUBST([DOC_INST_DIR])
391412

392413
AC_ARG_ENABLE(
393414
[doc],
@@ -396,7 +417,7 @@ AC_ARG_ENABLE(
396417
[case "${enableval}" in
397418
yes) enabled_doc=yes ;;
398419
no) enabled_doc=no ;;
399-
*) AC_MSG_ERROR(bad value ${enableval} for disable-doc option) ;;
420+
*) AC_MSG_ERROR([bad value ${enableval} for disable-doc option]) ;;
400421
esac],
401422
[enabled_doc=no])
402423

@@ -407,18 +428,18 @@ AC_ARG_ENABLE(
407428
[case "${enableval}" in
408429
yes) enabled_parport=yes ;;
409430
no) enabled_parport=no ;;
410-
*) AC_MSG_ERROR(bad value ${enableval} for enable-parport option) ;;
431+
*) AC_MSG_ERROR([bad value ${enableval} for enable-parport option]) ;;
411432
esac],
412433
[enabled_parport=no])
413-
434+
414435
AC_ARG_ENABLE(
415436
[linuxgpio],
416437
AS_HELP_STRING([--enable-linuxgpio],
417438
[Enable the Linux sysfs GPIO interface programmer type]),
418439
[case "${enableval}" in
419440
yes) enabled_linuxgpio=yes ;;
420441
no) enabled_linuxgpio=no ;;
421-
*) AC_MSG_ERROR(bad value ${enableval} for enable-linuxgpio option) ;;
442+
*) AC_MSG_ERROR([bad value ${enableval} for enable-linuxgpio option]) ;;
422443
esac],
423444
[enabled_linuxgpio=no])
424445

@@ -429,21 +450,18 @@ AC_ARG_ENABLE(
429450
[case "${enableval}" in
430451
yes) enabled_linuxspi=yes ;;
431452
no) enabled_linuxspi=no ;;
432-
*) AC_MSG_ERROR(bad value ${enableval} for enable-linuxspi option) ;;
453+
*) AC_MSG_ERROR([bad value ${enableval} for enable-linuxspi option]) ;;
433454
esac],
434455
[enabled_linuxspi=no])
435456

436-
DIST_SUBDIRS_AC='doc'
457+
AC_SUBST([DIST_SUBDIRS_AC], [doc])
437458

438459
if test "x$enabled_doc" = xyes; then
439460
SUBDIRS_AC='doc'
440461
else
441462
SUBDIRS_AC=''
442463
fi
443-
444-
AC_SUBST(DOC_INST_DIR, $DOC_INST_DIR)
445-
AC_SUBST(SUBDIRS_AC, $SUBDIRS_AC)
446-
AC_SUBST(DIST_SUBDIRS_AC, $DIST_SUBDIRS_AC)
464+
AC_SUBST([SUBDIRS_AC])
447465

448466

449467
# Find the parallel serial device files based on target system
@@ -494,15 +512,15 @@ if test "x$enabled_parport" = xyes; then
494512
else
495513
AC_MSG_RESULT([$DEFAULT_PAR_PORT])
496514
fi
497-
AC_SUBST(DEFAULT_PAR_PORT, $DEFAULT_PAR_PORT)
515+
AC_SUBST([DEFAULT_PAR_PORT])
498516
fi
499517

500518
AC_MSG_CHECKING([for serial device])
501519
AC_MSG_RESULT([$DEFAULT_SER_PORT])
502-
AC_SUBST(DEFAULT_SER_PORT, $DEFAULT_SER_PORT)
520+
AC_SUBST([DEFAULT_SER_PORT])
503521

504522
if test "x$enabled_parport" = xyes; then
505-
AC_DEFINE(HAVE_PARPORT, 1, [parallel port access enabled])
523+
AC_DEFINE([HAVE_PARPORT], [1], [parallel port access enabled])
506524
confsubst="-e /^@HAVE_PARPORT_/d"
507525
else
508526
confsubst="-e /^@HAVE_PARPORT_BEGIN@/,/^@HAVE_PARPORT_END@/d"
@@ -517,26 +535,27 @@ if test "x$enabled_linuxgpio" = xyes; then
517535
else
518536
AC_MSG_RESULT([$DEFAULT_LINUXGPIO_PORT])
519537
fi
520-
AC_SUBST(DEFAULT_LINUXGPIO_PORT, $DEFAULT_LINUXGPIO_PORT)
538+
AC_SUBST([DEFAULT_LINUXGPIO_PORT])
521539
fi
522540

523541
if test "x$enabled_linuxgpio" = xyes; then
524-
AC_DEFINE(HAVE_LINUXGPIO, 1, [Linux sysfs GPIO support enabled])
542+
AC_DEFINE([HAVE_LINUXGPIO], [1], [Linux sysfs GPIO support enabled])
525543
confsubst="$confsubst -e /^@HAVE_LINUXGPIO_/d"
526544
else
527545
confsubst="$confsubst -e /^@HAVE_LINUXGPIO_BEGIN@/,/^@HAVE_LINUXGPIO_END@/d"
528546
fi
529547

530548

531549
if test "x$enabled_linuxspi" = xyes; then
532-
AC_DEFINE(HAVE_LINUXSPI, 1, [Linux SPI support enabled])
550+
AC_DEFINE([HAVE_LINUXSPI], [1], [Linux SPI support enabled])
533551
confsubst="$confsubst -e /^@HAVE_LINUXSPI_/d"
534552
else
535553
confsubst="$confsubst -e /^@HAVE_LINUXSPI_BEGIN@/,/^@HAVE_LINUXSPI_END@/d"
536554
fi
537555

538556

539557
# If we are compiling with gcc, enable all warnings and make warnings errors.
558+
ENABLE_WARNINGS=""
540559
if test "x$GCC" = xyes; then
541560
ENABLE_WARNINGS="-Wall -Wextra -Wno-unused-parameter"
542561

@@ -561,7 +580,7 @@ if test "x$GCC" = xyes; then
561580
ENABLE_WARNINGS="$ENABLE_WARNINGS -Wno-pointer-sign"
562581
fi
563582
fi
564-
AC_SUBST(ENABLE_WARNINGS,$ENABLE_WARNINGS)
583+
AC_SUBST([ENABLE_WARNINGS])
565584

566585
# See if we need to drop into the windows subdir.
567586
case $target in

0 commit comments

Comments
 (0)