summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2013-06-16 08:25:12 -0500
committerNicolas Williams <nico@cryptonector.com>2013-06-21 11:57:12 -0500
commit298b2a60335569a31ed35a04c0c13cb355c0cb04 (patch)
tree2c422f69e7b21718fbc7c93db29a188fcf91a190
parentc79142890545d58c20f93a628d07fe98c4d013d4 (diff)
Add libjq autoconf goo
-rw-r--r--.gitignore6
-rw-r--r--Makefile.am30
-rw-r--r--builtin.c2
-rw-r--r--config.h.in37
-rw-r--r--configure.ac28
-rw-r--r--execute.c4
-rw-r--r--jq.h (renamed from execute.h)19
-rw-r--r--jq_test.c2
-rw-r--r--jv.h28
-rw-r--r--jv_alloc.h3
-rw-r--r--jv_aux.c1
-rw-r--r--jv_aux.h20
-rw-r--r--jv_file.c1
-rw-r--r--jv_file.h8
-rw-r--r--jv_parse.h6
-rw-r--r--jv_print.c1
-rw-r--r--libjq.map86
-rw-r--r--main.c3
-rwxr-xr-xsetup.sh1
19 files changed, 214 insertions, 72 deletions
diff --git a/.gitignore b/.gitignore
index 8734c174..988d5ebf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,10 @@
*.o
+*.a
+*.lo
+*.la
+*.lai
+*.so
+*.so.*
*~
.*.sw[a-p]
tags
diff --git a/Makefile.am b/Makefile.am
index c4f79e04..0c9b0db0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,13 +1,13 @@
### C source files to be built and distributed.
-JQ_INCS = jq_parser.h builtin.h bytecode.h compile.h execute.h \
- forkable_stack.h frame_layout.h jv.h jv_alloc.h jv_aux.h jv_dtoa.h \
- jv_file.h jv_parse.h jv_unicode.h locfile.h opcode.h opcode_list.h \
+LIBJQ_INCS = jq_parser.h builtin.h bytecode.h compile.h \
+ forkable_stack.h frame_layout.h jv_alloc.h jv_dtoa.h \
+ jv_parse.h jv_unicode.h locfile.h opcode.h opcode_list.h \
parser.y jv_utf8_tables.h lexer.l
-JQ_SRC = locfile.c opcode.c bytecode.c compile.c execute.c builtin.c \
+LIBJQ_SRC = locfile.c opcode.c bytecode.c compile.c execute.c builtin.c \
jv.c jv_parse.c jv_print.c jv_dtoa.c jv_unicode.c jv_aux.c jv_file.c \
- jv_alloc.c jq_test.c ${JQ_INCS}
+ jv_alloc.c jq_test.c ${LIBJQ_INCS}
### C build options
@@ -15,6 +15,7 @@ JQ_SRC = locfile.c opcode.c bytecode.c compile.c execute.c builtin.c \
AM_CFLAGS = -Wextra -Wall -Wno-missing-field-initializers \
-Wno-unused-parameter -Wno-unused-function
+ACLOCAL_AMFLAGS = -I m4
### Generating the lexer and parser
@@ -30,6 +31,22 @@ lexer.h: lexer.c
# OSX ships an old bison, so update with homebrew or macports
AM_YFLAGS = --warnings=all -d
+### libjq
+
+# noinst for now?
+lib_LIBRARIES = libjq.a
+libjq_a_SOURCES = ${LIBJQ_SRC}
+libjq_a_CFLAGS = $(AM_CFLAGS)
+
+lib_LTLIBRARIES = libjq.la
+libjq_la_SOURCES = ${LIBJQ_SRC}
+libjq_la_LIBADD = -lm
+if HAVE_LD_VERSION_SCRIPT
+libjq_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libjq.map -version-info 1:4:0
+endif
+
+include_HEADERS = jv.h jq.h
+
### Building the jq binary
@@ -43,7 +60,8 @@ version.h: .remake-version-h
$(AM_V_GEN) $(generate_ver); echo "$$ver" > $@
bin_PROGRAMS = jq
-jq_SOURCES = ${JQ_SRC} main.c
+jq_SOURCES = main.c
+jq_LDADD = libjq.la -lm
### Tests (make check)
diff --git a/builtin.c b/builtin.c
index a2adb1ac..3929dafd 100644
--- a/builtin.c
+++ b/builtin.c
@@ -4,8 +4,6 @@
#include "compile.h"
#include "jq_parser.h"
#include "locfile.h"
-#include "jv_aux.h"
-#include "jv_file.h"
#include "jv_unicode.h"
diff --git a/config.h.in b/config.h.in
index 46b33c08..cf218100 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,5 +1,39 @@
/* config.h.in. Generated from configure.ac by autoheader. */
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
@@ -24,6 +58,9 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
/* Version number of package */
#undef VERSION
diff --git a/configure.ac b/configure.ac
index 76a49a9e..70a8c875 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,6 +10,32 @@ AC_PROG_CC
AC_PROG_CC_STDC
AC_PROG_CPP_WERROR
AC_PROG_YACC
+AC_OBJEXT
+AC_EXEEXT
+LT_INIT([shared static win32-dll])
+AM_CONDITIONAL(ENABLE_SHARED, test "$enable_shared" = "yes")
+
+AC_MSG_CHECKING([if libraries can be versioned])
+GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
+if test "$GLD"; then
+ have_ld_version_script=yes
+ AC_MSG_RESULT(yes)
+else
+ have_ld_version_script=no
+ AC_MSG_RESULT(no)
+ AC_MSG_WARN(*** You have not enabled versioned symbols.)
+fi
+AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
+
+if test "$have_ld_version_script" = "yes"; then
+ AC_MSG_CHECKING([for symbol prefix])
+ SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
+ | ${CPP-${CC-gcc} -E} - 2>&1 \
+ | ${EGREP-grep} "^PREFIX=" \
+ | ${SED-sed} "s:^PREFIX=::"`
+ AC_SUBST(SYMBOL_PREFIX)
+ AC_MSG_RESULT($SYMBOL_PREFIX)
+fi
AM_PROG_CC_C_O
@@ -64,7 +90,7 @@ EOF
AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" != xno])
AC_SUBST([BUNDLER], ["$bundle_cmd"])
-dnl AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE([-Wall])
AC_CONFIG_FILES([Makefile])
diff --git a/execute.c b/execute.c
index 3a5512aa..423b133a 100644
--- a/execute.c
+++ b/execute.c
@@ -3,8 +3,6 @@
#include <stdlib.h>
#include <stdint.h>
-#include "execute.h"
-
#include "exec_stack.h"
#include "opcode.h"
#include "bytecode.h"
@@ -13,7 +11,7 @@
#include "jq_parser.h"
#include "locfile.h"
#include "jv.h"
-#include "jv_aux.h"
+#include "jq.h"
#include "parser.h"
#include "builtin.h"
diff --git a/execute.h b/jq.h
index 0cb0b36c..e35845c6 100644
--- a/execute.h
+++ b/jq.h
@@ -1,21 +1,18 @@
-#ifndef EXECUTE_H
-#define EXECUTE_H
-#include "bytecode.h"
+#ifndef _JQ_H_
+#define _JQ_H_
-typedef struct jq_state jq_state;
-
-int jq_compile(jq_state *, const char* str);
-
-/* args must be an array of the form [{name:"foo", value:"thing"}, {name:"bar",value:3}] */
-int jq_compile_args(jq_state *, const char* str, jv args);
+#include <jv.h>
enum {JQ_DEBUG_TRACE = 1};
+typedef struct jq_state jq_state;
jq_state *jq_init(void);
void jq_set_nomem_handler(jq_state *, void (*)(void *), void *);
+int jq_compile(jq_state *, const char* str);
+int jq_compile_args(jq_state *, const char* str, jv args);
+void jq_dump_disassembly(jq_state *, int);
void jq_start(jq_state *, jv value, int flags);
jv jq_next(jq_state *);
void jq_teardown(jq_state **);
-void jq_dump_disassembly(jq_state *, int);
-#endif
+#endif /* !_JQ_H_ */
diff --git a/jq_test.c b/jq_test.c
index f84cea9f..9e39594f 100644
--- a/jq_test.c
+++ b/jq_test.c
@@ -3,7 +3,7 @@
#include <string.h>
#include <stdlib.h>
#include "jv.h"
-#include "execute.h"
+#include "jq.h"
static void jv_test();
static void run_jq_tests();
diff --git a/jv.h b/jv.h
index 47da5d9d..f9fd9ee0 100644
--- a/jv.h
+++ b/jv.h
@@ -124,13 +124,27 @@ jv jv_dump_string(jv, int flags);
jv jv_parse(const char* string);
jv jv_parse_sized(const char* string, int length);
-
-
-
-
-
-
-
+typedef void (*jv_nomem_handler_f)(void *);
+void jv_nomem_handler(jv_nomem_handler_f, void *);
+
+jv jv_load_file(const char *, int);
+
+struct jv_parser;
+void jv_parser_init(struct jv_parser*);
+void jv_parser_free(struct jv_parser*);
+void jv_parser_set_buf(struct jv_parser*, const char*, int, int);
+jv jv_parser_next(struct jv_parser*);
+
+jv jv_get(jv, jv);
+jv jv_set(jv, jv, jv);
+jv jv_has(jv, jv);
+jv jv_setpath(jv, jv, jv);
+jv jv_getpath(jv, jv);
+jv jv_delpaths(jv, jv);
+jv jv_keys(jv /*object or array*/);
+int jv_cmp(jv, jv);
+jv jv_group(jv, jv);
+jv jv_sort(jv, jv);
#endif
diff --git a/jv_alloc.h b/jv_alloc.h
index cbcf9548..91190825 100644
--- a/jv_alloc.h
+++ b/jv_alloc.h
@@ -2,6 +2,7 @@
#define JV_ALLOC_H
#include <stddef.h>
+#include "jv.h"
#ifndef NDEBUG
extern volatile char jv_mem_uninitialised;
@@ -14,8 +15,6 @@ static void jv_mem_invalidate(void* mem, size_t n) {
#endif
}
-typedef void (*jv_nomem_handler_f)(void *);
-void jv_nomem_handler(jv_nomem_handler_f, void *);
void* jv_mem_alloc(size_t);
void* jv_mem_alloc_unguarded(size_t);
void jv_mem_free(void*);
diff --git a/jv_aux.c b/jv_aux.c
index 0c8cd8b7..eb4ded03 100644
--- a/jv_aux.c
+++ b/jv_aux.c
@@ -1,4 +1,3 @@
-#include "jv_aux.h"
#include <string.h>
#include <stdlib.h>
#include "jv_alloc.h"
diff --git a/jv_aux.h b/jv_aux.h
deleted file mode 100644
index 5a47b70c..00000000
--- a/jv_aux.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef JV_AUX_H
-#define JV_AUX_H
-
-#include "jv.h"
-
-jv jv_get(jv t, jv k);
-jv jv_set(jv t, jv k, jv v);
-jv jv_has(jv t, jv k);
-jv jv_setpath(jv root, jv path, jv value);
-jv jv_getpath(jv root, jv path);
-jv jv_delpaths(jv root, jv paths);
-
-jv jv_keys(jv /*object or array*/);
-int jv_cmp(jv, jv);
-
-jv jv_group(jv objects, jv keys);
-jv jv_sort(jv objects, jv keys);
-
-
-#endif
diff --git a/jv_file.c b/jv_file.c
index 7532a025..7c481ce3 100644
--- a/jv_file.c
+++ b/jv_file.c
@@ -4,7 +4,6 @@
#include <stdlib.h>
#include <string.h>
#include "jv.h"
-#include "jv_aux.h"
#include "jv_parse.h"
jv jv_load_file(const char* filename, int raw) {
diff --git a/jv_file.h b/jv_file.h
deleted file mode 100644
index a4ae76c9..00000000
--- a/jv_file.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef JV_FILE_H
-#define JV_FILE_H
-
-#include "jv.h"
-
-jv jv_load_file(const char *, int);
-
-#endif
diff --git a/jv_parse.h b/jv_parse.h
index 1d538c12..8ef86f65 100644
--- a/jv_parse.h
+++ b/jv_parse.h
@@ -28,10 +28,4 @@ struct jv_parser {
} st;
};
-void jv_parser_init(struct jv_parser* p);
-void jv_parser_free(struct jv_parser* p);
-
-void jv_parser_set_buf(struct jv_parser* p, const char* buf, int length, int is_partial);
-
-jv jv_parser_next(struct jv_parser* p);
#endif
diff --git a/jv_print.c b/jv_print.c
index f8edf335..890de040 100644
--- a/jv_print.c
+++ b/jv_print.c
@@ -5,7 +5,6 @@
#include "jv_dtoa.h"
#include "jv_unicode.h"
-#include "jv_aux.h"
#define ESC "\033"
#define COL(c) (ESC "[" c "m")
diff --git a/libjq.map b/libjq.map
new file mode 100644
index 00000000..bc16b4c3
--- /dev/null
+++ b/libjq.map
@@ -0,0 +1,86 @@
+JQ_1.4 {
+ global:
+ jq_compile;
+ jq_compile_args;
+ jq_dump_disassembly;
+ jq_init;
+ jq_next;
+ jq_set_nomem_handler;
+ jq_start;
+ jq_teardown;
+ jq_testsuite;
+ jv_array;
+ jv_array_append;
+ jv_array_concat;
+ jv_array_contains;
+ jv_array_get;
+ jv_array_length;
+ jv_array_set;
+ jv_array_sized;
+ jv_array_slice;
+ jv_bool;
+ jv_cmp;
+ jv_contains;
+ jv_copy;
+ jv_delpaths;
+ jv_dels;
+ jv_dump;
+ jv_dump_string;
+ jv_equal;
+ jv_false;
+ jv_free;
+ jv_get;
+ jv_get_kind;
+ jv_getpath;
+ jv_get_refcnt;
+ jv_group;
+ jv_has;
+ jv_invalid;
+ jv_invalid_get_msg;
+ jv_invalid_has_msg;
+ jv_invalid_with_msg;
+ jv_keys;
+ jv_kind_name;
+ jv_load_file;
+ jv_mem_alloc;
+ jv_mem_free;
+ jv_mem_uninitialised;
+ jv_nomem_handler;
+ jv_null;
+ jv_number;
+ jv_number_value;
+ jv_object;
+ jv_object_contains;
+ jv_object_delete;
+ jv_object_get;
+ jv_object_iter;
+ jv_object_iter_key;
+ jv_object_iter_next;
+ jv_object_iter_valid;
+ jv_object_iter_value;
+ jv_object_length;
+ jv_object_merge;
+ jv_object_set;
+ jv_parse;
+ jv_parser_free;
+ jv_parser_init;
+ jv_parser_next;
+ jv_parser_set_buf;
+ jv_parse_sized;
+ jv_set;
+ jv_setpath;
+ jv_sort;
+ jv_string;
+ jv_string_append_buf;
+ jv_string_append_str;
+ jv_string_concat;
+ jv_string_fmt;
+ jv_string_hash;
+ jv_string_length_bytes;
+ jv_string_length_codepoints;
+ jv_string_sized;
+ jv_string_value;
+ jv_true;
+ local:
+ *;
+};
diff --git a/main.c b/main.c
index 3f82b460..d66da9f7 100644
--- a/main.c
+++ b/main.c
@@ -6,9 +6,8 @@
#include <unistd.h>
#include "compile.h"
#include "jv.h"
-#include "jv_file.h"
+#include "jq.h"
#include "jv_parse.h"
-#include "execute.h"
#include "config.h" /* Autoconf generated header file */
#include "jv_alloc.h"
#include "version.h"
diff --git a/setup.sh b/setup.sh
index c63fc9cd..4dfc44be 100755
--- a/setup.sh
+++ b/setup.sh
@@ -24,6 +24,7 @@ elif [ "superclean" == "$1" ]; then
fi
else
autoreconf --install
+ automake --add-missing
./configure --prefix=/opt/junk
make check
[ -d tmp ] && mv tmp tmp-