Skip to content

Commit

Permalink
add --with-utf8proc=bundled option
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidaty committed Jul 9, 2023
1 parent 8213f7a commit af614af
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 43 deletions.
10 changes: 7 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,16 @@ jq.1: jq.1.prebuilt

SUBDIRS =

AM_CFLAGS += ${utf8proc_CFLAGS}
jq_LDADD += ${utf8proc_LIBS}

if BUNDLE_UTF8PROC
LIBJQ_SRC += modules/utf8proc/utf8proc.c
else
if BUILD_UTF8PROC
SUBDIRS += modules/utf8proc
endif

AM_CFLAGS += ${utf8proc_CFLAGS}
jq_LDADD += ${utf8proc_LIBS}
endif

### Build oniguruma

Expand Down
85 changes: 45 additions & 40 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -293,63 +293,68 @@ AM_CONDITIONAL([BUILD_ONIGURUMA], [test "x$build_oniguruma" = xyes])
dnl utf8proc
AC_ARG_WITH([utf8proc],
[AS_HELP_STRING([--with-utf8proc=prefix],
[specify the location of custom-installed utf8proc library to use, or 'builtin' to force built-in])], ,
[specify the location of custom-installed utf8proc library to use, 'builtin' to force built-in, 'bundled' to use built-in AND bundle into libjq, or 'auto' to use default prefix or fallback to builtin])], ,
[with_utf8proc=auto])

utf8proc_CFLAGS=
utf8proc_LIBS=
build_utf8proc=yes

AS_IF([test "x$with_utf8proc" = "xauto" ], [
test_prefix=
if test "x$prefix" != xNONE ; then
test_prefix=$prefix
elif test "x$ac_default_prefix" != x ; then
test_prefix=$ac_default_prefix
fi
if test "x$test_prefix" != "" ; then
bundle_utf8proc=no

AS_IF([test "x$with_utf8proc" = "xbundled" ], [
bundle_utf8proc=yes
utf8proc_CFLAGS="-Imodules/utf8proc -DUTF8PROC_STATIC"
], [
AS_IF([test "x$with_utf8proc" = "xauto" ], [
test_prefix=
if test "x$prefix" != xNONE ; then
test_prefix=$prefix
elif test "x$ac_default_prefix" != x ; then
test_prefix=$ac_default_prefix
fi
if test "x$test_prefix" != "" ; then
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I$test_prefix/include"
AC_CHECK_HEADER("utf8proc.h", [
with_utf8proc=$test_prefix
AC_MSG_NOTICE([utf8proc.h found in $test_prefix])
], [
with_utf8proc=builtin
])
CFLAGS="$save_CFLAGS"
fi
])
AS_IF([test "x$with_utf8proc" != xyes -a "x$with_utf8proc" != xbuiltin -a "x$with_utf8proc" != "x" ], [
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I$test_prefix/include"
save_LDFLAGS="$LDFLAGS"
utf8proc_CFLAGS="-I$with_utf8proc/include -DUTF8PROC_STATIC"
# utf8proc_LIBS="-L$with_utf8proc/lib -l:libutf8proc.a" # -l: not supported by some compilers
utf8proc_LIBS="$with_utf8proc/lib/libutf8proc.a"
CFLAGS="$CFLAGS $utf8proc_CFLAGS"
AC_CHECK_HEADER("utf8proc.h", [
with_utf8proc=$test_prefix
AC_MSG_NOTICE([utf8proc.h found in $test_prefix])
build_utf8proc=no
], [
with_utf8proc=builtin
AC_MSG_NOTICE([utf8proc.h not found in $with_utf8proc. Will use the packaged utf8proc.])
])
CFLAGS="$save_CFLAGS"
fi
])

AS_IF([test "x$with_utf8proc" != xyes -a "x$with_utf8proc" != xbuiltin -a "x$with_utf8proc" != "x" ], [
save_CFLAGS="$CFLAGS"
save_LDFLAGS="$LDFLAGS"
utf8proc_CFLAGS="-I$with_utf8proc/include -DUTF8PROC_STATIC"
# utf8proc_LIBS="-L$with_utf8proc/lib -l:libutf8proc.a" # -l: not supported by some compilers
utf8proc_LIBS="$with_utf8proc/lib/libutf8proc.a"
CFLAGS="$CFLAGS $utf8proc_CFLAGS"
AC_CHECK_HEADER("utf8proc.h", [
build_utf8proc=no
], [
AC_MSG_NOTICE([utf8proc.h not found in $with_utf8proc. Will use the packaged utf8proc.])
CFLAGS="$save_CFLAGS"
LDFLAGS="$save_LDFLAGS"
])
AS_IF([test "x$build_utf8proc" = xyes ], [
utf8proc_dir="`cd $srcdir && pwd`/modules/utf8proc"
utf8proc_CFLAGS="-I$utf8proc_dir -DUTF8PROC_STATIC"
# utf8proc_LIBS="-L$utf8proc_dir -l:libutf8proc.a" # -l: not supported by some compilers
utf8proc_LIBS="$utf8proc_dir/libutf8proc.a"
])
CFLAGS="$save_CFLAGS"
LDFLAGS="$save_LDFLAGS"
])

AS_IF([test "x$build_utf8proc" = xyes ], [
utf8proc_dir="`cd $srcdir && pwd`/modules/utf8proc"
utf8proc_CFLAGS="-I$utf8proc_dir -DUTF8PROC_STATIC"
# utf8proc_LIBS="-L$utf8proc_dir -l:libutf8proc.a" # -l: not supported by some compilers
utf8proc_LIBS="$utf8proc_dir/libutf8proc.a"
])

AC_SUBST(utf8proc_CFLAGS)
AC_SUBST(utf8proc_LIBS)

AM_CONDITIONAL([BUILD_UTF8PROC], [test "x$build_utf8proc" = xyes])
AM_CONDITIONAL([BUNDLE_UTF8PROC], [test "x$bundle_utf8proc" = xyes])

AC_SUBST([BUNDLER], ["$bundle_cmd"])

Expand Down

0 comments on commit af614af

Please sign in to comment.