Skip to content

Commit

Permalink
Simplify pcre
Browse files Browse the repository at this point in the history
  • Loading branch information
ingwarsw committed May 26, 2024
1 parent 351ef84 commit 3e99eb4
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 36 deletions.
98 changes: 75 additions & 23 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -5333,21 +5333,7 @@ esac
fi


for ac_header in pcre.h
do :
ac_fn_c_check_header_compile "$LINENO" "pcre.h" "ac_cv_header_pcre_h" "$ac_includes_default"
if test "x$ac_cv_header_pcre_h" = xyes
then :
printf "%s\n" "#define HAVE_PCRE_H 1" >>confdefs.h
WITH_PCRE=yes
else case e in #(
e) WITH_PCRE=no ;;
esac
fi

done
if test $WITH_PCRE = no ; then
# Extract the first word of "pcre-config", so it can be a program name with args.
# Extract the first word of "pcre-config", so it can be a program name with args.
set dummy pcre-config; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
printf %s "checking for $ac_word... " >&6; }
Expand Down Expand Up @@ -5394,19 +5380,85 @@ printf "%s\n" "no" >&6; }
fi


if test "$PCRE_CONFIG" != "false"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: using pcre-config to find extra flags" >&5
if test "$PCRE_CONFIG" != "false"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: using pcre-config to find extra flags" >&5
printf "%s\n" "$as_me: using pcre-config to find extra flags" >&6;}
CFLAGS="${CFLAGS} `$PCRE_CONFIG --cflags`"
LIBS="${LIBS} `$PCRE_CONFIG --libs`"
WITH_PCRE=yes
fi
CFLAGS="${CFLAGS} `$PCRE_CONFIG --cflags`"
LIBS="${LIBS} `$PCRE_CONFIG --libs`"
else
for ac_header in pcre.h
do :
ac_fn_c_check_header_compile "$LINENO" "pcre.h" "ac_cv_header_pcre_h" "$ac_includes_default"
if test "x$ac_cv_header_pcre_h" = xyes
then :
printf "%s\n" "#define HAVE_PCRE_H 1" >>confdefs.h
WITH_PCRE=yes
else case e in #(
e) WITH_PCRE=no ;;
esac
fi

done
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pcre_compile in -lpcre" >&5
printf %s "checking for pcre_compile in -lpcre... " >&6; }
if test ${ac_cv_lib_pcre_pcre_compile+y}
then :
printf %s "(cached) " >&6
else case e in #(
e) ac_check_lib_save_LIBS=$LIBS
LIBS="-lpcre $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply.
The 'extern "C"' is for builds by C++ compilers;
although this is not generally supported in C code supporting it here
has little cost and some practical benefit (sr 110532). */
#ifdef __cplusplus
extern "C"
#endif
char pcre_compile (void);
int
main (void)
{
return pcre_compile ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ac_cv_lib_pcre_pcre_compile=yes
else case e in #(
e) ac_cv_lib_pcre_pcre_compile=no ;;
esac
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS ;;
esac
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcre_pcre_compile" >&5
printf "%s\n" "$ac_cv_lib_pcre_pcre_compile" >&6; }
if test "x$ac_cv_lib_pcre_pcre_compile" = xyes
then :
printf "%s\n" "#define HAVE_LIBPCRE 1" >>confdefs.h

LIBS="-lpcre $LIBS"

else case e in #(
e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}
as_fn_error $? "Can't find pcre
See 'config.log' for more details" "$LINENO" 5; } ;;
esac
fi

if test $WITH_PCRE = no; then
as_fn_error $? "Cannot find pcre library." "$LINENO" 5
fi


ac_fn_c_check_header_compile "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default"
if test "x$ac_cv_header_unistd_h" = xyes
then :
Expand Down
21 changes: 8 additions & 13 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ fi
dnl ########### programs ############

AC_PROG_CC
dnl XXX STD_C=1, if compiler is standard

dnl XXX
dnl ${CC} ${CCFLAGS} -c symtest.c >symtest.out 2>&1 || {
Expand Down Expand Up @@ -418,20 +417,16 @@ fi

AC_CHECK_LIB(z, inflate, [], [AC_MSG_FAILURE([Cant find inflate in libz])])

AC_CHECK_HEADERS([pcre.h], WITH_PCRE=yes, WITH_PCRE=no)
if test $WITH_PCRE = no ; then
AC_PATH_PROG([PCRE_CONFIG], [pcre-config], [false])
if test "$PCRE_CONFIG" != "false"; then
AC_MSG_NOTICE([using pcre-config to find extra flags])
CFLAGS="${CFLAGS} `$PCRE_CONFIG --cflags`"
LIBS="${LIBS} `$PCRE_CONFIG --libs`"
WITH_PCRE=yes
fi
AC_PATH_PROG([PCRE_CONFIG], [pcre-config], [false])
if test "$PCRE_CONFIG" != "false"; then
AC_MSG_NOTICE([using pcre-config to find extra flags])
CFLAGS="${CFLAGS} `$PCRE_CONFIG --cflags`"
LIBS="${LIBS} `$PCRE_CONFIG --libs`"
else
AC_CHECK_HEADERS([pcre.h], WITH_PCRE=yes, WITH_PCRE=no)
AC_CHECK_LIB(pcre, pcre_compile, [], [AC_MSG_FAILURE([Can't find pcre])])
fi

if test $WITH_PCRE = no; then
AC_MSG_ERROR([Cannot find pcre library.])
fi
dnl ########### headers ############

AC_CHECK_HEADERS(unistd.h memory.h sys/select.h)
Expand Down

0 comments on commit 3e99eb4

Please sign in to comment.