]> granicus.if.org Git - jq/commitdiff
Add local oniguruma submodule
authorErik Brinkman <erik.brinkman@gmail.com>
Fri, 27 Jan 2017 04:29:00 +0000 (23:29 -0500)
committerWilliam Langford <wlangfor@gmail.com>
Sun, 19 Feb 2017 02:34:26 +0000 (21:34 -0500)
Configure should still allow use of prebuilt onigurumas (whether
system-installed or in a special prefix).  If these are not found, and
configure was not called with `--without-oniguruma`, then use the vendored
oniguruma module.  If configure was called with `--without-oniguruma`, then we
do not build regex functionality into jq.

.gitmodules [new file with mode: 0644]
.travis.yml
Makefile.am
configure.ac
modules/oniguruma [new submodule]
src/builtin.c

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..3fff3b8
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "modules/oniguruma"]
+       path = modules/oniguruma
+       url = https://github.com/kkos/oniguruma.git
index 97596ff838574acf18fe33658d104e3163e631cd..922b165a52ef563b0db3d535de3c12bfee254444 100644 (file)
@@ -19,9 +19,9 @@ matrix:
 addons:
     apt:
         packages:
-            - libonig-dev
             - valgrind
             - bison
+            - automake
 
 before_install:
     - echo "$TRAVIS_OS_NAME"
@@ -29,8 +29,8 @@ before_install:
     - brew update               || true;
       brew install flex         || true;
       brew install bison        || true;
-      brew install oniguruma    || true;
     - rm src/{lexer,parser}.{c,h}
+    - sed -i.bak '/^AM_INIT_AUTOMAKE(\[-Wno-portability 1\.14\])$/s/14/11/' modules/oniguruma/configure.ac
 
 install:
     - bundle install --gemfile=docs/Gemfile
@@ -46,7 +46,7 @@ before_script:
     - echo PATH=$PATH
     - which bison
     - bison --version
-    - autoreconf -i
+    - autoreconf -if
     - ./configure YACC="$(which bison) -y" $COVERAGE
 
 script:
index cf5d74dc5bd47122042bdf9b70bfc8f975e43c66..3c3095d11c09b3de46fb8019aa9bb3e153e35a8d 100644 (file)
@@ -48,7 +48,7 @@ AM_YFLAGS = --warnings=all -d
 lib_LTLIBRARIES = libjq.la
 libjq_la_SOURCES = ${LIBJQ_SRC}
 libjq_la_LIBADD = -lm
-libjq_la_LDFLAGS = -export-symbols-regex '^j[qv]_' -version-info 1:4:0
+libjq_la_LDFLAGS = $(onig_LDFLAGS) -export-symbols-regex '^j[qv]_' -version-info 1:4:0
 
 if WIN32
 libjq_la_LIBADD += -lshlwapi
@@ -133,6 +133,15 @@ jq.1: $(srcdir)/jq.1.prebuilt
 endif
 
 
+### Build oniguruma
+
+if BUILD_ONIGURUMA
+libjq_la_LIBADD += modules/oniguruma/src/.libs/libonig.la
+SUBDIRS = modules/oniguruma
+endif
+
+AM_CFLAGS += $(onig_CFLAGS)
+
 ### Packaging
 
 docs/site.yml: configure.ac
index 59432fdd4c0e46ea26cb76637457bb84d23c06bc..65fce4fa5ecac00b48cb4795454c75482cac36b8 100644 (file)
@@ -44,35 +44,6 @@ if test "$USE_MAINTAINER_MODE" = yes; then
   fi
 fi
 
-
-##########################################################################
-# check for ONIGURUMA library
-##########################################################################
-
-AC_ARG_WITH([oniguruma],
-    [AS_HELP_STRING([--with-oniguruma=prefix],
-        [try this for a non-standard install prefix of the oniguruma library])],
-    [],
-    [with_oniguruma=yes])
-
-AS_IF([test "x$with_oniguruma" != xno], [
-    AS_IF([test "x$with_oniguruma" != xyes], [
-        CFLAGS="$CFLAGS -I${with_oniguruma}/include"
-        LDFLAGS="$LDFLAGS -L${with_oniguruma}/lib"
-    ])
-    # check for ONIGURUMA library
-    have_oniguruma=0
-    AC_CHECK_HEADER("oniguruma.h",
-        AC_CHECK_LIB([onig],[onig_version],[LIBS="$LIBS -lonig"; have_oniguruma=1;]))
-    # handle check results
-    AS_IF([test $have_oniguruma = 1], [
-        AC_DEFINE([HAVE_ONIGURUMA], 1, [Define to 1 if Oniguruma is installed])
-    ], [
-        AC_MSG_NOTICE([Oniguruma was not found.])
-        AC_MSG_NOTICE([Try setting the location using '--with-oniguruma=PREFIX'])
-    ])
-])
-
 dnl Check for valgrind
 AC_CHECK_PROGS(valgrind_cmd, valgrind)
 if test "x$valgrind_cmd" = "x" ; then
@@ -254,6 +225,41 @@ AC_C_BIGENDIAN(
    AC_MSG_ERROR(universial endianess not supported)
 )
 
+dnl Oniguruma
+AC_ARG_WITH([oniguruma],
+   [AS_HELP_STRING([--with-oniguruma=prefix],
+      [try this for a non-standard install prefix of the oniguruma library])], ,
+   [with_oniguruma=yes])
+
+build_oniguruma=no
+AS_IF([test "x$with_oniguruma" != xno], [
+   save_CFLAGS="$CFLAGS"
+   save_LDFLAGS="$LDFLAGS"
+   AS_IF([test "x$with_oniguruma" != xyes], [
+      onig_CFLAGS="-I${with_oniguruma}/include"
+      onig_LDFLAGS="-L${with_oniguruma}/lib"
+      CFLAGS="$CFLAGS $onig_CFLAGS"
+      LDFLAGS="$LDFLAGS $onig_LDFLAGS"
+   ])
+   # check for ONIGURUMA library
+   AC_CHECK_HEADER("oniguruma.h",
+      AC_CHECK_LIB([onig],[onig_version]))
+   CFLAGS="$save_CFLAGS"
+   LDFLAGS="$save_LDFLAGS"
+
+   # handle check results
+   AS_IF([test "x$ac_cv_lib_onig_onig_version" != "xyes"], [
+      onig_CFLAGS="-I${srcdir}/modules/oniguruma/src"
+      onig_LDFLAGS=
+      AC_CONFIG_SUBDIRS([modules/oniguruma])
+      build_oniguruma=yes
+      AC_MSG_NOTICE([Oniguruma was not found. Will use the packaged oniguruma.])
+   ])
+   AC_SUBST(onig_CFLAGS)
+   AC_SUBST(onig_LDFLAGS)
+])
+
+AM_CONDITIONAL([BUILD_ONIGURUMA], [test "x$build_oniguruma" = xyes])
 AC_SUBST([BUNDLER], ["$bundle_cmd"])
 
 AC_CONFIG_MACRO_DIR([config/m4])
diff --git a/modules/oniguruma b/modules/oniguruma
new file mode 160000 (submodule)
index 0000000..4ab96b4
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 4ab96b4e2d4614494ca556496dc7d6123a832bea
index 31f2ae999b14c359db89bacd92a6b712b617a0be..380ae449ad485a56d4627477cd2e250ee7a61452 100644 (file)
@@ -29,7 +29,7 @@ void *alloca (size_t);
 #include <ctype.h>
 #include <limits.h>
 #include <math.h>
-#ifdef HAVE_ONIGURUMA
+#ifdef HAVE_LIBONIG
 #include <oniguruma.h>
 #endif
 #include <string.h>
@@ -697,7 +697,7 @@ static jv f_group_by_impl(jq_state *jq, jv input, jv keys) {
   }
 }
 
-#ifdef HAVE_ONIGURUMA
+#ifdef HAVE_LIBONIG
 static int f_match_name_iter(const UChar* name, const UChar *name_end, int ngroups,
     int *groups, regex_t *reg, void *arg) {
   jv captures = *(jv*)arg;
@@ -901,11 +901,11 @@ static jv f_match(jq_state *jq, jv input, jv regex, jv modifiers, jv testmode) {
   jv_free(regex);
   return result;
 }
-#else /* ! HAVE_ONIGURUMA */
+#else /* !HAVE_LIBONIG */
 static jv f_match(jq_state *jq, jv input, jv regex, jv modifiers, jv testmode) {
   return jv_invalid_with_msg(jv_string("jq was compiled without ONIGURUMA regex libary. match/test/sub and related functions are not available."));
 }
-#endif /* HAVE_ONIGURUMA */
+#endif /* HAVE_LIBONIG */
 
 static jv minmax_by(jv values, jv keys, int is_min) {
   if (jv_get_kind(values) != JV_KIND_ARRAY)