Fossil SCM

fossil-scm / tools / sqlcompattest.c
Blame History Raw 90 lines
1
/*
2
** Copyright (c) 2019 D. Richard Hipp
3
**
4
** This program is free software; you can redistribute it and/or
5
** modify it under the terms of the Simplified BSD License (also
6
** known as the "2-Clause License" or "FreeBSD License".)
7
**
8
** This program is distributed in the hope that it will be useful,
9
** but without any warranty; without even the implied warranty of
10
** merchantability or fitness for a particular purpose.
11
**
12
** Author contact information:
13
** [email protected]
14
** http://www.hwaci.com/drh/
15
**
16
*******************************************************************************
17
**
18
** This file is NOT part of the Fossil executable. It is called from
19
** auto.def in the autosetup system.
20
**
21
** This file contains a test program used by ../configure with the
22
** the --disable-internal-sqlite option to determine whether or
23
** not the system SQLite library is sufficient to support Fossil.
24
**
25
** This must be compiled with -D MINIMUM_SQLITE_VERSION set in auto.def.
26
**
27
** It is preferred to statically link Fossil with the sqlite3.c source
28
** file that is part of the source tree and not use any SQLite shared
29
** library that is included with the system. But some packagers do not
30
** like to do this. Hence, we provide the option to link Fossil against
31
** the system SQLite shared library. But Fossil is very particular about
32
** the version and build options for SQLite. Unless a recent version of
33
** SQLite is available, and unless that SQLite is built using some
34
** non-default features, the system library won't meet the needs of
35
** Fossil. This program attempts to determine if the system library
36
** SQLite is sufficient for Fossil.
37
**
38
** Compile this program, linking it against the system SQLite library,
39
** and run it. If it returns with a zero exit code, then all is well.
40
** But if it returns a non-zero exit code, then the system SQLite library
41
** lacks some capability that Fossil uses. A message on stdout describes
42
** the missing feature.
43
*/
44
#include "sqlite3.h"
45
#include <stdio.h>
46
#include <string.h>
47
48
int main(int argc, char **argv){
49
50
#if !defined(MINIMUM_SQLITE_VERSION)
51
#error "Must set -DMINIMUM_SQLITE_VERSION=nn.nn.nn in auto.def"
52
#endif
53
54
#define QUOTE(VAL) #VAL
55
#define STR(MACRO_VAL) QUOTE(MACRO_VAL)
56
57
char zMinimumVersionNumber[8]="nn.nn.nn";
58
strncpy((char *)&zMinimumVersionNumber,STR(MINIMUM_SQLITE_VERSION),
59
sizeof(zMinimumVersionNumber));
60
61
long major, minor, release, version;
62
sscanf(zMinimumVersionNumber, "%li.%li.%li", &major, &minor, &release);
63
version=(major*1000000)+(minor*1000)+release;
64
65
int i;
66
static const char *zRequiredOpts[] = {
67
"ENABLE_FTS4", /* Required for repository search */
68
"ENABLE_DBSTAT_VTAB", /* Required by /repo-tabsize page */
69
};
70
71
/* Check minimum SQLite version number */
72
if( sqlite3_libversion_number()<version ){
73
printf("found system SQLite version %s but need %s or later, "
74
"consider removing --disable-internal-sqlite\n",
75
sqlite3_libversion(),STR(MINIMUM_SQLITE_VERSION));
76
return 1;
77
}
78
79
for(i=0; i<sizeof(zRequiredOpts)/sizeof(zRequiredOpts[0]); i++){
80
if( !sqlite3_compileoption_used(zRequiredOpts[i]) ){
81
printf("system SQLite library omits required build option -DSQLITE_%s\n",
82
zRequiredOpts[i]);
83
return 1;
84
}
85
}
86
87
/* Success! */
88
return 0;
89
}
90

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button