Skip to content

Commit 2e6d1af

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 fcb6f74 commit 2e6d1af

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
@@ -167,6 +167,7 @@ AC_CHECK_LIB([readline], [readline], [dnl
167167
AH_TEMPLATE([HAVE_LIBELF],
168168
[Define if ELF support is enabled via libelf])
169169
AC_CHECK_LIB([elf], [elf_getshdrstrndx], [have_libelf=yes])
170+
LIBELF=""
170171
if test "x$have_libelf" = xyes; then
171172
case $target in
172173
*)
@@ -176,13 +177,14 @@ if test "x$have_libelf" = xyes; then
176177
AC_DEFINE([HAVE_LIBELF])
177178
AC_CHECK_HEADERS([libelf.h libelf/libelf.h])
178179
fi
179-
AC_SUBST(LIBELF, $LIBELF)
180+
AC_SUBST([LIBELF])
180181

181182
AC_SEARCH_LIBS([gethostent], [nsl])
182183
AC_SEARCH_LIBS([setsockopt], [socket])
183184
AH_TEMPLATE([HAVE_LIBUSB],
184185
[Define if USB support is enabled via libusb])
185186
AC_CHECK_LIB([usb], [usb_get_string_simple], [have_libusb=yes])
187+
LIBUSB=""
186188
if test "x$have_libusb" = xyes; then
187189
case $target in
188190
*-*-darwin*)
@@ -196,7 +198,7 @@ if test "x$have_libusb" = xyes; then
196198
AC_CHECK_HEADERS([usb.h])
197199
AC_CHECK_HEADERS([lusb0_usb.h])
198200
fi
199-
AC_SUBST(LIBUSB, $LIBUSB)
201+
AC_SUBST([LIBUSB])
200202

201203
AC_ARG_ENABLE(
202204
[libusb_1_0],
@@ -205,13 +207,15 @@ AC_ARG_ENABLE(
205207
[case "${enableval}" in
206208
yes) enabled_libusb_1_0=yes ;;
207209
no) enabled_libusb_1_0=no ;;
208-
*) AC_MSG_ERROR(bad value ${enableval} for enable-libusb_1_0 option) ;;
210+
*) AC_MSG_ERROR([bad value ${enableval} for enable-libusb_1_0 option]) ;;
209211
esac],
210212
[enabled_libusb_1_0=yes])
211213

214+
have_libusb_1_0=no
212215
AH_TEMPLATE([HAVE_LIBUSB_1_0],
213216
[Define if USB support is enabled via libusb 1.0])
214217
AC_CHECK_LIB([usb-1.0], [libusb_init], [have_libusb_1_0=yes])
218+
LIBUSB_1_0=""
215219
if test "x$have_libusb_1_0" = xyes && test "x$enabled_libusb_1_0" = xyes; then
216220
case $target in
217221
*-*-darwin*)
@@ -245,11 +249,13 @@ if test "x$have_libusb_1_0" = xyes && test "x$enabled_libusb_1_0" = xyes; then
245249
AC_DEFINE([HAVE_LIBUSB_1_0])
246250
AC_CHECK_HEADERS([libusb.h])
247251
fi
248-
AC_SUBST(LIBUSB_1_0, $LIBUSB_1_0)
252+
AC_SUBST([LIBUSB_1_0])
249253

250254
AH_TEMPLATE([HAVE_LIBHIDAPI],
251255
[Define if HID support is enabled via libhidapi])
252-
AC_SEARCH_LIBS([hid_init], [hidapi hidapi-libusb hidapi-hidraw], [have_libhidapi=yes])
256+
AC_SEARCH_LIBS([hid_init], [hidapi hidapi-libusb hidapi-hidraw],
257+
[have_libhidapi=yes], [have_libhidapi=no])
258+
LIBHIDAPI=""
253259
if test "x$have_libhidapi" = xyes; then
254260
case $target in
255261
*-*-darwin*)
@@ -262,11 +268,13 @@ if test "x$have_libhidapi" = xyes; then
262268
AC_DEFINE([HAVE_LIBHIDAPI])
263269
AC_CHECK_HEADERS([hidapi/hidapi.h])
264270
fi
265-
AC_SUBST(LIBHIDAPI, $LIBHIDAPI)
271+
AC_SUBST([LIBHIDAPI])
266272

267273
AH_TEMPLATE([HAVE_LIBSERIALPORT],
268274
[Define if libserialport is found])
269-
AC_CHECK_LIB([serialport], [sp_open], [have_libserialport=yes])
275+
AC_CHECK_LIB([serialport], [sp_open],
276+
[have_libserialport=yes], [have_libserialport=no])
277+
LIBSERIALPORT=""
270278
if test "x$have_libserialport" = xyes; then
271279
case $target in
272280
*)
@@ -276,40 +284,50 @@ if test "x$have_libserialport" = xyes; then
276284
AC_DEFINE([HAVE_LIBSERIALPORT])
277285
AC_CHECK_HEADERS([libserialport.h])
278286
fi
279-
AC_SUBST(LIBSERIALPORT, $LIBSERIALPORT)
287+
AC_SUBST([LIBSERIALPORT])
280288

281289
AH_TEMPLATE([HAVE_LIBFTDI1],
282290
[Define if FTDI support is enabled via libftdi1])
283291
AH_TEMPLATE([HAVE_LIBFTDI],
284292
[Define if FTDI support is enabled via libftdi])
285293
AH_TEMPLATE([HAVE_LIBFTDI_TYPE_232H],
286294
[Define if libftdi supports FT232H, libftdi version >= 0.20])
287-
AC_CHECK_LIB([ftdi1], [ftdi_new], [have_libftdi1=yes], [], [$LIBUSB_1_0])
288-
AC_CHECK_LIB([ftdi], [ftdi_usb_get_strings], [have_libftdi=yes], [], [-lusb])
295+
AC_CHECK_LIB([ftdi1], [ftdi_new],
296+
[have_libftdi1=yes], [have_libftdi1=no], [$LIBUSB_1_0])
297+
AC_CHECK_LIB([ftdi], [ftdi_usb_get_strings],
298+
[have_libftdi=yes], [have_libftdi=no], [-lusb])
299+
LIBFTDI=""
300+
LIBFTDI1=""
289301
if test "x$have_libftdi1" = xyes; then
290302
LIBFTDI1="-lftdi1"
291303
AC_DEFINE([HAVE_LIBFTDI1])
292-
AC_SUBST(LIBFTDI1, $LIBFTDI1)
304+
AC_SUBST([LIBFTDI1])
293305
LIBS="${LIBS} ${LIBFTDI1}"
294-
AC_CHECK_FUNCS(ftdi_tcioflush)
306+
AC_CHECK_FUNCS([ftdi_tcioflush])
295307
else
296308
if test "x$have_libftdi" = xyes; then
297309
LIBFTDI="-lftdi -lusb"
298310
AC_DEFINE([HAVE_LIBFTDI])
299-
AC_SUBST(LIBFTDI, $LIBFTDI)
300-
AC_CHECK_DECL(TYPE_232H,[have_libftdi_FT232H=yes], [], [[#include <ftdi.h>]])
311+
AC_SUBST([LIBFTDI])
312+
AC_CHECK_DECL([TYPE_232H],
313+
[have_libftdi_FT232H=yes],
314+
[have_libftdi_FT232H=no],
315+
[[#include <ftdi.h>]])
301316
if test "x$have_libftdi_FT232H" = xyes; then
302317
AC_DEFINE([HAVE_LIBFTDI_TYPE_232H])
303318
fi
304319
fi
305320
fi
321+
306322
AC_CHECK_HEADERS([pthread.h])
307-
# as there exits header file only pthread implementations for Windows, check if we have a library
308-
AC_CHECK_LIB([pthread], [pthread_create], [have_pthread=yes])
323+
# as there exist header file only pthread implementations for Windows, check if we have a library
324+
AC_CHECK_LIB([pthread], [pthread_create], [have_pthread=yes], [have_pthread=no])
325+
LIBPTHREAD=""
309326
if test "x$have_pthread" = xyes; then
310327
LIBPTHREAD="-lpthread"
311328
fi
312-
AC_SUBST(LIBPTHREAD, $LIBPTHREAD)
329+
AC_SUBST([LIBPTHREAD])
330+
313331
# Checks for header files.
314332
AC_CHECK_HEADERS([limits.h stdlib.h string.h])
315333
AC_CHECK_HEADERS([fcntl.h sys/ioctl.h sys/time.h termios.h unistd.h])
@@ -328,6 +346,8 @@ AC_CHECK_FUNCS([memset select strcasecmp strdup strerror strncasecmp strtol strt
328346

329347
AC_MSG_CHECKING([for a Win32 HID library])
330348
SAVED_LIBS="${LIBS}"
349+
LIBHID=""
350+
HIDINCLUDE=""
331351
case $target in
332352
*-*-mingw32* | *-*-cygwin* | *-*-windows*)
333353
LIBHID="-lhid -lsetupapi"
@@ -359,7 +379,7 @@ else
359379
LIBHID=""
360380
fi
361381
LIBS="${SAVED_LIBS}"
362-
AC_SUBST(LIBHID, $LIBHID)
382+
AC_SUBST([LIBHID])
363383

364384
# Check for types
365385

@@ -377,7 +397,7 @@ AC_ARG_ENABLE(
377397
[case "${enableval}" in
378398
yes) versioned_doc=yes ;;
379399
no) versioned_doc=no ;;
380-
*) AC_MSG_ERROR(bad value ${enableval} for versioned-doc option) ;;
400+
*) AC_MSG_ERROR([bad value ${enableval} for versioned-doc option]) ;;
381401
esac],
382402
[versioned_doc=yes])
383403

@@ -386,6 +406,7 @@ if test "x$versioned_doc" = "xyes"; then
386406
else
387407
DOC_INST_DIR='$(DESTDIR)$(datadir)/doc/avrdude'
388408
fi
409+
AC_SUBST([DOC_INST_DIR])
389410

390411
AC_ARG_ENABLE(
391412
[doc],
@@ -394,7 +415,7 @@ AC_ARG_ENABLE(
394415
[case "${enableval}" in
395416
yes) enabled_doc=yes ;;
396417
no) enabled_doc=no ;;
397-
*) AC_MSG_ERROR(bad value ${enableval} for disable-doc option) ;;
418+
*) AC_MSG_ERROR([bad value ${enableval} for disable-doc option]) ;;
398419
esac],
399420
[enabled_doc=no])
400421

@@ -405,18 +426,18 @@ AC_ARG_ENABLE(
405426
[case "${enableval}" in
406427
yes) enabled_parport=yes ;;
407428
no) enabled_parport=no ;;
408-
*) AC_MSG_ERROR(bad value ${enableval} for enable-parport option) ;;
429+
*) AC_MSG_ERROR([bad value ${enableval} for enable-parport option]) ;;
409430
esac],
410431
[enabled_parport=no])
411-
432+
412433
AC_ARG_ENABLE(
413434
[linuxgpio],
414435
AS_HELP_STRING([--enable-linuxgpio],
415436
[Enable the Linux sysfs GPIO interface programmer type]),
416437
[case "${enableval}" in
417438
yes) enabled_linuxgpio=yes ;;
418439
no) enabled_linuxgpio=no ;;
419-
*) AC_MSG_ERROR(bad value ${enableval} for enable-linuxgpio option) ;;
440+
*) AC_MSG_ERROR([bad value ${enableval} for enable-linuxgpio option]) ;;
420441
esac],
421442
[enabled_linuxgpio=no])
422443

@@ -427,21 +448,18 @@ AC_ARG_ENABLE(
427448
[case "${enableval}" in
428449
yes) enabled_linuxspi=yes ;;
429450
no) enabled_linuxspi=no ;;
430-
*) AC_MSG_ERROR(bad value ${enableval} for enable-linuxspi option) ;;
451+
*) AC_MSG_ERROR([bad value ${enableval} for enable-linuxspi option]) ;;
431452
esac],
432453
[enabled_linuxspi=no])
433454

434-
DIST_SUBDIRS_AC='doc'
455+
AC_SUBST([DIST_SUBDIRS_AC], [doc])
435456

436457
if test "x$enabled_doc" = xyes; then
437458
SUBDIRS_AC='doc'
438459
else
439460
SUBDIRS_AC=''
440461
fi
441-
442-
AC_SUBST(DOC_INST_DIR, $DOC_INST_DIR)
443-
AC_SUBST(SUBDIRS_AC, $SUBDIRS_AC)
444-
AC_SUBST(DIST_SUBDIRS_AC, $DIST_SUBDIRS_AC)
462+
AC_SUBST([SUBDIRS_AC])
445463

446464

447465
# Find the parallel serial device files based on target system
@@ -492,15 +510,15 @@ if test "x$enabled_parport" = xyes; then
492510
else
493511
AC_MSG_RESULT([$DEFAULT_PAR_PORT])
494512
fi
495-
AC_SUBST(DEFAULT_PAR_PORT, $DEFAULT_PAR_PORT)
513+
AC_SUBST([DEFAULT_PAR_PORT])
496514
fi
497515

498516
AC_MSG_CHECKING([for serial device])
499517
AC_MSG_RESULT([$DEFAULT_SER_PORT])
500-
AC_SUBST(DEFAULT_SER_PORT, $DEFAULT_SER_PORT)
518+
AC_SUBST([DEFAULT_SER_PORT])
501519

502520
if test "x$enabled_parport" = xyes; then
503-
AC_DEFINE(HAVE_PARPORT, 1, [parallel port access enabled])
521+
AC_DEFINE([HAVE_PARPORT], [1], [parallel port access enabled])
504522
confsubst="-e /^@HAVE_PARPORT_/d"
505523
else
506524
confsubst="-e /^@HAVE_PARPORT_BEGIN@/,/^@HAVE_PARPORT_END@/d"
@@ -515,26 +533,27 @@ if test "x$enabled_linuxgpio" = xyes; then
515533
else
516534
AC_MSG_RESULT([$DEFAULT_LINUXGPIO_PORT])
517535
fi
518-
AC_SUBST(DEFAULT_LINUXGPIO_PORT, $DEFAULT_LINUXGPIO_PORT)
536+
AC_SUBST([DEFAULT_LINUXGPIO_PORT])
519537
fi
520538

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

528546

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

536554

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

@@ -559,7 +578,7 @@ if test "x$GCC" = xyes; then
559578
ENABLE_WARNINGS="$ENABLE_WARNINGS -Wno-pointer-sign"
560579
fi
561580
fi
562-
AC_SUBST(ENABLE_WARNINGS,$ENABLE_WARNINGS)
581+
AC_SUBST([ENABLE_WARNINGS])
563582

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

0 commit comments

Comments
 (0)