Fossil SCM

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

Keyboard Shortcuts

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