Skip to content

Commit dd9e4d2

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 var values 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 cc94578 commit dd9e4d2

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
@@ -129,6 +129,7 @@ AC_CHECK_LIB([readline], [readline], [dnl
129129
AH_TEMPLATE([HAVE_LIBELF],
130130
[Define if ELF support is enabled via libelf])
131131
AC_CHECK_LIB([elf], [elf_getshdrstrndx], [have_libelf=yes])
132+
LIBELF=""
132133
if test "x$have_libelf" = xyes; then
133134
case $target in
134135
*)
@@ -138,13 +139,14 @@ if test "x$have_libelf" = xyes; then
138139
AC_DEFINE([HAVE_LIBELF])
139140
AC_CHECK_HEADERS([libelf.h libelf/libelf.h])
140141
fi
141-
AC_SUBST(LIBELF, $LIBELF)
142+
AC_SUBST([LIBELF])
142143

143144
AC_SEARCH_LIBS([gethostent], [nsl])
144145
AC_SEARCH_LIBS([setsockopt], [socket])
145146
AH_TEMPLATE([HAVE_LIBUSB],
146147
[Define if USB support is enabled via libusb])
147148
AC_CHECK_LIB([usb], [usb_get_string_simple], [have_libusb=yes])
149+
LIBUSB=""
148150
if test "x$have_libusb" = xyes; then
149151
case $target in
150152
*-*-darwin*)
@@ -158,7 +160,7 @@ if test "x$have_libusb" = xyes; then
158160
AC_CHECK_HEADERS([usb.h])
159161
AC_CHECK_HEADERS([lusb0_usb.h])
160162
fi
161-
AC_SUBST(LIBUSB, $LIBUSB)
163+
AC_SUBST([LIBUSB])
162164

163165
AC_ARG_ENABLE(
164166
[libusb_1_0],
@@ -167,13 +169,15 @@ AC_ARG_ENABLE(
167169
[case "${enableval}" in
168170
yes) enabled_libusb_1_0=yes ;;
169171
no) enabled_libusb_1_0=no ;;
170-
*) AC_MSG_ERROR(bad value ${enableval} for enable-libusb_1_0 option) ;;
172+
*) AC_MSG_ERROR([bad value ${enableval} for enable-libusb_1_0 option]) ;;
171173
esac],
172174
[enabled_libusb_1_0=yes])
173175

176+
have_libusb_1_0=no
174177
AH_TEMPLATE([HAVE_LIBUSB_1_0],
175178
[Define if USB support is enabled via libusb 1.0])
176179
AC_CHECK_LIB([usb-1.0], [libusb_init], [have_libusb_1_0=yes])
180+
LIBUSB_1_0=""
177181
if test "x$have_libusb_1_0" = xyes && test "x$enabled_libusb_1_0" = xyes; then
178182
case $target in
179183
*-*-darwin*)
@@ -207,11 +211,13 @@ if test "x$have_libusb_1_0" = xyes && test "x$enabled_libusb_1_0" = xyes; then
207211
AC_DEFINE([HAVE_LIBUSB_1_0])
208212
AC_CHECK_HEADERS([libusb.h])
209213
fi
210-
AC_SUBST(LIBUSB_1_0, $LIBUSB_1_0)
214+
AC_SUBST([LIBUSB_1_0])
211215

212216
AH_TEMPLATE([HAVE_LIBHIDAPI],
213217
[Define if HID support is enabled via libhidapi])
214-
AC_SEARCH_LIBS([hid_init], [hidapi hidapi-libusb hidapi-hidraw], [have_libhidapi=yes])
218+
AC_SEARCH_LIBS([hid_init], [hidapi hidapi-libusb hidapi-hidraw],
219+
[have_libhidapi=yes], [have_libhidapi=no])
220+
LIBHIDAPI=""
215221
if test "x$have_libhidapi" = xyes; then
216222
case $target in
217223
*-*-darwin*)
@@ -224,11 +230,13 @@ if test "x$have_libhidapi" = xyes; then
224230
AC_DEFINE([HAVE_LIBHIDAPI])
225231
AC_CHECK_HEADERS([hidapi/hidapi.h])
226232
fi
227-
AC_SUBST(LIBHIDAPI, $LIBHIDAPI)
233+
AC_SUBST([LIBHIDAPI])
228234

229235
AH_TEMPLATE([HAVE_LIBSERIALPORT],
230236
[Define if libserialport is found])
231-
AC_CHECK_LIB([serialport], [sp_open], [have_libserialport=yes])
237+
AC_CHECK_LIB([serialport], [sp_open],
238+
[have_libserialport=yes], [have_libserialport=no])
239+
LIBSERIALPORT=""
232240
if test "x$have_libserialport" = xyes; then
233241
case $target in
234242
*)
@@ -238,40 +246,50 @@ if test "x$have_libserialport" = xyes; then
238246
AC_DEFINE([HAVE_LIBSERIALPORT])
239247
AC_CHECK_HEADERS([libserialport.h])
240248
fi
241-
AC_SUBST(LIBSERIALPORT, $LIBSERIALPORT)
249+
AC_SUBST([LIBSERIALPORT])
242250

243251
AH_TEMPLATE([HAVE_LIBFTDI1],
244252
[Define if FTDI support is enabled via libftdi1])
245253
AH_TEMPLATE([HAVE_LIBFTDI],
246254
[Define if FTDI support is enabled via libftdi])
247255
AH_TEMPLATE([HAVE_LIBFTDI_TYPE_232H],
248256
[Define if libftdi supports FT232H, libftdi version >= 0.20])
249-
AC_CHECK_LIB([ftdi1], [ftdi_new], [have_libftdi1=yes], [], [$LIBUSB_1_0])
250-
AC_CHECK_LIB([ftdi], [ftdi_usb_get_strings], [have_libftdi=yes], [], [-lusb])
257+
AC_CHECK_LIB([ftdi1], [ftdi_new],
258+
[have_libftdi1=yes], [have_libftdi1=no], [$LIBUSB_1_0])
259+
AC_CHECK_LIB([ftdi], [ftdi_usb_get_strings],
260+
[have_libftdi=yes], [have_libftdi=no], [-lusb])
261+
LIBFTDI=""
262+
LIBFTDI1=""
251263
if test "x$have_libftdi1" = xyes; then
252264
LIBFTDI1="-lftdi1"
253265
AC_DEFINE([HAVE_LIBFTDI1])
254-
AC_SUBST(LIBFTDI1, $LIBFTDI1)
266+
AC_SUBST([LIBFTDI1])
255267
LIBS="${LIBS} ${LIBFTDI1}"
256-
AC_CHECK_FUNCS(ftdi_tcioflush)
268+
AC_CHECK_FUNCS([ftdi_tcioflush])
257269
else
258270
if test "x$have_libftdi" = xyes; then
259271
LIBFTDI="-lftdi -lusb"
260272
AC_DEFINE([HAVE_LIBFTDI])
261-
AC_SUBST(LIBFTDI, $LIBFTDI)
262-
AC_CHECK_DECL(TYPE_232H,[have_libftdi_FT232H=yes], [], [[#include <ftdi.h>]])
273+
AC_SUBST([LIBFTDI])
274+
AC_CHECK_DECL([TYPE_232H],
275+
[have_libftdi_FT232H=yes],
276+
[have_libftdi_FT232H=no],
277+
[[#include <ftdi.h>]])
263278
if test "x$have_libftdi_FT232H" = xyes; then
264279
AC_DEFINE([HAVE_LIBFTDI_TYPE_232H])
265280
fi
266281
fi
267282
fi
283+
268284
AC_CHECK_HEADERS([pthread.h])
269-
# as there exits header file only pthread implementations for Windows, check if we have a library
270-
AC_CHECK_LIB([pthread], [pthread_create], [have_pthread=yes])
285+
# as there exist header file only pthread implementations for Windows, check if we have a library
286+
AC_CHECK_LIB([pthread], [pthread_create], [have_pthread=yes], [have_pthread=no])
287+
LIBPTHREAD=""
271288
if test "x$have_pthread" = xyes; then
272289
LIBPTHREAD="-lpthread"
273290
fi
274-
AC_SUBST(LIBPTHREAD, $LIBPTHREAD)
291+
AC_SUBST([LIBPTHREAD])
292+
275293
# Checks for header files.
276294
AC_CHECK_HEADERS([limits.h stdlib.h string.h])
277295
AC_CHECK_HEADERS([fcntl.h sys/ioctl.h sys/time.h termios.h unistd.h])
@@ -290,6 +308,8 @@ AC_CHECK_FUNCS([memset select strcasecmp strdup strerror strncasecmp strtol strt
290308

291309
AC_MSG_CHECKING([for a Win32 HID library])
292310
SAVED_LIBS="${LIBS}"
311+
LIBHID=""
312+
HIDINCLUDE=""
293313
case $target in
294314
*-*-mingw32* | *-*-cygwin* | *-*-windows*)
295315
LIBHID="-lhid -lsetupapi"
@@ -321,7 +341,7 @@ else
321341
LIBHID=""
322342
fi
323343
LIBS="${SAVED_LIBS}"
324-
AC_SUBST(LIBHID, $LIBHID)
344+
AC_SUBST([LIBHID])
325345

326346
# Check for types
327347

@@ -339,7 +359,7 @@ AC_ARG_ENABLE(
339359
[case "${enableval}" in
340360
yes) versioned_doc=yes ;;
341361
no) versioned_doc=no ;;
342-
*) AC_MSG_ERROR(bad value ${enableval} for versioned-doc option) ;;
362+
*) AC_MSG_ERROR([bad value ${enableval} for versioned-doc option]) ;;
343363
esac],
344364
[versioned_doc=yes])
345365

@@ -348,6 +368,7 @@ if test "x$versioned_doc" = "xyes"; then
348368
else
349369
DOC_INST_DIR='$(DESTDIR)$(datadir)/doc/avrdude'
350370
fi
371+
AC_SUBST([DOC_INST_DIR])
351372

352373
AC_ARG_ENABLE(
353374
[doc],
@@ -356,7 +377,7 @@ AC_ARG_ENABLE(
356377
[case "${enableval}" in
357378
yes) enabled_doc=yes ;;
358379
no) enabled_doc=no ;;
359-
*) AC_MSG_ERROR(bad value ${enableval} for disable-doc option) ;;
380+
*) AC_MSG_ERROR([bad value ${enableval} for disable-doc option]) ;;
360381
esac],
361382
[enabled_doc=no])
362383

@@ -367,18 +388,18 @@ AC_ARG_ENABLE(
367388
[case "${enableval}" in
368389
yes) enabled_parport=yes ;;
369390
no) enabled_parport=no ;;
370-
*) AC_MSG_ERROR(bad value ${enableval} for enable-parport option) ;;
391+
*) AC_MSG_ERROR([bad value ${enableval} for enable-parport option]) ;;
371392
esac],
372393
[enabled_parport=no])
373-
394+
374395
AC_ARG_ENABLE(
375396
[linuxgpio],
376397
AS_HELP_STRING([--enable-linuxgpio],
377398
[Enable the Linux sysfs GPIO interface programmer type]),
378399
[case "${enableval}" in
379400
yes) enabled_linuxgpio=yes ;;
380401
no) enabled_linuxgpio=no ;;
381-
*) AC_MSG_ERROR(bad value ${enableval} for enable-linuxgpio option) ;;
402+
*) AC_MSG_ERROR([bad value ${enableval} for enable-linuxgpio option]) ;;
382403
esac],
383404
[enabled_linuxgpio=no])
384405

@@ -389,21 +410,18 @@ AC_ARG_ENABLE(
389410
[case "${enableval}" in
390411
yes) enabled_linuxspi=yes ;;
391412
no) enabled_linuxspi=no ;;
392-
*) AC_MSG_ERROR(bad value ${enableval} for enable-linuxspi option) ;;
413+
*) AC_MSG_ERROR([bad value ${enableval} for enable-linuxspi option]) ;;
393414
esac],
394415
[enabled_linuxspi=no])
395416

396-
DIST_SUBDIRS_AC='doc'
417+
AC_SUBST([DIST_SUBDIRS_AC], [doc])
397418

398419
if test "x$enabled_doc" = xyes; then
399420
SUBDIRS_AC='doc'
400421
else
401422
SUBDIRS_AC=''
402423
fi
403-
404-
AC_SUBST(DOC_INST_DIR, $DOC_INST_DIR)
405-
AC_SUBST(SUBDIRS_AC, $SUBDIRS_AC)
406-
AC_SUBST(DIST_SUBDIRS_AC, $DIST_SUBDIRS_AC)
424+
AC_SUBST([SUBDIRS_AC])
407425

408426

409427
# Find the parallel serial device files based on target system
@@ -454,15 +472,15 @@ if test "x$enabled_parport" = xyes; then
454472
else
455473
AC_MSG_RESULT([$DEFAULT_PAR_PORT])
456474
fi
457-
AC_SUBST(DEFAULT_PAR_PORT, $DEFAULT_PAR_PORT)
475+
AC_SUBST([DEFAULT_PAR_PORT])
458476
fi
459477

460478
AC_MSG_CHECKING([for serial device])
461479
AC_MSG_RESULT([$DEFAULT_SER_PORT])
462-
AC_SUBST(DEFAULT_SER_PORT, $DEFAULT_SER_PORT)
480+
AC_SUBST([DEFAULT_SER_PORT])
463481

464482
if test "x$enabled_parport" = xyes; then
465-
AC_DEFINE(HAVE_PARPORT, 1, [parallel port access enabled])
483+
AC_DEFINE([HAVE_PARPORT], [1], [parallel port access enabled])
466484
confsubst="-e /^@HAVE_PARPORT_/d"
467485
else
468486
confsubst="-e /^@HAVE_PARPORT_BEGIN@/,/^@HAVE_PARPORT_END@/d"
@@ -477,26 +495,27 @@ if test "x$enabled_linuxgpio" = xyes; then
477495
else
478496
AC_MSG_RESULT([$DEFAULT_LINUXGPIO_PORT])
479497
fi
480-
AC_SUBST(DEFAULT_LINUXGPIO_PORT, $DEFAULT_LINUXGPIO_PORT)
498+
AC_SUBST([DEFAULT_LINUXGPIO_PORT])
481499
fi
482500

483501
if test "x$enabled_linuxgpio" = xyes; then
484-
AC_DEFINE(HAVE_LINUXGPIO, 1, [Linux sysfs GPIO support enabled])
502+
AC_DEFINE([HAVE_LINUXGPIO], [1], [Linux sysfs GPIO support enabled])
485503
confsubst="$confsubst -e /^@HAVE_LINUXGPIO_/d"
486504
else
487505
confsubst="$confsubst -e /^@HAVE_LINUXGPIO_BEGIN@/,/^@HAVE_LINUXGPIO_END@/d"
488506
fi
489507

490508

491509
if test "x$enabled_linuxspi" = xyes; then
492-
AC_DEFINE(HAVE_LINUXSPI, 1, [Linux SPI support enabled])
510+
AC_DEFINE([HAVE_LINUXSPI], [1], [Linux SPI support enabled])
493511
confsubst="$confsubst -e /^@HAVE_LINUXSPI_/d"
494512
else
495513
confsubst="$confsubst -e /^@HAVE_LINUXSPI_BEGIN@/,/^@HAVE_LINUXSPI_END@/d"
496514
fi
497515

498516

499517
# If we are compiling with gcc, enable all warnings and make warnings errors.
518+
ENABLE_WARNINGS=""
500519
if test "x$GCC" = xyes; then
501520
ENABLE_WARNINGS="-Wall -Wextra -Wno-unused-parameter"
502521

@@ -521,7 +540,7 @@ if test "x$GCC" = xyes; then
521540
ENABLE_WARNINGS="$ENABLE_WARNINGS -Wno-pointer-sign"
522541
fi
523542
fi
524-
AC_SUBST(ENABLE_WARNINGS,$ENABLE_WARNINGS)
543+
AC_SUBST([ENABLE_WARNINGS])
525544

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

0 commit comments

Comments
 (0)