Makefile.in 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. # Autotools-conventional vars which are used by package installation
  45. # rules in main.mk. To get sane handling when a user overrides only
  46. # a subset of these, we perform some acrobatics with these vars
  47. # in the configure script: see [proj-remap-autoconf-dir-vars] for
  48. # full details.
  49. #
  50. # For completeness's sake, the aforementioned conventional vars which
  51. # are relevant to our installation rules are:
  52. #
  53. # datadir = $(prefix)/share
  54. # mandir = $(datadir)/man
  55. # includedir = $(prefix)/include
  56. # exec_prefix = $(prefix)
  57. # bindir = $(exec_prefix)/bin
  58. # libdir = $(exec_prefix)/lib
  59. #
  60. # Our builds do not require any of their relatives:
  61. #
  62. # sbindir = $(exec_prefix)/sbin
  63. # sysconfdir = /etc
  64. # sharedstatedir = $(prefix)/com
  65. # localstatedir = /var
  66. # runstatedir = /run
  67. # infodir = $(datadir)/info
  68. # libexecdir = $(exec_prefix)/libexec
  69. #
  70. prefix = @prefix@
  71. datadir = @datadir@
  72. mandir = @mandir@
  73. includedir = @includedir@
  74. exec_prefix = @exec_prefix@
  75. bindir = @bindir@
  76. libdir = @libdir@
  77. INSTALL = @BIN_INSTALL@
  78. AR = @AR@
  79. AR.flags = cr # TODO? Add a configure test to determine this?
  80. CC = @CC@
  81. B.cc = @CC_FOR_BUILD@ @BUILD_CFLAGS@
  82. T.cc = $(CC)
  83. #
  84. # $(CFLAGS) is problematic because it is frequently overridden when
  85. # invoking make, which loses things like -fPIC. So... we avoid using
  86. # it directly and instead add a level of indirection. We combine
  87. # $(CFLAGS) and $(CPPFLAGS) here because that's the way the legacy
  88. # build did it and many builds rely on that. See main.mk for more
  89. # details.
  90. #
  91. # Historical note: the pre-3.48 build only honored CPPFLAGS at
  92. # configure-time, and expanded them into the generated Makefile. There
  93. # are, in that build, no uses of CPPFLAGS in the configure-expanded
  94. # Makefile. Ergo: if a client configures with CPPFLAGS=... and then
  95. # explicitly passes CFLAGS=... to make, the CPPFLAGS will be
  96. # lost. That behavior is retained in 3.48+.
  97. #
  98. CFLAGS = @CFLAGS@ @CPPFLAGS@
  99. #
  100. # $(LDFLAGS.configure) represents any LDFLAGS=... the client passes to
  101. # configure. See main.mk.
  102. #
  103. LDFLAGS.configure = @LDFLAGS@
  104. #
  105. # CFLAGS.core is documented in main.mk.
  106. #
  107. CFLAGS.core = @SH_CFLAGS@
  108. LDFLAGS.shlib = @SH_LDFLAGS@
  109. LDFLAGS.zlib = @LDFLAGS_ZLIB@
  110. LDFLAGS.math = @LDFLAGS_MATH@
  111. LDFLAGS.rpath = @LDFLAGS_RPATH@
  112. LDFLAGS.pthread = @LDFLAGS_PTHREAD@
  113. LDFLAGS.dlopen = @LDFLAGS_DLOPEN@
  114. LDFLAGS.readline = @LDFLAGS_READLINE@
  115. CFLAGS.readline = @CFLAGS_READLINE@
  116. LDFLAGS.icu = @LDFLAGS_ICU@
  117. CFLAGS.icu = @CFLAGS_ICU@
  118. LDFLAGS.libsqlite3.soname = @LDFLAGS_LIBSQLITE3_SONAME@
  119. # soname: see https://sqlite.org/src/forumpost/5a3b44f510df8ded
  120. ENABLE_SHARED = @ENABLE_SHARED@
  121. ENABLE_STATIC = @ENABLE_STATIC@
  122. HAVE_WASI_SDK = @HAVE_WASI_SDK@
  123. T.cc.sqlite = $(T.cc) @TARGET_DEBUG@
  124. #
  125. # Define -D_HAVE_SQLITE_CONFIG_H so that the code knows it
  126. # can include the generated sqlite_cfg.h.
  127. #
  128. # main.mk will fill out T.cc.sqlite with additional flags common to
  129. # all builds.
  130. #
  131. T.cc.sqlite += -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite
  132. #
  133. # $(JIMSH) and $(CFLAGS.jimsh) are documented in main.mk. $(JIMSH)
  134. # must start with a path component so that it can be invoked as a
  135. # shell command.
  136. #
  137. CFLAGS.jimsh = @CFLAGS_JIMSH@
  138. JIMSH = ./jimsh$(TEXE)
  139. #
  140. # $(B.tclsh) is documented in main.mk.
  141. #
  142. B.tclsh = @BTCLSH@
  143. $(B.tclsh):
  144. #
  145. # $(OPT_FEATURE_FLAGS) is documented in main.mk.
  146. #
  147. # The appending of $(OPTIONS) to $(OPT_FEATURE_FLAGS) is historical
  148. # and somewhat confusing because there's another var, $(OPTS), which
  149. # has a similar (but not identical) role.
  150. #
  151. OPT_FEATURE_FLAGS = @OPT_FEATURE_FLAGS@ $(OPTIONS)
  152. #
  153. # Version (X.Y.Z) number for the SQLite being compiled.
  154. #
  155. PACKAGE_VERSION = @PACKAGE_VERSION@
  156. #
  157. # Filename extensions for binaries and libraries
  158. #
  159. B.exe = @BUILD_EXEEXT@
  160. T.exe = @TARGET_EXEEXT@
  161. B.dll = @BUILD_DLLEXT@
  162. T.dll = @TARGET_DLLEXT@
  163. B.lib = @BUILD_LIBEXT@
  164. T.lib = @TARGET_LIBEXT@
  165. #
  166. # $(HAVE_TCL) is 1 if the configure script was able to locate the
  167. # tclConfig.sh file, else it is 0. When this variable is 1, the TCL
  168. # extension library (libtclsqlite3.so) and related testing apps are
  169. # built.
  170. #
  171. HAVE_TCL = @HAVE_TCL@
  172. #
  173. # $(TCLSH_CMD) is the command to use for tclsh - normally just
  174. # "tclsh", but we may know the specific version we want to use. This
  175. # must point to a canonical TCL interpreter, not JimTCL.
  176. #
  177. TCLSH_CMD = @TCLSH_CMD@
  178. TCL_CONFIG_SH = @TCL_CONFIG_SH@
  179. #
  180. # TCL config info from tclConfig.sh
  181. #
  182. # We have to inject this differently in main.mk to accommodate static
  183. # makefiles, so we don't currently bother to export it here. This
  184. # block is retained in case we decide that we do indeed need to export
  185. # it at configure-time instead of calculate it at make-time.
  186. #
  187. #TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
  188. #TCL_LIB_SPEC = @TCL_LIB_SPEC@
  189. #TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@
  190. #TCL_EXEC_PREFIX = @TCL_EXEC_PREFIX@
  191. #TCL_VERSION = @TCL_VERSION@
  192. #
  193. # $(TCLLIBDIR) = where to install the tcl plugin. If this is empty, it
  194. # is calculated at make-time by the targets which need it but we
  195. # export it here so that it can be set at configure-time, so that
  196. # clients are not required to pass it at make-time, or may set it in
  197. # their environment to override it.
  198. #
  199. TCLLIBDIR = @TCLLIBDIR@
  200. #
  201. # Additional options when running tests using testrunner.tcl
  202. # This is usually either blank or --status.
  203. #
  204. TSTRNNR_OPTS = @TSTRNNR_OPTS@
  205. #
  206. # If gcov support was enabled by the configure script, add the appropriate
  207. # flags here. It's not always as easy as just having the user add the right
  208. # CFLAGS / LDFLAGS, because libtool wants to use CFLAGS when linking, which
  209. # causes build errors with -fprofile-arcs -ftest-coverage with some GCCs.
  210. # Supposedly GCC does the right thing if you use --coverage, but in
  211. # practice it still fails. See:
  212. #
  213. # http://www.mail-archive.com/debian-gcc@lists.debian.org/msg26197.html
  214. #
  215. # for more info.
  216. #
  217. CFLAGS.gcov1 = -DSQLITE_COVERAGE_TEST=1 -fprofile-arcs -ftest-coverage
  218. LDFLAGS.gcov1 = -lgcov
  219. USE_GCOV = @USE_GCOV@
  220. T.compile.extras = $(CFLAGS.gcov$(USE_GCOV))
  221. T.link.extras = $(LDFLAGS.gcov$(USE_GCOV))
  222. #
  223. # Vars with the AS_ prefix are specifically related to AutoSetup.
  224. #
  225. # AS_AUTO_DEF is the main configure script.
  226. #
  227. AS_AUTO_DEF = $(TOP)/auto.def
  228. #
  229. # Shell commands to re-run $(TOP)/configure with the same args it was
  230. # invoked with to produce this makefile.
  231. #
  232. AS_AUTORECONFIG = @SQLITE_AUTORECONFIG@
  233. USE_AMALGAMATION ?= @USE_AMALGAMATION@
  234. LINK_TOOLS_DYNAMICALLY ?= @LINK_TOOLS_DYNAMICALLY@
  235. AMALGAMATION_GEN_FLAGS ?= --linemacros=@AMALGAMATION_LINE_MACROS@
  236. #
  237. # CFLAGS for sqlite3$(T.exe)
  238. #
  239. SHELL_OPT ?= @OPT_SHELL@
  240. Makefile: $(TOP)/Makefile.in $(AS_AUTO_DEF)
  241. $(AS_AUTORECONFIG)
  242. @touch $@
  243. sqlite3.pc: $(TOP)/sqlite3.pc.in $(AS_AUTO_DEF)
  244. $(AS_AUTORECONFIG)
  245. @touch $@
  246. install: install-pc # defined in main.mk
  247. sqlite_cfg.h: $(AS_AUTO_DEF)
  248. $(AS_AUTORECONFIG)
  249. @touch $@
  250. #
  251. # Fiddle app
  252. #
  253. # EMCC_WRAPPER must refer to the genuine emcc binary, or a
  254. # call-compatible wrapper, e.g. $(TOP)/tool/emcc.sh. If it's empty,
  255. # build components requiring Emscripten will not build.
  256. #
  257. # Achtung: though _this_ makefile is POSIX-make compatible, the fiddle
  258. # build requires GNU make.
  259. #
  260. EMCC_WRAPPER = @EMCC_WRAPPER@
  261. fiddle: sqlite3.c shell.c
  262. @if [ x = "x$(EMCC_WRAPPER)" ]; then \
  263. echo "Emscripten SDK not found by configure. Cannot build fiddle." 1&>2; \
  264. exit 1; \
  265. fi
  266. $(MAKE) -C ext/wasm fiddle emcc_opt=-Os
  267. #
  268. # Spell-checking for source comments
  269. # The sources checked are either C sources or C source templates.
  270. # Their comments are extracted and processed through aspell using
  271. # a custom dictionary that contains scads of odd identifiers that
  272. # find their way into the comments.
  273. #
  274. # Currently, this target is setup to be "made" in-tree only.
  275. # The output is ephemeral. Redirect it to guide spelling fixups,
  276. # either to correct spelling or add words to tool/custom.txt.
  277. #
  278. ./custom.rws: ./tool/custom.txt
  279. @echo 'Updating custom dictionary from tool/custom.txt'
  280. aspell --lang=en create master ./custom.rws < ./tool/custom.txt
  281. # Note that jimsh does not work here:
  282. # https://github.com/msteveb/jimtcl/issues/319
  283. misspell: ./custom.rws has_tclsh84
  284. $(TCLSH_CMD) ./tool/spellsift.tcl ./src/*.c ./src/*.h ./src/*.in
  285. #
  286. # clean/distclean are mostly defined in main.mk. In this makefile we
  287. # perform cleanup known to be relevant to (only) the autosetup-driven
  288. # build.
  289. #
  290. #clean-autosetup:
  291. # -if [ -f ext/wasm/GNUmakefile ]; then \
  292. # gmake --no-print-directory --ignore-errors -C ext/wasm clean; \
  293. # fi >/dev/null 2>&1; true
  294. #clean: clean-autosetup
  295. distclean-autosetup: clean
  296. rm -f sqlite_cfg.h config.log config.status config.defines.* Makefile sqlite3.pc
  297. rm -f $(TOP)/tool/emcc.sh
  298. rm -f libsqlite3*$(T.dll)
  299. rm -f jimsh0*
  300. # -if [ -f ext/wasm/GNUmakefile ]; then \
  301. # gmake --no-print-directory --ignore-errors -C ext/wasm distclean; \
  302. # fi >/dev/null 2>&1; true
  303. distclean: distclean-autosetup
  304. #
  305. # tool/version-info: a utility for emitting sqlite3 version info
  306. # in various forms.
  307. #
  308. version-info$(T.exe): $(TOP)/tool/version-info.c Makefile sqlite3.h
  309. $(T.link) $(ST_OPT) -o $@ $(TOP)/tool/version-info.c
  310. include $(TOP)/main.mk