Skip to content

Commit d26577c

Browse files
committed
Use GP_SLEEP_IF_TTY
Only sleep after configure warning message if the output goes to an interactive terminal (isatty()). This has the potential to significantly accelerate the time configure needs to run for non-default camlib sets in the cases where nobody is watching anyway.
1 parent eb63ef9 commit d26577c

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

libgphoto2_port/gphoto-m4/gp-camlibs.m4

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# gp-camlibs.m4 - define camlibs and camlib infrastructure -*- Autoconf -*-
2-
# serial 13
2+
# serial 14
33
dnl | Increment the above serial number every time you edit this file.
44
dnl | When it finds multiple m4 files with the same name,
55
dnl | aclocal will use the one with the highest serial.
@@ -163,7 +163,7 @@ AC_MSG_WARN([
163163
# * or even better, just build the standard set of camlibs. #
164164
#=====================================================================#
165165
])
166-
GP_SLEEP([5])
166+
GP_SLEEP_IF_TTY([5])
167167
])
168168
dnl
169169
dnl
@@ -248,7 +248,7 @@ AS_VAR_IF([gp_sh_with_camlibs], [canon], [dnl
248248
# driver to prevent unnecessary support requests. #
249249
#==============================================================#
250250
])
251-
GP_SLEEP([5])
251+
GP_SLEEP_IF_TTY([5])
252252
])dnl
253253
254254
dnl set -x
@@ -308,7 +308,7 @@ do
308308
# 'standard' instead. #
309309
#=============================================================#
310310
])
311-
GP_SLEEP([5])
311+
GP_SLEEP_IF_TTY([5])
312312
gp_camlib="standard"
313313
;;
314314
esac
@@ -438,7 +438,7 @@ AS_IF([test "x$gp_camlib_set_skipping" = "x"], [dnl
438438
# you insist on building these camlibs. #
439439
#=========================================================#
440440
])
441-
GP_SLEEP([5])
441+
GP_SLEEP_IF_TTY([5])
442442
])
443443
444444
GP_SET_SPACE_VAR([camlib-set], [gp_camlib_set])

libgphoto2_port/gphoto-m4/gp-progs.m4

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# gp-progs.m4 - look for certain well-known tools -*- Autoconf -*-
2-
# serial 13
2+
# serial 14
33
dnl | Increment the above serial number every time you edit this file.
44
dnl | When it finds multiple m4 files with the same name,
55
dnl | aclocal will use the one with the highest serial.
@@ -71,7 +71,7 @@ dnl ####################################################################
7171
m4_pattern_forbid([GP_PROG_SLEEP])dnl
7272
AC_DEFUN_ONCE([GP_PROG_SLEEP],[dnl
7373
AC_ARG_VAR([SLEEP], [sleep delay command])dnl
74-
AC_MSG_CHECKING([whether to sleep])
74+
AC_MSG_CHECKING([for sleep])
7575
AS_VAR_IF([SLEEP], [no], [dnl
7676
AC_MSG_RESULT([no])
7777
], [dnl

libgphoto2_port/gphoto-m4/gp-sleep.m4

+31-9
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,51 @@
11
# gp-sleep.m4 - look for the sleep(1) tool -*- Autoconf -*-
2-
# serial 13
2+
# serial 14
33
dnl | Increment the above serial number every time you edit this file.
44
dnl | When it finds multiple m4 files with the same name,
55
dnl | aclocal will use the one with the highest serial.
66
dnl
77
dnl ####################################################################
88
dnl GP_SLEEP(delay_in_whole_seconds)
9-
dnl If the SLEEP variable is set to "no" or empty or is unset,
10-
dnl do not sleep.
11-
dnl If the SLEEP variable is set to something else, run that something
12-
dnl else with the given delay value.
9+
dnl * If the SLEEP variable is set to "no" or empty or is unset,
10+
dnl do not sleep.
11+
dnl * If stdout (FD 1) is not a TTY (!isatty(1)), do not sleep.
12+
dnl * Otherwise, run ${SLEEP} with the given delay value argument.
1313
dnl ####################################################################
14+
dnl
15+
dnl ####################################################################
16+
dnl GP_SLEEP_IF_TTY(delay_in_whole_seconds)
17+
dnl * If the SLEEP variable is set to "no" or empty or is unset,
18+
dnl do not sleep.
19+
dnl * If stdout (FD 1) is not a TTY (!isatty(1)), do not sleep.
20+
dnl * If tty -t is not present and therefore fails, we do not lose
21+
dnl much: Just that interactive users do not benefit from seeing the
22+
dnl warning a bit longer.
23+
dnl * Otherwise, run ${SLEEP} with the given delay value argument.
24+
dnl ####################################################################
25+
dnl
1426
AC_DEFUN_ONCE([_GP_SLEEP_INIT], [dnl
1527
AC_REQUIRE([GP_PROG_SLEEP])dnl
16-
AS_IF([test "x$SLEEP" != "x" && test "x$SLEEP" != "xno"], [dnl
17-
gp_sleep=[$]SLEEP
28+
AC_MSG_CHECKING([whether configure script should sleep])
29+
AS_IF([test "x$SLEEP" != x && test "x$SLEEP" != xno], [dnl
30+
AC_MSG_RESULT([yes])
31+
gp_sleep=[$]SLEEP
1832
], [dnl
19-
gp_sleep=:
33+
AC_MSG_RESULT([no])
34+
gp_sleep=:
2035
])
2136
])dnl
2237
dnl
2338
dnl
2439
AC_DEFUN([GP_SLEEP], [dnl
2540
AC_REQUIRE([_GP_SLEEP_INIT])dnl
26-
$gp_sleep $1
41+
[$]gp_sleep $1
42+
])dnl
43+
dnl
44+
AC_DEFUN([GP_SLEEP_IF_TTY], [dnl
45+
AC_REQUIRE([_GP_SLEEP_INIT])dnl
46+
AS_IF([test -t 1], [dnl
47+
[$]gp_sleep $1
48+
])
2749
])dnl
2850
dnl
2951
dnl

0 commit comments

Comments
 (0)