mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
allow building without sqlite3
Changelog-Changed: build: SQLite3 is no longer a hard build requirement. C-Lightning can now be built to support only the PostgreSQL back-end.
This commit is contained in:
committed by
Christian Decker
parent
c1aa33a62a
commit
abbc712afb
6
Makefile
6
Makefile
@@ -205,7 +205,7 @@ BOLT_DEPS := $(BOLT_GEN)
|
|||||||
ALL_PROGRAMS =
|
ALL_PROGRAMS =
|
||||||
|
|
||||||
CPPFLAGS += -DBINTOPKGLIBEXECDIR="\"$(shell sh tools/rel.sh $(bindir) $(pkglibexecdir))\""
|
CPPFLAGS += -DBINTOPKGLIBEXECDIR="\"$(shell sh tools/rel.sh $(bindir) $(pkglibexecdir))\""
|
||||||
CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) $(COPTFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . -I/usr/local/include $(POSTGRES_INCLUDE) $(FEATURES) $(COVFLAGS) $(DEV_CFLAGS) -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS $(PIE_CFLAGS) $(COMPAT_CFLAGS) -DBUILD_ELEMENTS=1
|
CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) $(COPTFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . -I/usr/local/include $(SQLITE3_CFLAGS) $(POSTGRES_INCLUDE) $(FEATURES) $(COVFLAGS) $(DEV_CFLAGS) -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS $(PIE_CFLAGS) $(COMPAT_CFLAGS) -DBUILD_ELEMENTS=1
|
||||||
# If CFLAGS is already set in the environment of make (to whatever value, it
|
# If CFLAGS is already set in the environment of make (to whatever value, it
|
||||||
# does not matter) then it would export it to subprocesses with the above value
|
# does not matter) then it would export it to subprocesses with the above value
|
||||||
# we set, including CWARNFLAGS which by default contains -Wall -Werror. This
|
# we set, including CWARNFLAGS which by default contains -Wall -Werror. This
|
||||||
@@ -221,9 +221,9 @@ ifeq ($(STATIC),1)
|
|||||||
# For MacOS, Jacob Rapoport <jacob@rumblemonkey.com> changed this to:
|
# For MacOS, Jacob Rapoport <jacob@rumblemonkey.com> changed this to:
|
||||||
# -L/usr/local/lib -Wl,-lgmp -lsqlite3 -lz -Wl,-lm -lpthread -ldl $(COVFLAGS)
|
# -L/usr/local/lib -Wl,-lgmp -lsqlite3 -lz -Wl,-lm -lpthread -ldl $(COVFLAGS)
|
||||||
# But that doesn't static link.
|
# But that doesn't static link.
|
||||||
LDLIBS = -L/usr/local/lib -Wl,-dn -lgmp -lsqlite3 -lz -Wl,-dy -lm -lpthread -ldl $(COVFLAGS)
|
LDLIBS = -L/usr/local/lib -Wl,-dn -lgmp $(SQLITE3_LDLIBS) -lz -Wl,-dy -lm -lpthread -ldl $(COVFLAGS)
|
||||||
else
|
else
|
||||||
LDLIBS = -L/usr/local/lib -lm -lgmp -lsqlite3 -lz $(COVFLAGS)
|
LDLIBS = -L/usr/local/lib -lm -lgmp $(SQLITE3_LDLIBS) -lz $(COVFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# If we have the postgres client library we need to link against it as well
|
# If we have the postgres client library we need to link against it as well
|
||||||
|
|||||||
17
configure
vendored
17
configure
vendored
@@ -8,6 +8,8 @@ CONFIG_VAR_FILE=config.vars
|
|||||||
CONFIG_HEADER=ccan/config.h
|
CONFIG_HEADER=ccan/config.h
|
||||||
BASE_WARNFLAGS="-Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror"
|
BASE_WARNFLAGS="-Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror"
|
||||||
|
|
||||||
|
: ${PKG_CONFIG=pkg-config}
|
||||||
|
|
||||||
# You can set PG_CONFIG in the environment to direct configure to call
|
# You can set PG_CONFIG in the environment to direct configure to call
|
||||||
# a specific 'pg_config' binary. If you set it to an empty string, then
|
# a specific 'pg_config' binary. If you set it to an empty string, then
|
||||||
# PostgreSQL support will be explicitly disabled, even if a 'pg_config'
|
# PostgreSQL support will be explicitly disabled, even if a 'pg_config'
|
||||||
@@ -236,6 +238,13 @@ fi
|
|||||||
# Doesn't set a var, but makes sure it exists
|
# Doesn't set a var, but makes sure it exists
|
||||||
require 'python3-mako' "You need the mako module for python3: see doc/INSTALL.md" python3 -c 'import mako'
|
require 'python3-mako' "You need the mako module for python3: see doc/INSTALL.md" python3 -c 'import mako'
|
||||||
|
|
||||||
|
SQLITE3_CFLAGS=""
|
||||||
|
SQLITE3_LDLIBS="-lsqlite3"
|
||||||
|
if command -v "${PKG_CONFIG}" >/dev/null; then
|
||||||
|
SQLITE3_CFLAGS="$("${PKG_CONFIG}" --silence-errors --cflags sqlite3 || :)"
|
||||||
|
SQLITE3_LDLIBS="$("${PKG_CONFIG}" --silence-errors --libs sqlite3 || :)"
|
||||||
|
fi
|
||||||
|
|
||||||
POSTGRES_INCLUDE=""
|
POSTGRES_INCLUDE=""
|
||||||
POSTGRES_LDLIBS=""
|
POSTGRES_LDLIBS=""
|
||||||
if command -v "${PG_CONFIG}" >/dev/null; then
|
if command -v "${PG_CONFIG}" >/dev/null; then
|
||||||
@@ -244,7 +253,7 @@ if command -v "${PG_CONFIG}" >/dev/null; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f $CONFIG_VAR_FILE.$$
|
rm -f $CONFIG_VAR_FILE.$$
|
||||||
$CONFIGURATOR --extra-tests --autotools-style --var-file=$CONFIG_VAR_FILE.$$ --header-file=$CONFIG_HEADER --configurator-cc="$CONFIGURATOR_CC" --wrapper="$CONFIGURATOR_WRAPPER" "$CC" ${CWARNFLAGS-$BASE_WARNFLAGS} $CDEBUGFLAGS $COPTFLAGS -I/usr/local/include -L/usr/local/lib $POSTGRES_INCLUDE <<EOF
|
$CONFIGURATOR --extra-tests --autotools-style --var-file=$CONFIG_VAR_FILE.$$ --header-file=$CONFIG_HEADER --configurator-cc="$CONFIGURATOR_CC" --wrapper="$CONFIGURATOR_WRAPPER" "$CC" ${CWARNFLAGS-$BASE_WARNFLAGS} $CDEBUGFLAGS $COPTFLAGS -I/usr/local/include -L/usr/local/lib $SQLITE3_CFLAGS $POSTGRES_INCLUDE <<EOF
|
||||||
|
|
||||||
var=HAVE_GOOD_LIBSODIUM
|
var=HAVE_GOOD_LIBSODIUM
|
||||||
desc=libsodium with IETF chacha20 variants
|
desc=libsodium with IETF chacha20 variants
|
||||||
@@ -271,7 +280,7 @@ int main(void)
|
|||||||
var=HAVE_SQLITE3_EXPANDED_SQL
|
var=HAVE_SQLITE3_EXPANDED_SQL
|
||||||
desc=sqlite3_expanded_sql
|
desc=sqlite3_expanded_sql
|
||||||
style=DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE
|
style=DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE
|
||||||
link=-lsqlite3
|
link=$SQLITE3_LDLIBS
|
||||||
code=
|
code=
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -285,7 +294,7 @@ int main(void)
|
|||||||
var=HAVE_SQLITE3
|
var=HAVE_SQLITE3
|
||||||
desc=sqlite3
|
desc=sqlite3
|
||||||
style=DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE
|
style=DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE
|
||||||
link=-lsqlite3
|
link=$SQLITE3_LDLIBS
|
||||||
code=
|
code=
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -368,6 +377,8 @@ add_var CONFIGURATOR_CC "$CONFIGURATOR_CC"
|
|||||||
add_var CWARNFLAGS "$CWARNFLAGS"
|
add_var CWARNFLAGS "$CWARNFLAGS"
|
||||||
add_var CDEBUGFLAGS "$CDEBUGFLAGS"
|
add_var CDEBUGFLAGS "$CDEBUGFLAGS"
|
||||||
add_var COPTFLAGS "$COPTFLAGS"
|
add_var COPTFLAGS "$COPTFLAGS"
|
||||||
|
add_var SQLITE3_CFLAGS "$SQLITE3_CFLAGS"
|
||||||
|
add_var SQLITE3_LDLIBS "$SQLITE3_LDLIBS"
|
||||||
add_var POSTGRES_INCLUDE "$POSTGRES_INCLUDE"
|
add_var POSTGRES_INCLUDE "$POSTGRES_INCLUDE"
|
||||||
add_var POSTGRES_LDLIBS "$POSTGRES_LDLIBS"
|
add_var POSTGRES_LDLIBS "$POSTGRES_LDLIBS"
|
||||||
add_var VALGRIND "$VALGRIND"
|
add_var VALGRIND "$VALGRIND"
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
DEVTOOLS_SRC := devtools/gen_print_wire.c devtools/gen_print_onion_wire.c devtools/print_wire.c
|
DEVTOOLS_SRC := devtools/gen_print_wire.c devtools/gen_print_onion_wire.c devtools/print_wire.c
|
||||||
DEVTOOLS_OBJS := $(DEVTOOLS_SRC:.c=.o)
|
DEVTOOLS_OBJS := $(DEVTOOLS_SRC:.c=.o)
|
||||||
DEVTOOLS := devtools/bolt11-cli devtools/decodemsg devtools/onion devtools/dump-gossipstore devtools/gossipwith devtools/create-gossipstore devtools/mkcommit devtools/mkfunding devtools/mkclose devtools/mkgossip devtools/mkencoded devtools/checkchannels devtools/mkquery devtools/lightning-checkmessage devtools/topology devtools/route
|
DEVTOOLS := devtools/bolt11-cli devtools/decodemsg devtools/onion devtools/dump-gossipstore devtools/gossipwith devtools/create-gossipstore devtools/mkcommit devtools/mkfunding devtools/mkclose devtools/mkgossip devtools/mkencoded devtools/mkquery devtools/lightning-checkmessage devtools/topology devtools/route
|
||||||
|
ifeq ($(HAVE_SQLITE3),1)
|
||||||
|
DEVTOOLS += devtools/checkchannels
|
||||||
|
endif
|
||||||
ifeq ($(EXPERIMENTAL_FEATURES),1)
|
ifeq ($(EXPERIMENTAL_FEATURES),1)
|
||||||
DEVTOOLS += devtools/blindedpath
|
DEVTOOLS += devtools/blindedpath
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/* Updates the given file if any library versions have changed. This
|
/* Updates the given file if any library versions have changed. This
|
||||||
* is important for systemwide updates, such as sqlite3. */
|
* is important for systemwide updates, such as sqlite3. */
|
||||||
|
#include "config.h"
|
||||||
#include <ccan/err/err.h>
|
#include <ccan/err/err.h>
|
||||||
#include <ccan/read_write_all/read_write_all.h>
|
#include <ccan/read_write_all/read_write_all.h>
|
||||||
#include <ccan/tal/grab_file/grab_file.h>
|
#include <ccan/tal/grab_file/grab_file.h>
|
||||||
@@ -7,7 +8,12 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <gmp.h>
|
#include <gmp.h>
|
||||||
#include <sqlite3.h>
|
#if HAVE_SQLITE3
|
||||||
|
# include <sqlite3.h>
|
||||||
|
# define IF_SQLITE3(...) __VA_ARGS__
|
||||||
|
#else
|
||||||
|
# define IF_SQLITE3(...)
|
||||||
|
#endif
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -16,19 +22,21 @@
|
|||||||
static const char template[] =
|
static const char template[] =
|
||||||
"/* Generated file by tools/headerversions, do not edit! */\n"
|
"/* Generated file by tools/headerversions, do not edit! */\n"
|
||||||
"/* GMP version: %s */\n"
|
"/* GMP version: %s */\n"
|
||||||
"/* SQLITE3 version: %u */\n"
|
IF_SQLITE3("/* SQLITE3 version: %u */\n")
|
||||||
"/* ZLIB version: %s */\n"
|
"/* ZLIB version: %s */\n"
|
||||||
"#include <ccan/err/err.h>\n"
|
"#include <ccan/err/err.h>\n"
|
||||||
"#include <gmp.h>\n"
|
"#include <gmp.h>\n"
|
||||||
"#include <sqlite3.h>\n"
|
IF_SQLITE3("#include <sqlite3.h>\n")
|
||||||
"#include <zlib.h>\n"
|
"#include <zlib.h>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"static inline void check_linked_library_versions(void)\n"
|
"static inline void check_linked_library_versions(void)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" char compiled_gmp_version[100];\n"
|
" char compiled_gmp_version[100];\n"
|
||||||
|
IF_SQLITE3(
|
||||||
" if (SQLITE_VERSION_NUMBER != sqlite3_libversion_number())\n"
|
" if (SQLITE_VERSION_NUMBER != sqlite3_libversion_number())\n"
|
||||||
" errx(1, \"SQLITE version mismatch: compiled %%u, now %%u\",\n"
|
" errx(1, \"SQLITE version mismatch: compiled %%u, now %%u\",\n"
|
||||||
" SQLITE_VERSION_NUMBER, sqlite3_libversion_number());\n"
|
" SQLITE_VERSION_NUMBER, sqlite3_libversion_number());\n"
|
||||||
|
)
|
||||||
" /* zlib documents that first char alters ABI. Kudos! */\n"
|
" /* zlib documents that first char alters ABI. Kudos! */\n"
|
||||||
" if (zlibVersion()[0] != ZLIB_VERSION[0])\n"
|
" if (zlibVersion()[0] != ZLIB_VERSION[0])\n"
|
||||||
" errx(1, \"zlib version mismatch: compiled %%s, now %%s\",\n"
|
" errx(1, \"zlib version mismatch: compiled %%s, now %%s\",\n"
|
||||||
@@ -60,7 +68,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
new = tal_fmt(NULL, template,
|
new = tal_fmt(NULL, template,
|
||||||
gmp_version,
|
gmp_version,
|
||||||
sqlite3_libversion_number(),
|
IF_SQLITE3(sqlite3_libversion_number(),)
|
||||||
zlibVersion());
|
zlibVersion());
|
||||||
if (!file || !streq(new, file)) {
|
if (!file || !streq(new, file)) {
|
||||||
int fd = open(argv[1], O_TRUNC|O_WRONLY|O_CREAT, 0666);
|
int fd = open(argv[1], O_TRUNC|O_WRONLY|O_CREAT, 0666);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include <ccan/autodata/autodata.h>
|
#include <ccan/autodata/autodata.h>
|
||||||
#include <ccan/list/list.h>
|
#include <ccan/list/list.h>
|
||||||
#include <ccan/short_types/short_types.h>
|
#include <ccan/short_types/short_types.h>
|
||||||
#include <sqlite3.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
/* For testing, we want to catch fatal messages. */
|
/* For testing, we want to catch fatal messages. */
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <ccan/ccan/tal/str/str.h>
|
#include <ccan/ccan/tal/str/str.h>
|
||||||
#include <ccan/endian/endian.h>
|
#include <ccan/endian/endian.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <sqlite3.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if HAVE_POSTGRES
|
#if HAVE_POSTGRES
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
#include "gen_db_sqlite3.c"
|
#include "gen_db_sqlite3.c"
|
||||||
#include <ccan/ccan/tal/str/str.h>
|
#include <ccan/ccan/tal/str/str.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
#include <sqlite3.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if HAVE_SQLITE3
|
#if HAVE_SQLITE3
|
||||||
|
#include <sqlite3.h>
|
||||||
|
|
||||||
#if !HAVE_SQLITE3_EXPANDED_SQL
|
#if !HAVE_SQLITE3_EXPANDED_SQL
|
||||||
/* Prior to sqlite3 v3.14, we have to use tracing to dump statements */
|
/* Prior to sqlite3 v3.14, we have to use tracing to dump statements */
|
||||||
|
|||||||
Reference in New Issue
Block a user