|
@ -12,10 +12,42 @@ |
|
|
#include <sys/types.h> |
|
|
#include <sys/types.h> |
|
|
#include <zlib.h> |
|
|
#include <zlib.h> |
|
|
|
|
|
|
|
|
|
|
|
static const char template[] = |
|
|
|
|
|
"/* Generated file by tools/headerversions, do not edit! */\n" |
|
|
|
|
|
"/* GMP version: %s */\n" |
|
|
|
|
|
"/* SQLITE3 version: %u */\n" |
|
|
|
|
|
"/* ZLIB version: %s */\n" |
|
|
|
|
|
"#include <ccan/err/err.h>\n" |
|
|
|
|
|
"#include <gmp.h>\n" |
|
|
|
|
|
"#include <sqlite3.h>\n" |
|
|
|
|
|
"#include <zlib.h>\n" |
|
|
|
|
|
"\n" |
|
|
|
|
|
"static inline void check_linked_library_versions(void)\n" |
|
|
|
|
|
"{\n" |
|
|
|
|
|
" char compiled_gmp_version[100];\n" |
|
|
|
|
|
" if (SQLITE_VERSION_NUMBER != sqlite3_libversion_number())\n" |
|
|
|
|
|
" errx(1, \"SQLITE version mismatch: compiled %%u, now %%u\",\n" |
|
|
|
|
|
" SQLITE_VERSION_NUMBER, sqlite3_libversion_number());\n" |
|
|
|
|
|
" /* zlib documents that first char alters ABI. Kudos! */\n" |
|
|
|
|
|
" if (zlibVersion()[0] != ZLIB_VERSION[0])\n" |
|
|
|
|
|
" errx(1, \"zlib version mismatch: compiled %%s, now %%s\",\n" |
|
|
|
|
|
" ZLIB_VERSION, zlibVersion());\n" |
|
|
|
|
|
" /* GMP doesn't say anything, and we have to assemble our own string. */\n" |
|
|
|
|
|
" snprintf(compiled_gmp_version, sizeof(compiled_gmp_version),\n" |
|
|
|
|
|
" \"%%u.%%u.%%u\",\n" |
|
|
|
|
|
" __GNU_MP_VERSION,\n" |
|
|
|
|
|
" __GNU_MP_VERSION_MINOR,\n" |
|
|
|
|
|
" __GNU_MP_VERSION_PATCHLEVEL);\n" |
|
|
|
|
|
" if (strcmp(compiled_gmp_version, gmp_version) != 0)\n" |
|
|
|
|
|
" errx(1, \"gmp version mismatch: compiled %%s, now %%s\",\n" |
|
|
|
|
|
" compiled_gmp_version, gmp_version);\n" |
|
|
|
|
|
"}\n"; |
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) |
|
|
int main(int argc, char *argv[]) |
|
|
{ |
|
|
{ |
|
|
char *file, *new; |
|
|
char *file, *new; |
|
|
|
|
|
|
|
|
|
|
|
/* We don't bother with setup_locale(); we're a build tool */ |
|
|
err_set_progname(argv[0]); |
|
|
err_set_progname(argv[0]); |
|
|
|
|
|
|
|
|
if (argc != 2) |
|
|
if (argc != 2) |
|
@ -25,11 +57,7 @@ int main(int argc, char *argv[]) |
|
|
if (!file && errno != ENOENT) |
|
|
if (!file && errno != ENOENT) |
|
|
err(1, "Reading %s", argv[1]); |
|
|
err(1, "Reading %s", argv[1]); |
|
|
|
|
|
|
|
|
new = tal_fmt(NULL, |
|
|
new = tal_fmt(NULL, template, |
|
|
"/* Generated file by tools/headerversions, do not edit! */\n" |
|
|
|
|
|
"/* GMP version: %s */\n" |
|
|
|
|
|
"/* SQLITE3 version: %u */\n" |
|
|
|
|
|
"/* ZLIB version: %s */\n", |
|
|
|
|
|
gmp_version, |
|
|
gmp_version, |
|
|
sqlite3_libversion_number(), |
|
|
sqlite3_libversion_number(), |
|
|
zlibVersion()); |
|
|
zlibVersion()); |
|
|