Makefile.in 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. #!/usr/bin/make
  2. # ^^^^ help out editors which guess this file's type.
  3. #
  4. # Makefile for SQLITE
  5. #
  6. # This makefile is intended to be configured automatically using the
  7. # configure script.
  8. #
  9. # The docs for many of its variables are in the primary static
  10. # makefile, main.mk (which this one includes at runtime).
  11. #
  12. all:
  13. ########################################################################
  14. #
  15. # Known TODOs/FIXMEs/TOIMPROVEs for the autosetup port, in no
  16. # particular order...
  17. #
  18. # - TEA pieces.
  19. #
  20. # - Replace the autotools-specific distribution deliverable(s).
  21. #
  22. # - Confirm whether cross-compilation works and patch it
  23. # appropriately.
  24. #
  25. # Maintenance reminders:
  26. #
  27. # - This makefile should remain as POSIX-make-compatible as possible:
  28. # https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html
  29. #
  30. # - The naming convention of some vars, using periods instead of
  31. # underscores, though unconventional, was selected for a couple of
  32. # reasons: 1) Personal taste (for which there is no accounting). 2)
  33. # It is thought to help defend against inadvertent injection of
  34. # those vars via environment variables (because X.Y is not a legal
  35. # environment variable name). "Feature or bug?" is debatable and
  36. # this naming convention may be reverted if it causes any grief.
  37. #
  38. #
  39. # The top-most directory of the source tree. This is the directory
  40. # that contains this "Makefile.in" and the "configure" script.
  41. #
  42. TOP = @abs_top_srcdir@
  43. #
  44. # Just testing some default dir expansions...
  45. # srcdir = @srcdir@
  46. # builddir = @builddir@
  47. # top_srcdir = @top_srcdir@
  48. # abs_top_srcdir = @abs_top_srcdir@
  49. # abs_top_builddir = @abs_top_builddir@
  50. #
  51. #
  52. # Autotools-conventional vars which are used by package installation
  53. # rules in main.mk.
  54. #
  55. # Autosetup allows the various XYZdir vars to be overridden at
  56. # configure-time with, e.g. --libdir=X and --mandir=Y. However,
  57. # defining them at configure-time, instead of at make-time, leads to
  58. # later awkwardness:
  59. #
  60. # $ ./configure --prefix=/usr
  61. # $ make prefix=/bar
  62. #
  63. # In that invocation, libdir will be /usr/foo, not /bar/foo as it
  64. # normally should, unless the user _also_ passes libdir=... to make.
  65. #
  66. # In 99%+ of use cases, setting prefix=X has the desired effect of
  67. # calculating conventional defaults for various other dirs, like
  68. # $prefix/lib, $prefix/include, etc. If, however, we export those at
  69. # configure-time, the passing prefix=... to make will update only
  70. # $prefix and none of its derived dirs.
  71. #
  72. # Because it is more important (for our use cases) that these vars be
  73. # overridable via a make invocation than a configure invocation, and
  74. # they conventionally derive from $(prefix) in all but the most exotic
  75. # of use cases, we do not export the configure-defined overrides of
  76. # those vars to this makefile. Instead, we export only $prefix and
  77. # its derived vars are set to their conventional default values in
  78. # main.mk, which users can then override at make-time as needed.
  79. # Overriding $prefix via make will also calculate any derived vars, as
  80. # one would expect, unless each is specifically overridden.
  81. #
  82. # For completeness's sake, the aforementioned conventional vars which
  83. # are relevant to our installation rules are:
  84. #
  85. # datadir = $(prefix)/share
  86. # mandir = $(datadir)/man
  87. # includedir = $(prefix)/include
  88. # exec_prefix = $(prefix)
  89. # bindir = $(exec_prefix)/bin
  90. # libdir = $(exec_prefix)/lib
  91. #
  92. # Our builds do not require any of their relatives:
  93. #
  94. # sbindir = $(exec_prefix)/sbin
  95. # sysconfdir = /etc
  96. # sharedstatedir = $(prefix)/com
  97. # localstatedir = /var
  98. # runstatedir = /run
  99. # infodir = $(datadir)/info
  100. # libexecdir = $(exec_prefix)/libexec
  101. #
  102. prefix = @prefix@
  103. datadir = @datadir@
  104. mandir = @mandir@
  105. includedir = @includedir@
  106. exec_prefix = @exec_prefix@
  107. bindir = @bindir@
  108. libdir = @libdir@
  109. INSTALL = @BIN_INSTALL@
  110. AR = @AR@
  111. AR.flags = cr # TODO? Add a configure test to determine this?
  112. CC = @CC@
  113. B.cc = @CC_FOR_BUILD@ @BUILD_CFLAGS@
  114. T.cc = $(CC)
  115. #
  116. # $(CFLAGS) is problematic because it is frequently overridden when
  117. # invoking make, which loses things like -fPIC. So... we avoid using
  118. # it directly and instead add a level of indirection. We combine
  119. # $(CFLAGS) and $(CPPFLAGS) here because that's the way the legacy
  120. # build did it and many builds rely on that. See main.mk for more
  121. # details.
  122. #
  123. # Historical note: the pre-3.48 build only honored CPPFLAGS at
  124. # configure-time, and expanded them into the generated Makefile. There
  125. # are, in that build, no uses of CPPFLAGS in the configure-expanded
  126. # Makefile. Ergo: if a client configures with CPPFLAGS=... and then
  127. # explicitly passes CFLAGS=... to make, the CPPFLAGS will be
  128. # lost. That behavior is retained in 3.48+ because also honoring
  129. # CPPFLAGS at make-time may have undesired side effects on any number
  130. # of builds.
  131. #
  132. CFLAGS = @CFLAGS@ @CPPFLAGS@
  133. #
  134. # $(LDFLAGS.configure) represents any LDFLAGS=... the client passes to
  135. # configure. See main.mk.
  136. #
  137. LDFLAGS.configure = @LDFLAGS@
  138. #
  139. # CFLAGS.core is documented in main.mk.
  140. #
  141. CFLAGS.core = @SH_CFLAGS@
  142. LDFLAGS.shlib = @SH_LDFLAGS@
  143. LDFLAGS.zlib = @LDFLAGS_ZLIB@
  144. LDFLAGS.math = @LDFLAGS_MATH@
  145. LDFLAGS.rpath = @LDFLAGS_RPATH@
  146. LDFLAGS.pthread = @LDFLAGS_PTHREAD@
  147. LDFLAGS.dlopen = @LDFLAGS_DLOPEN@
  148. LDFLAGS.readline = @LDFLAGS_READLINE@
  149. CFLAGS.readline = @CFLAGS_READLINE@
  150. LDFLAGS.icu = @LDFLAGS_ICU@
  151. CFLAGS.icu = @CFLAGS_ICU@
  152. LDFLAGS.libsqlite3.soname = @LDFLAGS_LIBSQLITE3_SONAME@
  153. ENABLE_SHARED = @ENABLE_SHARED@
  154. ENABLE_STATIC = @ENABLE_STATIC@
  155. HAVE_WASI_SDK = @HAVE_WASI_SDK@
  156. T.cc.sqlite = $(T.cc) @TARGET_DEBUG@
  157. #
  158. # Define -D_HAVE_SQLITE_CONFIG_H so that the code knows it
  159. # can include the generated sqlite_cfg.h.
  160. #
  161. # main.mk will fill out T.cc.sqlite with additional flags common to
  162. # all builds.
  163. #
  164. T.cc.sqlite += -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite
  165. #
  166. # $(JIMSH) and $(CFLAGS.jimsh) are documented in main.mk. $(JIMSH)
  167. # must start with a path component so that it can be invoked as a
  168. # shell command.
  169. #
  170. CFLAGS.jimsh = @CFLAGS_JIMSH@
  171. JIMSH = ./jimsh$(TEXE)
  172. #
  173. # $(B.tclsh) is documented in main.mk.
  174. #
  175. B.tclsh = @BTCLSH@
  176. $(B.tclsh):
  177. #
  178. # $(CFLAGS.libsqlite3) is documented in main.mk.
  179. #
  180. CFLAGS.libsqlite3 = -DSQLITE_TEMP_STORE=@TEMP_STORE@
  181. #
  182. # $(OPT_FEATURE_FLAGS) is documented in main.mk.
  183. #
  184. # The appending of $(OPTIONS) to $(OPT_FEATURE_FLAGS) is historical
  185. # and somewhat confusing because there's another var, $(OPTS), which
  186. # has a similar (but not identical) role.
  187. #
  188. OPT_FEATURE_FLAGS = @OPT_FEATURE_FLAGS@ $(OPTIONS)
  189. #
  190. # Version (X.Y.Z) number for the SQLite being compiled.
  191. #
  192. PACKAGE_VERSION = @PACKAGE_VERSION@
  193. #
  194. # Filename extensions for binaries and libraries
  195. #
  196. B.exe = @BUILD_EXEEXT@
  197. T.exe = @TARGET_EXEEXT@
  198. B.dll = @BUILD_DLLEXT@
  199. T.dll = @TARGET_DLLEXT@
  200. B.lib = @BUILD_LIBEXT@
  201. T.lib = @TARGET_LIBEXT@
  202. #
  203. # $(HAVE_TCL) is 1 if the configure script was able to locate the
  204. # tclConfig.sh file, else it is 0. When this variable is 1, the TCL
  205. # extension library (libtclsqlite3.so) and related testing apps are
  206. # built.
  207. #
  208. HAVE_TCL = @HAVE_TCL@
  209. #
  210. # $(TCLSH_CMD) is the command to use for tclsh - normally just
  211. # "tclsh", but we may know the specific version we want to use. This
  212. # must point to a canonical TCL interpreter, not JimTCL.
  213. #
  214. TCLSH_CMD = @TCLSH_CMD@
  215. TCL_CONFIG_SH = @TCL_CONFIG_SH@
  216. #
  217. # TCL config info from tclConfig.sh
  218. #
  219. # We have to inject this differently in main.mk to accommodate static
  220. # makefiles, so we don't currently bother to export it here. This
  221. # block is retained in case we decide that we do indeed need to export
  222. # it at configure-time instead of calculate it at make-time.
  223. #
  224. #TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
  225. #TCL_LIB_SPEC = @TCL_LIB_SPEC@
  226. #TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@
  227. #TCL_EXEC_PREFIX = @TCL_EXEC_PREFIX@
  228. #TCL_VERSION = @TCL_VERSION@
  229. #
  230. # $(TCLLIBDIR) = where to install the tcl plugin. If this is empty, it
  231. # is calculated at make-time by the targets which need it but we
  232. # export it here so that it can be set at configure-time, so that
  233. # clients are not required to pass it at make-time, or set it in their
  234. # environment, to override it.
  235. #
  236. TCLLIBDIR = @TCLLIBDIR@
  237. #
  238. # Additional options when running tests using testrunner.tcl
  239. # This is usually either blank, or else --status
  240. #
  241. TSTRNNR_OPTS = @TSTRNNR_OPTS@
  242. #
  243. # If gcov support was enabled by the configure script, add the appropriate
  244. # flags here. It's not always as easy as just having the user add the right
  245. # CFLAGS / LDFLAGS, because libtool wants to use CFLAGS when linking, which
  246. # causes build errors with -fprofile-arcs -ftest-coverage with some GCCs.
  247. # Supposedly GCC does the right thing if you use --coverage, but in
  248. # practice it still fails. See:
  249. #
  250. # http://www.mail-archive.com/debian-gcc@lists.debian.org/msg26197.html
  251. #
  252. # for more info.
  253. #
  254. CFLAGS.gcov1 = -DSQLITE_COVERAGE_TEST=1 -fprofile-arcs -ftest-coverage
  255. LDFLAGS.gcov1 = -lgcov
  256. USE_GCOV = @USE_GCOV@
  257. T.compile.extras = $(CFLAGS.gcov$(USE_GCOV))
  258. T.link.extras = $(LDFLAGS.gcov$(USE_GCOV))
  259. #
  260. # Vars with the AS_ prefix are specifically related to AutoSetup.
  261. #
  262. # AS_AUTO_DEF is the main configure script.
  263. #
  264. AS_AUTO_DEF = $(TOP)/auto.def
  265. #
  266. # Shell commands to re-run $(TOP)/configure with the same args it was
  267. # invoked with to produce this makefile.
  268. #
  269. AS_AUTORECONFIG = @SQLITE_AUTORECONFIG@
  270. USE_AMALGAMATION ?= @USE_AMALGAMATION@
  271. LINK_TOOLS_DYNAMICALLY ?= @LINK_TOOLS_DYNAMICALLY@
  272. AMALGAMATION_GEN_FLAGS ?= --linemacros=@AMALGAMATION_LINE_MACROS@
  273. #
  274. # CFLAGS for sqlite3$(T.exe)
  275. #
  276. SHELL_OPT ?= @OPT_SHELL@
  277. Makefile: $(TOP)/Makefile.in $(AS_AUTO_DEF)
  278. $(AS_AUTORECONFIG)
  279. @touch $@
  280. sqlite3.pc: $(TOP)/sqlite3.pc.in $(AS_AUTO_DEF)
  281. $(AS_AUTORECONFIG)
  282. @touch $@
  283. install: install-pc # defined in main.mk
  284. sqlite_cfg.h: $(AS_AUTO_DEF)
  285. $(AS_AUTORECONFIG)
  286. @touch $@
  287. #
  288. # Fiddle app
  289. #
  290. # EMCC_WRAPPER must refer to the genuine emcc binary, or a
  291. # call-compatible wrapper, e.g. $(TOP)/tool/emcc.sh. If it's empty,
  292. # build components requiring Emscripten will not build.
  293. #
  294. # Achtung: though _this_ makefile is POSIX-make compatible, the fiddle
  295. # build requires GNU make.
  296. #
  297. EMCC_WRAPPER = @EMCC_WRAPPER@
  298. fiddle: sqlite3.c shell.c
  299. @if [ x = "x$(EMCC_WRAPPER)" ]; then \
  300. echo "Emscripten SDK not found by configure. Cannot build fiddle." 1&>2; \
  301. exit 1; \
  302. fi
  303. $(MAKE) -C ext/wasm fiddle emcc_opt=-Os
  304. #
  305. # Spell-checking for source comments
  306. # The sources checked are either C sources or C source templates.
  307. # Their comments are extracted and processed through aspell using
  308. # a custom dictionary that contains scads of odd identifiers that
  309. # find their way into the comments.
  310. #
  311. # Currently, this target is setup to be "made" in-tree only.
  312. # The output is ephemeral. Redirect it to guide spelling fixups,
  313. # either to correct spelling or add words to tool/custom.txt.
  314. #
  315. ./custom.rws: ./tool/custom.txt
  316. @echo 'Updating custom dictionary from tool/custom.txt'
  317. aspell --lang=en create master ./custom.rws < ./tool/custom.txt
  318. # Note that jimsh does not work here:
  319. # https://github.com/msteveb/jimtcl/issues/319
  320. misspell: ./custom.rws has_tclsh84
  321. $(TCLSH_CMD) ./tool/spellsift.tcl ./src/*.c ./src/*.h ./src/*.in
  322. #
  323. # clean/distclean are mostly defined in main.mk. In this makefile we
  324. # perform cleanup known to be relevant to (only) the autosetup-driven
  325. # build.
  326. #
  327. #clean-autosetup:
  328. # -if [ -f ext/wasm/GNUmakefile ]; then \
  329. # gmake --no-print-directory --ignore-errors -C ext/wasm clean; \
  330. # fi >/dev/null 2>&1; true
  331. #clean: clean-autosetup
  332. distclean-autosetup: clean
  333. rm -f sqlite_cfg.h config.log config.status config.defines.* Makefile sqlite3.pc
  334. rm -f $(TOP)/tool/emcc.sh
  335. rm -f libsqlite3*$(T.dll)
  336. rm -f jimsh0*
  337. # -if [ -f ext/wasm/GNUmakefile ]; then \
  338. # gmake --no-print-directory --ignore-errors -C ext/wasm distclean; \
  339. # fi >/dev/null 2>&1; true
  340. distclean: distclean-autosetup
  341. #
  342. # tool/version-info: a utility for emitting sqlite3 version info
  343. # in various forms.
  344. #
  345. version-info$(T.exe): $(TOP)/tool/version-info.c Makefile sqlite3.h
  346. $(T.link) $(ST_OPT) -o $@ $(TOP)/tool/version-info.c
  347. include $(TOP)/main.mk