1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00

Add libjq autoconf goo

This commit is contained in:
Nicolas Williams
2013-06-16 08:25:12 -05:00
parent c791428905
commit 298b2a6033
19 changed files with 211 additions and 69 deletions

6
.gitignore vendored
View File

@@ -1,4 +1,10 @@
*.o
*.a
*.lo
*.la
*.lai
*.so
*.so.*
*~
.*.sw[a-p]
tags

View File

@@ -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)

View File

@@ -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"

View File

@@ -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

View File

@@ -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])

View File

@@ -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"

View File

@@ -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_ */

View File

@@ -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();

22
jv.h
View File

@@ -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

View File

@@ -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*);

View File

@@ -1,4 +1,3 @@
#include "jv_aux.h"
#include <string.h>
#include <stdlib.h>
#include "jv_alloc.h"

View File

@@ -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

View File

@@ -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) {

View File

@@ -1,8 +0,0 @@
#ifndef JV_FILE_H
#define JV_FILE_H
#include "jv.h"
jv jv_load_file(const char *, int);
#endif

View File

@@ -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

View File

@@ -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")

86
libjq.map Normal file
View File

@@ -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:
*;
};

3
main.c
View File

@@ -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"

View File

@@ -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-