AryaWu/sqlite
0
1#!/usr/bin/make2# ^^^^ help out editors which guess this file's type.3#4# Makefile for SQLITE5#6# This makefile is intended to be configured automatically using the7# configure script.8#9# The docs for many of its variables are in the primary static10# makefile, main.mk (which this one includes at runtime).11#12all:13########################################################################14# Maintenance reminders:15#16# - This makefile should remain as POSIX-make-compatible as possible:17# https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html18#19# - The naming convention of some vars, using periods instead of20# underscores, though unconventional, was selected for a couple of21# reasons: 1) Personal taste (for which there is no accounting). 2)22# It is thought to help defend against inadvertent injection of23# those vars via environment variables (because X.Y is not a legal24# environment variable name). "Feature or bug?" is debatable and25# this naming convention may be reverted if it causes any grief.26#27 28#29# The top-most directory of the source tree. This is the directory30# that contains this "Makefile.in" and the "configure" script.31#32TOP = /sqlite33 34#35# Autotools-conventional vars which are used by package installation36# rules in main.mk. To get sane handling when a user overrides only37# a subset of these, we perform some acrobatics with these vars38# in the configure script: see [proj-remap-autoconf-dir-vars] for39# full details.40#41# For completeness's sake, the aforementioned conventional vars which42# are relevant to our installation rules are:43#44# datadir = $(prefix)/share45# mandir = $(datadir)/man46# includedir = $(prefix)/include47# exec_prefix = $(prefix)48# bindir = $(exec_prefix)/bin49# libdir = $(exec_prefix)/lib50#51# Our builds do not require any of their relatives:52#53# sbindir = $(exec_prefix)/sbin54# sysconfdir = /etc55# sharedstatedir = $(prefix)/com56# localstatedir = /var57# runstatedir = /run58# infodir = $(datadir)/info59# libexecdir = $(exec_prefix)/libexec60#61prefix = /usr/local62datadir = ${prefix}/share63mandir = ${datadir}/man64includedir = ${prefix}/include65exec_prefix = ${prefix}66bindir = ${exec_prefix}/bin67libdir = ${exec_prefix}/lib68 69INSTALL = /usr/bin/install70AR = ar71AR.flags = cr72CC = clang-1473B.cc = cc -g74T.cc = $(CC)75#76# $(CFLAGS) is problematic because it is frequently overridden when77# invoking make, which loses things like -fPIC. So... we avoid using78# it directly and instead add a level of indirection. We combine79# $(CFLAGS) and $(CPPFLAGS) here because that's the way the legacy80# build did it and many builds rely on that. See main.mk for more81# details.82#83# Historical note: the pre-3.48 build only honored CPPFLAGS at84# configure-time, and expanded them into the generated Makefile. There85# are, in that build, no uses of CPPFLAGS in the configure-expanded86# Makefile. Ergo: if a client configures with CPPFLAGS=... and then87# explicitly passes CFLAGS=... to make, the CPPFLAGS will be88# lost. That behavior is retained in 3.48+.89#90CFLAGS = -fpass-plugin=/usr/lib/mull-ir-frontend-14 -g -grecord-command-line -fprofile-instr-generate -fcoverage-mapping -DSQLITE_PRIVATE='' 91#92# $(LDFLAGS.configure) represents any LDFLAGS=... the client passes to93# configure. See main.mk.94#95LDFLAGS.configure = 96 97#98# CFLAGS.core is documented in main.mk.99#100CFLAGS.core = -fPIC101LDFLAGS.shlib = -shared102LDFLAGS.zlib = 103LDFLAGS.math = -lm104LDFLAGS.rpath = -rpath /usr/local/lib105LDFLAGS.pthread = 106LDFLAGS.dlopen = 107LDFLAGS.readline = 108CFLAGS.readline = 109LDFLAGS.icu = 110LDFLAGS.rt = 111CFLAGS.icu = 112LDFLAGS.libsqlite3.soname = 113# soname: see https://sqlite.org/src/forumpost/5a3b44f510df8ded114LDFLAGS.libsqlite3.os-specific = \115 116# os-specific: see117# - https://sqlite.org/forum/forumpost/9dfd5b8fd525a5d7118# - https://sqlite.org/forum/forumpost/0c7fc097b2119# - https://sqlite.org/forum/forumpost/5651662b8875ec0a120 121libsqlite3.DLL.basename = libsqlite3122# DLL.basename: see https://sqlite.org/forum/forumpost/828fdfe904123libsqlite3.out.implib = 124# libsqlite3.out.implib => the output filename part of LDFLAGS_OUT_IMPLIB.125ENABLE_LIB_SHARED = 1126ENABLE_LIB_STATIC = 1127HAVE_WASI_SDK = 0128libsqlite3.DLL.install-rules = unix-generic129 130# -fsanitize flags for the fuzzcheck-asap app131CFLAGS.fuzzcheck-asan.fsanitize = 132 133#134# Intended to either be empty or be set to -g -DSQLITE_DEBUG=1.135#136T.cc.TARGET_DEBUG = -DNDEBUG137 138#139# $(JIMSH) and $(CFLAGS.jimsh) are documented in main.mk. $(JIMSH)140# must start with a path component so that it can be invoked as a141# shell command.142#143CFLAGS.jimsh = -O1 -DHAVE_REALPATH144JIMSH = ./jimsh$(T.exe)145 146#147# $(B.tclsh) is documented in main.mk.148#149B.tclsh = $(JIMSH)150$(B.tclsh):151 152#153# $(OPT_FEATURE_FLAGS) is documented in main.mk.154#155# The appending of $(OPTIONS) to $(OPT_FEATURE_FLAGS) is historical156# and somewhat confusing because there's another var, $(OPTS), which157# has a similar (but not identical) role.158#159OPT_FEATURE_FLAGS = -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_PERCENTILE -DSQLITE_THREADSAFE=1 $(OPTIONS)160 161#162# Version (X.Y.Z) number for the SQLite being compiled.163#164PACKAGE_VERSION = 3.52.0165 166#167# Filename extensions for binaries and libraries168#169B.exe = 170T.exe = 171B.dll = .so172T.dll = .so173B.lib = .a174T.lib = .a175 176#177# $(HAVE_TCL) is 1 if the configure script was able to locate the178# tclConfig.sh file, else it is 0. When this variable is 1, the TCL179# extension library (libtclsqlite3.so) and related testing apps are180# built.181#182HAVE_TCL = 0183 184#185# $(TCLSH_CMD) is the command to use for tclsh - normally just186# "tclsh", but we may know the specific version we want to use. This187# must point to a canonical TCL interpreter, not JimTCL.188#189TCLSH_CMD = 190TCL_CONFIG_SH = 191 192#193# TCL config info from tclConfig.sh194#195# We have to inject this differently in main.mk to accommodate static196# makefiles, so we don't currently bother to export it here. This197# block is retained in case we decide that we do indeed need to export198# it at configure-time instead of calculate it at make-time.199#200#TCL_INCLUDE_SPEC = 201#TCL_LIB_SPEC = 202#TCL_STUB_LIB_SPEC = 203#TCL_EXEC_PREFIX = 204#TCL_VERSION = 205TCL_MAJOR_VERSION = 206# ^^^ main.mk optionally uses this for determining the Tcl extension's207# DLL name.208TCL_EXT_DLL_BASENAME = 209# ^^^ base name of the Tcl extension DLL. It varies by platform and210# Tcl version.211 212#213# $(TCLLIBDIR) = where to install the tcl plugin. If this is empty, it214# is calculated at make-time by the targets which need it but we215# export it here so that it can be set at configure-time, so that216# clients are not required to pass it at make-time, or may set it in217# their environment to override it.218#219TCLLIBDIR = 220 221#222# Additional options when running tests using testrunner.tcl223# This is usually either blank or --status.224#225TSTRNNR_OPTS = 226 227#228# If gcov support was enabled by the configure script, add the appropriate229# flags here. It's not always as easy as just having the user add the right230# CFLAGS / LDFLAGS, because libtool wants to use CFLAGS when linking, which231# causes build errors with -fprofile-arcs -ftest-coverage with some GCCs.232# Supposedly GCC does the right thing if you use --coverage, but in233# practice it still fails. See:234#235# http://www.mail-archive.com/debian-gcc@lists.debian.org/msg26197.html236#237# for more info.238#239CFLAGS.gcov1 = -DSQLITE_COVERAGE_TEST=1 -fprofile-arcs -ftest-coverage240LDFLAGS.gcov1 = -lgcov241USE_GCOV = 0242T.compile.gcov = $(CFLAGS.gcov$(USE_GCOV))243T.link.gcov = $(LDFLAGS.gcov$(USE_GCOV))244 245#246# Vars with the AS_ prefix are specifically related to AutoSetup.247#248# AS_AUTO_DEF is the main configure script.249#250AS_AUTO_DEF = $(TOP)/auto.def251#252# Shell commands to re-run $(TOP)/configure with the same args it was253# invoked with to produce this makefile.254#255AS_AUTORECONFIG = cd "/sqlite" && ./configure CC=clang-14 "CFLAGS=-fpass-plugin=/usr/lib/mull-ir-frontend-14 -g -grecord-command-line -fprofile-instr-generate -fcoverage-mapping -DSQLITE_PRIVATE=''"256.PHONY: config reconfigure257config reconfigure:258 $(AS_AUTORECONFIG)259USE_AMALGAMATION ?= 1260LINK_TOOLS_DYNAMICALLY ?= 0261AMALGAMATION_GEN_FLAGS ?= --linemacros=0262EXTRA_SRC ?= 263STATIC_TCLSQLITE3 = 0264STATIC_CLI_SHELL = 0265 266#267# CFLAGS for sqlite3$(T.exe)268#269SHELL_OPT ?= -DSQLITE_DQS=0 -DSQLITE_ENABLE_BYTECODE_VTAB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_OFFSET_SQL_FUNC -DSQLITE_ENABLE_PERCENTILE -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_STMTVTAB -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION -DSQLITE_STRICT_SUBTYPE=1270 271Makefile: $(TOP)/Makefile.in $(AS_AUTO_DEF)272 $(AS_AUTORECONFIG)273 @touch $@274 275sqlite3.pc: $(TOP)/sqlite3.pc.in $(AS_AUTO_DEF)276 $(AS_AUTORECONFIG)277 @touch $@278install: install-pc # defined in main.mk279 280sqlite_cfg.h: $(AS_AUTO_DEF)281 $(AS_AUTORECONFIG)282 @touch $@283 284#285# Fiddle app286#287# EMCC_WRAPPER must refer to the genuine emcc binary, or a288# call-compatible wrapper, e.g. $(TOP)/tool/emcc.sh. If it's empty,289# build components requiring Emscripten will not build.290#291# Achtung: though _this_ makefile is POSIX-make compatible, the fiddle292# build requires GNU make.293#294EMCC_WRAPPER = 295fiddle: sqlite3.c shell.c296 @if [ x = "x$(EMCC_WRAPPER)" ]; then \297 echo "Emscripten SDK not found by configure. Cannot build fiddle." 1&>2; \298 exit 1; \299 fi300 $(MAKE) -C ext/wasm fiddle emcc_opt=-Os301 302#303# Spell-checking for source comments304# The sources checked are either C sources or C source templates.305# Their comments are extracted and processed through aspell using306# a custom dictionary that contains scads of odd identifiers that307# find their way into the comments.308#309# Currently, this target is setup to be "made" in-tree only.310# The output is ephemeral. Redirect it to guide spelling fixups,311# either to correct spelling or add words to tool/custom.txt.312#313./custom.rws: ./tool/custom.txt314 @echo 'Updating custom dictionary from tool/custom.txt'315 aspell --lang=en create master ./custom.rws < ./tool/custom.txt316misspell: ./custom.rws has_tclsh84317# $(JIMSH) does not work with spellsift.tcl318 $(TCLSH_CMD) ./tool/spellsift.tcl ./src/*.c ./src/*.h ./src/*.in319 320#321# clean/distclean are mostly defined in main.mk. In this makefile we322# perform cleanup known to be relevant to (only) the autosetup-driven323# build.324#325distclean-autosetup:326 rm -f sqlite_cfg.h config.log config.status config.defines.* Makefile sqlite3.pc327 rm -f $(TOP)/tool/emcc.sh328 rm -f libsqlite3*$(T.dll)329 rm -f jimsh0*330distclean: distclean-autosetup331 332#333# tool/version-info: a utility for emitting sqlite3 version info334# in various forms. It's used by ext/wasm/.335#336version-info$(T.exe): $(TOP)/tool/version-info.c Makefile sqlite3.h337 $(T.link) $(ST_OPT) -o $@ $(TOP)/tool/version-info.c338 339include $(TOP)/main.mk340 