Skip to content

Commit e725a51

Browse files
committed
Add --with-cunit configure option
1 parent 1754069 commit e725a51

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

configure.ac

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ AC_ARG_ENABLE([lib-only],
8282
[Build libnghttp3 only.])],
8383
[lib_only=$enableval], [lib_only=no])
8484

85+
AC_ARG_WITH([cunit],
86+
[AS_HELP_STRING([--with-cunit],
87+
[Use cunit [default=check]])],
88+
[request_cunit=$withval], [request_cunit=check])
8589

8690
# Checks for programs
8791
AC_PROG_CC
@@ -99,30 +103,38 @@ AX_CXX_COMPILE_STDCXX([17], [noext], [optional])
99103
# Checks for libraries.
100104

101105
# cunit
102-
PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes], [have_cunit=no])
103-
# If pkg-config does not find cunit, check it using AC_CHECK_LIB. We
104-
# do this because Debian (Ubuntu) lacks pkg-config file for cunit.
105-
if test "x${have_cunit}" = "xno"; then
106-
AC_MSG_WARN([${CUNIT_PKG_ERRORS}])
107-
AC_CHECK_LIB([cunit], [CU_initialize_registry],
108-
[have_cunit=yes], [have_cunit=no])
106+
have_cunit=no
107+
if test "x${request_cunit}" != "xno"; then
108+
PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes], [have_cunit=no])
109+
# If pkg-config does not find cunit, check it using AC_CHECK_LIB. We
110+
# do this because Debian (Ubuntu) lacks pkg-config file for cunit.
111+
if test "x${have_cunit}" = "xno"; then
112+
AC_MSG_WARN([${CUNIT_PKG_ERRORS}])
113+
AC_CHECK_LIB([cunit], [CU_initialize_registry],
114+
[have_cunit=yes], [have_cunit=no])
115+
if test "x${have_cunit}" = "xyes"; then
116+
CUNIT_LIBS="-lcunit"
117+
CUNIT_CFLAGS=""
118+
AC_SUBST([CUNIT_LIBS])
119+
AC_SUBST([CUNIT_CFLAGS])
120+
fi
121+
fi
109122
if test "x${have_cunit}" = "xyes"; then
110-
CUNIT_LIBS="-lcunit"
111-
CUNIT_CFLAGS=""
112-
AC_SUBST([CUNIT_LIBS])
113-
AC_SUBST([CUNIT_CFLAGS])
123+
# cunit in Mac OS X requires ncurses. Note that in Mac OS X, test
124+
# program can be built without -lncurses, but it emits runtime
125+
# error.
126+
case "${build}" in
127+
*-apple-darwin*)
128+
CUNIT_LIBS="$CUNIT_LIBS -lncurses"
129+
AC_SUBST([CUNIT_LIBS])
130+
;;
131+
esac
114132
fi
115133
fi
116-
if test "x${have_cunit}" = "xyes"; then
117-
# cunit in Mac OS X requires ncurses. Note that in Mac OS X, test
118-
# program can be built without -lncurses, but it emits runtime
119-
# error.
120-
case "${build}" in
121-
*-apple-darwin*)
122-
CUNIT_LIBS="$CUNIT_LIBS -lncurses"
123-
AC_SUBST([CUNIT_LIBS])
124-
;;
125-
esac
134+
135+
if test "x${request_cunit}" = "xyes" &&
136+
test "x${have_cunit}" != "xyes"; then
137+
AC_MSG_ERROR([cunit was requested (--with-cunit) but not found])
126138
fi
127139

128140
AM_CONDITIONAL([HAVE_CUNIT], [ test "x${have_cunit}" = "xyes" ])

0 commit comments

Comments
 (0)