Kitxuuu commited on
Commit
210394b
·
verified ·
1 Parent(s): de43fd8

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. local-test-sqlite3-delta-02/afc-sqlite3/art/sqlite370.eps +0 -0
  2. local-test-sqlite3-delta-02/afc-sqlite3/art/sqlite370.ico +0 -0
  3. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/INSTALL +370 -0
  4. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/Makefile.am +20 -0
  5. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/Makefile.fallback +19 -0
  6. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/Makefile.msc +1098 -0
  7. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/README.first +11 -0
  8. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/README.txt +100 -0
  9. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/configure.ac +270 -0
  10. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/Makefile.in +463 -0
  11. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/README.txt +78 -0
  12. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/aclocal.m4 +9 -0
  13. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/configure.ac +227 -0
  14. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/doc/sqlite3.n +15 -0
  15. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/license.terms +6 -0
  16. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/pkgIndex.tcl.in +10 -0
  17. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/tclconfig/install-sh +541 -0
  18. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/tclconfig/tcl.m4 +0 -0
  19. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/win/makefile.vc +61 -0
  20. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/win/nmakehlp.c +815 -0
  21. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/win/rules-ext.vc +123 -0
  22. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/win/rules.vc +1913 -0
  23. local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/win/targets.vc +98 -0
  24. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/LICENSE +35 -0
  25. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/README.autosetup +11 -0
  26. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/README.md +318 -0
  27. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/autosetup +2536 -0
  28. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/autosetup-config.guess +1815 -0
  29. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/autosetup-config.sub +2354 -0
  30. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/autosetup-find-tclsh +16 -0
  31. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/autosetup-test-tclsh +20 -0
  32. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/cc-db.tcl +15 -0
  33. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/cc-lib.tcl +187 -0
  34. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/cc-shared.tcl +113 -0
  35. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/cc.tcl +758 -0
  36. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/jimsh0.c +0 -0
  37. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/pkg-config.tcl +168 -0
  38. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/proj.tcl +1269 -0
  39. local-test-sqlite3-delta-02/afc-sqlite3/autosetup/system.tcl +420 -0
  40. local-test-sqlite3-delta-02/afc-sqlite3/contrib/sqlitecon.tcl +679 -0
  41. local-test-sqlite3-delta-02/afc-sqlite3/doc/F2FS.txt +87 -0
  42. local-test-sqlite3-delta-02/afc-sqlite3/doc/compile-for-unix.md +66 -0
  43. local-test-sqlite3-delta-02/afc-sqlite3/doc/compile-for-windows.md +175 -0
  44. local-test-sqlite3-delta-02/afc-sqlite3/doc/json-enhancements.md +144 -0
  45. local-test-sqlite3-delta-02/afc-sqlite3/doc/jsonb.md +290 -0
  46. local-test-sqlite3-delta-02/afc-sqlite3/doc/lemon.html +1282 -0
  47. local-test-sqlite3-delta-02/afc-sqlite3/doc/pager-invariants.txt +76 -0
  48. local-test-sqlite3-delta-02/afc-sqlite3/doc/testrunner.md +356 -0
  49. local-test-sqlite3-delta-02/afc-sqlite3/doc/trusted-schema.md +142 -0
  50. local-test-sqlite3-delta-02/afc-sqlite3/doc/vdbesort-memory.md +49 -0
local-test-sqlite3-delta-02/afc-sqlite3/art/sqlite370.eps ADDED
The diff for this file is too large to render. See raw diff
 
local-test-sqlite3-delta-02/afc-sqlite3/art/sqlite370.ico ADDED
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/INSTALL ADDED
@@ -0,0 +1,370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Installation Instructions
2
+ *************************
3
+
4
+ Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation,
5
+ Inc.
6
+
7
+ Copying and distribution of this file, with or without modification,
8
+ are permitted in any medium without royalty provided the copyright
9
+ notice and this notice are preserved. This file is offered as-is,
10
+ without warranty of any kind.
11
+
12
+ Basic Installation
13
+ ==================
14
+
15
+ Briefly, the shell commands `./configure; make; make install' should
16
+ configure, build, and install this package. The following
17
+ more-detailed instructions are generic; see the `README' file for
18
+ instructions specific to this package. Some packages provide this
19
+ `INSTALL' file but do not implement all of the features documented
20
+ below. The lack of an optional feature in a given package is not
21
+ necessarily a bug. More recommendations for GNU packages can be found
22
+ in *note Makefile Conventions: (standards)Makefile Conventions.
23
+
24
+ The `configure' shell script attempts to guess correct values for
25
+ various system-dependent variables used during compilation. It uses
26
+ those values to create a `Makefile' in each directory of the package.
27
+ It may also create one or more `.h' files containing system-dependent
28
+ definitions. Finally, it creates a shell script `config.status' that
29
+ you can run in the future to recreate the current configuration, and a
30
+ file `config.log' containing compiler output (useful mainly for
31
+ debugging `configure').
32
+
33
+ It can also use an optional file (typically called `config.cache'
34
+ and enabled with `--cache-file=config.cache' or simply `-C') that saves
35
+ the results of its tests to speed up reconfiguring. Caching is
36
+ disabled by default to prevent problems with accidental use of stale
37
+ cache files.
38
+
39
+ If you need to do unusual things to compile the package, please try
40
+ to figure out how `configure' could check whether to do them, and mail
41
+ diffs or instructions to the address given in the `README' so they can
42
+ be considered for the next release. If you are using the cache, and at
43
+ some point `config.cache' contains results you don't want to keep, you
44
+ may remove or edit it.
45
+
46
+ The file `configure.ac' (or `configure.in') is used to create
47
+ `configure' by a program called `autoconf'. You need `configure.ac' if
48
+ you want to change it or regenerate `configure' using a newer version
49
+ of `autoconf'.
50
+
51
+ The simplest way to compile this package is:
52
+
53
+ 1. `cd' to the directory containing the package's source code and type
54
+ `./configure' to configure the package for your system.
55
+
56
+ Running `configure' might take a while. While running, it prints
57
+ some messages telling which features it is checking for.
58
+
59
+ 2. Type `make' to compile the package.
60
+
61
+ 3. Optionally, type `make check' to run any self-tests that come with
62
+ the package, generally using the just-built uninstalled binaries.
63
+
64
+ 4. Type `make install' to install the programs and any data files and
65
+ documentation. When installing into a prefix owned by root, it is
66
+ recommended that the package be configured and built as a regular
67
+ user, and only the `make install' phase executed with root
68
+ privileges.
69
+
70
+ 5. Optionally, type `make installcheck' to repeat any self-tests, but
71
+ this time using the binaries in their final installed location.
72
+ This target does not install anything. Running this target as a
73
+ regular user, particularly if the prior `make install' required
74
+ root privileges, verifies that the installation completed
75
+ correctly.
76
+
77
+ 6. You can remove the program binaries and object files from the
78
+ source code directory by typing `make clean'. To also remove the
79
+ files that `configure' created (so you can compile the package for
80
+ a different kind of computer), type `make distclean'. There is
81
+ also a `make maintainer-clean' target, but that is intended mainly
82
+ for the package's developers. If you use it, you may have to get
83
+ all sorts of other programs in order to regenerate files that came
84
+ with the distribution.
85
+
86
+ 7. Often, you can also type `make uninstall' to remove the installed
87
+ files again. In practice, not all packages have tested that
88
+ uninstallation works correctly, even though it is required by the
89
+ GNU Coding Standards.
90
+
91
+ 8. Some packages, particularly those that use Automake, provide `make
92
+ distcheck', which can by used by developers to test that all other
93
+ targets like `make install' and `make uninstall' work correctly.
94
+ This target is generally not run by end users.
95
+
96
+ Compilers and Options
97
+ =====================
98
+
99
+ Some systems require unusual options for compilation or linking that
100
+ the `configure' script does not know about. Run `./configure --help'
101
+ for details on some of the pertinent environment variables.
102
+
103
+ You can give `configure' initial values for configuration parameters
104
+ by setting variables in the command line or in the environment. Here
105
+ is an example:
106
+
107
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
108
+
109
+ *Note Defining Variables::, for more details.
110
+
111
+ Compiling For Multiple Architectures
112
+ ====================================
113
+
114
+ You can compile the package for more than one kind of computer at the
115
+ same time, by placing the object files for each architecture in their
116
+ own directory. To do this, you can use GNU `make'. `cd' to the
117
+ directory where you want the object files and executables to go and run
118
+ the `configure' script. `configure' automatically checks for the
119
+ source code in the directory that `configure' is in and in `..'. This
120
+ is known as a "VPATH" build.
121
+
122
+ With a non-GNU `make', it is safer to compile the package for one
123
+ architecture at a time in the source code directory. After you have
124
+ installed the package for one architecture, use `make distclean' before
125
+ reconfiguring for another architecture.
126
+
127
+ On MacOS X 10.5 and later systems, you can create libraries and
128
+ executables that work on multiple system types--known as "fat" or
129
+ "universal" binaries--by specifying multiple `-arch' options to the
130
+ compiler but only a single `-arch' option to the preprocessor. Like
131
+ this:
132
+
133
+ ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
134
+ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
135
+ CPP="gcc -E" CXXCPP="g++ -E"
136
+
137
+ This is not guaranteed to produce working output in all cases, you
138
+ may have to build one architecture at a time and combine the results
139
+ using the `lipo' tool if you have problems.
140
+
141
+ Installation Names
142
+ ==================
143
+
144
+ By default, `make install' installs the package's commands under
145
+ `/usr/local/bin', include files under `/usr/local/include', etc. You
146
+ can specify an installation prefix other than `/usr/local' by giving
147
+ `configure' the option `--prefix=PREFIX', where PREFIX must be an
148
+ absolute file name.
149
+
150
+ You can specify separate installation prefixes for
151
+ architecture-specific files and architecture-independent files. If you
152
+ pass the option `--exec-prefix=PREFIX' to `configure', the package uses
153
+ PREFIX as the prefix for installing programs and libraries.
154
+ Documentation and other data files still use the regular prefix.
155
+
156
+ In addition, if you use an unusual directory layout you can give
157
+ options like `--bindir=DIR' to specify different values for particular
158
+ kinds of files. Run `configure --help' for a list of the directories
159
+ you can set and what kinds of files go in them. In general, the
160
+ default for these options is expressed in terms of `${prefix}', so that
161
+ specifying just `--prefix' will affect all of the other directory
162
+ specifications that were not explicitly provided.
163
+
164
+ The most portable way to affect installation locations is to pass the
165
+ correct locations to `configure'; however, many packages provide one or
166
+ both of the following shortcuts of passing variable assignments to the
167
+ `make install' command line to change installation locations without
168
+ having to reconfigure or recompile.
169
+
170
+ The first method involves providing an override variable for each
171
+ affected directory. For example, `make install
172
+ prefix=/alternate/directory' will choose an alternate location for all
173
+ directory configuration variables that were expressed in terms of
174
+ `${prefix}'. Any directories that were specified during `configure',
175
+ but not in terms of `${prefix}', must each be overridden at install
176
+ time for the entire installation to be relocated. The approach of
177
+ makefile variable overrides for each directory variable is required by
178
+ the GNU Coding Standards, and ideally causes no recompilation.
179
+ However, some platforms have known limitations with the semantics of
180
+ shared libraries that end up requiring recompilation when using this
181
+ method, particularly noticeable in packages that use GNU Libtool.
182
+
183
+ The second method involves providing the `DESTDIR' variable. For
184
+ example, `make install DESTDIR=/alternate/directory' will prepend
185
+ `/alternate/directory' before all installation names. The approach of
186
+ `DESTDIR' overrides is not required by the GNU Coding Standards, and
187
+ does not work on platforms that have drive letters. On the other hand,
188
+ it does better at avoiding recompilation issues, and works well even
189
+ when some directory options were not specified in terms of `${prefix}'
190
+ at `configure' time.
191
+
192
+ Optional Features
193
+ =================
194
+
195
+ If the package supports it, you can cause programs to be installed
196
+ with an extra prefix or suffix on their names by giving `configure' the
197
+ option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
198
+
199
+ Some packages pay attention to `--enable-FEATURE' options to
200
+ `configure', where FEATURE indicates an optional part of the package.
201
+ They may also pay attention to `--with-PACKAGE' options, where PACKAGE
202
+ is something like `gnu-as' or `x' (for the X Window System). The
203
+ `README' should mention any `--enable-' and `--with-' options that the
204
+ package recognizes.
205
+
206
+ For packages that use the X Window System, `configure' can usually
207
+ find the X include and library files automatically, but if it doesn't,
208
+ you can use the `configure' options `--x-includes=DIR' and
209
+ `--x-libraries=DIR' to specify their locations.
210
+
211
+ Some packages offer the ability to configure how verbose the
212
+ execution of `make' will be. For these packages, running `./configure
213
+ --enable-silent-rules' sets the default to minimal output, which can be
214
+ overridden with `make V=1'; while running `./configure
215
+ --disable-silent-rules' sets the default to verbose, which can be
216
+ overridden with `make V=0'.
217
+
218
+ Particular systems
219
+ ==================
220
+
221
+ On HP-UX, the default C compiler is not ANSI C compatible. If GNU
222
+ CC is not installed, it is recommended to use the following options in
223
+ order to use an ANSI C compiler:
224
+
225
+ ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
226
+
227
+ and if that doesn't work, install pre-built binaries of GCC for HP-UX.
228
+
229
+ HP-UX `make' updates targets which have the same time stamps as
230
+ their prerequisites, which makes it generally unusable when shipped
231
+ generated files such as `configure' are involved. Use GNU `make'
232
+ instead.
233
+
234
+ On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
235
+ parse its `<wchar.h>' header file. The option `-nodtk' can be used as
236
+ a workaround. If GNU CC is not installed, it is therefore recommended
237
+ to try
238
+
239
+ ./configure CC="cc"
240
+
241
+ and if that doesn't work, try
242
+
243
+ ./configure CC="cc -nodtk"
244
+
245
+ On Solaris, don't put `/usr/ucb' early in your `PATH'. This
246
+ directory contains several dysfunctional programs; working variants of
247
+ these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
248
+ in your `PATH', put it _after_ `/usr/bin'.
249
+
250
+ On Haiku, software installed for all users goes in `/boot/common',
251
+ not `/usr/local'. It is recommended to use the following options:
252
+
253
+ ./configure --prefix=/boot/common
254
+
255
+ Specifying the System Type
256
+ ==========================
257
+
258
+ There may be some features `configure' cannot figure out
259
+ automatically, but needs to determine by the type of machine the package
260
+ will run on. Usually, assuming the package is built to be run on the
261
+ _same_ architectures, `configure' can figure that out, but if it prints
262
+ a message saying it cannot guess the machine type, give it the
263
+ `--build=TYPE' option. TYPE can either be a short name for the system
264
+ type, such as `sun4', or a canonical name which has the form:
265
+
266
+ CPU-COMPANY-SYSTEM
267
+
268
+ where SYSTEM can have one of these forms:
269
+
270
+ OS
271
+ KERNEL-OS
272
+
273
+ See the file `config.sub' for the possible values of each field. If
274
+ `config.sub' isn't included in this package, then this package doesn't
275
+ need to know the machine type.
276
+
277
+ If you are _building_ compiler tools for cross-compiling, you should
278
+ use the option `--target=TYPE' to select the type of system they will
279
+ produce code for.
280
+
281
+ If you want to _use_ a cross compiler, that generates code for a
282
+ platform different from the build platform, you should specify the
283
+ "host" platform (i.e., that on which the generated programs will
284
+ eventually be run) with `--host=TYPE'.
285
+
286
+ Sharing Defaults
287
+ ================
288
+
289
+ If you want to set default values for `configure' scripts to share,
290
+ you can create a site shell script called `config.site' that gives
291
+ default values for variables like `CC', `cache_file', and `prefix'.
292
+ `configure' looks for `PREFIX/share/config.site' if it exists, then
293
+ `PREFIX/etc/config.site' if it exists. Or, you can set the
294
+ `CONFIG_SITE' environment variable to the location of the site script.
295
+ A warning: not all `configure' scripts look for a site script.
296
+
297
+ Defining Variables
298
+ ==================
299
+
300
+ Variables not defined in a site shell script can be set in the
301
+ environment passed to `configure'. However, some packages may run
302
+ configure again during the build, and the customized values of these
303
+ variables may be lost. In order to avoid this problem, you should set
304
+ them in the `configure' command line, using `VAR=value'. For example:
305
+
306
+ ./configure CC=/usr/local2/bin/gcc
307
+
308
+ causes the specified `gcc' to be used as the C compiler (unless it is
309
+ overridden in the site shell script).
310
+
311
+ Unfortunately, this technique does not work for `CONFIG_SHELL' due to
312
+ an Autoconf bug. Until the bug is fixed you can use this workaround:
313
+
314
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
315
+
316
+ `configure' Invocation
317
+ ======================
318
+
319
+ `configure' recognizes the following options to control how it
320
+ operates.
321
+
322
+ `--help'
323
+ `-h'
324
+ Print a summary of all of the options to `configure', and exit.
325
+
326
+ `--help=short'
327
+ `--help=recursive'
328
+ Print a summary of the options unique to this package's
329
+ `configure', and exit. The `short' variant lists options used
330
+ only in the top level, while the `recursive' variant lists options
331
+ also present in any nested packages.
332
+
333
+ `--version'
334
+ `-V'
335
+ Print the version of Autoconf used to generate the `configure'
336
+ script, and exit.
337
+
338
+ `--cache-file=FILE'
339
+ Enable the cache: use and save the results of the tests in FILE,
340
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
341
+ disable caching.
342
+
343
+ `--config-cache'
344
+ `-C'
345
+ Alias for `--cache-file=config.cache'.
346
+
347
+ `--quiet'
348
+ `--silent'
349
+ `-q'
350
+ Do not print messages saying which checks are being made. To
351
+ suppress all normal output, redirect it to `/dev/null' (any error
352
+ messages will still be shown).
353
+
354
+ `--srcdir=DIR'
355
+ Look for the package's source code in directory DIR. Usually
356
+ `configure' can determine that directory automatically.
357
+
358
+ `--prefix=DIR'
359
+ Use DIR as the installation prefix. *note Installation Names::
360
+ for more details, including other options available for fine-tuning
361
+ the installation locations.
362
+
363
+ `--no-create'
364
+ `-n'
365
+ Run the configure checks, but stop before creating any output
366
+ files.
367
+
368
+ `configure' also accepts some other, not widely useful, options. Run
369
+ `configure --help' for more details.
370
+
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/Makefile.am ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ AM_CFLAGS = @BUILD_CFLAGS@
3
+ lib_LTLIBRARIES = libsqlite3.la
4
+ libsqlite3_la_SOURCES = sqlite3.c
5
+ libsqlite3_la_LDFLAGS = -no-undefined -version-info 8:6:8
6
+
7
+ bin_PROGRAMS = sqlite3
8
+ sqlite3_SOURCES = shell.c sqlite3.h
9
+ EXTRA_sqlite3_SOURCES = sqlite3.c
10
+ sqlite3_LDADD = @EXTRA_SHELL_OBJ@ @READLINE_LIBS@
11
+ sqlite3_DEPENDENCIES = @EXTRA_SHELL_OBJ@
12
+ sqlite3_CFLAGS = $(AM_CFLAGS) -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_DQS=0 -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_STMTVTAB -DSQLITE_ENABLE_DBSTAT_VTAB $(SHELL_CFLAGS)
13
+
14
+ include_HEADERS = sqlite3.h sqlite3ext.h
15
+
16
+ EXTRA_DIST = sqlite3.1 tea Makefile.msc sqlite3.rc sqlite3rc.h README.txt Replace.cs Makefile.fallback
17
+ pkgconfigdir = ${libdir}/pkgconfig
18
+ pkgconfig_DATA = sqlite3.pc
19
+
20
+ man_MANS = sqlite3.1
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/Makefile.fallback ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/make
2
+ #
3
+ # If the configure script does not work, then this Makefile is available
4
+ # as a backup. Manually configure the variables below.
5
+ #
6
+ # Note: This makefile works out-of-the-box on MacOS 10.2 (Jaguar)
7
+ #
8
+ CC = gcc
9
+ CFLAGS = -O0 -I.
10
+ LIBS = -lz
11
+ COPTS += -D_BSD_SOURCE
12
+ COPTS += -DSQLITE_ENABLE_LOCKING_STYLE=0
13
+ COPTS += -DSQLITE_THREADSAFE=0
14
+ COPTS += -DSQLITE_OMIT_LOAD_EXTENSION
15
+ COPTS += -DSQLITE_WITHOUT_ZONEMALLOC
16
+ COPTS += -DSQLITE_ENABLE_RTREE
17
+
18
+ sqlite3: shell.c sqlite3.c
19
+ $(CC) $(CFLAGS) $(COPTS) -o sqlite3 shell.c sqlite3.c $(LIBS)
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/Makefile.msc ADDED
@@ -0,0 +1,1098 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### DO NOT EDIT ####
2
+ # This makefile is automatically generated from the Makefile.msc at
3
+ # the root of the canonical SQLite source tree (not the
4
+ # amalgamation tarball) using the tool/mkmsvcmin.tcl
5
+ # script.
6
+ #
7
+
8
+ #
9
+ # nmake Makefile for SQLite
10
+ #
11
+ ###############################################################################
12
+ ############################## START OF OPTIONS ###############################
13
+ ###############################################################################
14
+
15
+ # The toplevel directory of the source tree. This is the directory
16
+ # that contains this "Makefile.msc".
17
+ #
18
+ TOP = .
19
+
20
+
21
+ # Optionally set EXTRA_SRC to a list of C files to append to
22
+ # the generated sqlite3.c.
23
+ #
24
+ !IFNDEF EXTRA_SRC
25
+ EXTRA_SRC =
26
+ !ENDIF
27
+
28
+ # Set this non-0 to enable full warnings (-W4, etc) when compiling.
29
+ #
30
+ !IFNDEF USE_FULLWARN
31
+ USE_FULLWARN = 1
32
+ !ENDIF
33
+
34
+ # Set this non-0 to enable treating warnings as errors (-WX, etc) when
35
+ # compiling.
36
+ #
37
+ !IFNDEF USE_FATAL_WARN
38
+ USE_FATAL_WARN = 0
39
+ !ENDIF
40
+
41
+ # Set this non-0 to enable full runtime error checks (-RTC1, etc). This
42
+ # has no effect if (any) optimizations are enabled.
43
+ #
44
+ !IFNDEF USE_RUNTIME_CHECKS
45
+ USE_RUNTIME_CHECKS = 0
46
+ !ENDIF
47
+
48
+ # Set this non-0 to create a SQLite amalgamation file that excludes the
49
+ # various built-in extensions.
50
+ #
51
+ !IFNDEF MINIMAL_AMALGAMATION
52
+ MINIMAL_AMALGAMATION = 0
53
+ !ENDIF
54
+
55
+ # Set this non-0 to use "stdcall" calling convention for the core library
56
+ # and shell executable.
57
+ #
58
+ !IFNDEF USE_STDCALL
59
+ USE_STDCALL = 0
60
+ !ENDIF
61
+
62
+ # Use the USE_SEH=0 option on the nmake command line to omit structured
63
+ # exception handling (SEH) support. SEH is on by default.
64
+ #
65
+ !IFNDEF USE_SEH
66
+ USE_SEH = 1
67
+ !ENDIF
68
+
69
+ # Use STATICALLY_LINK_TCL=1 to statically link against TCL
70
+ #
71
+ !IFNDEF STATICALLY_LINK_TCL
72
+ STATICALLY_LINK_TCL = 0
73
+ !ELSEIF $(STATICALLY_LINK_TCL)!=0
74
+ CCOPTS = $(CCOPTS) -DSTATIC_BUILD
75
+ !ENDIF
76
+
77
+ # Set this non-0 to have the shell executable link against the core dynamic
78
+ # link library.
79
+ #
80
+ !IFNDEF DYNAMIC_SHELL
81
+ DYNAMIC_SHELL = 0
82
+ !ENDIF
83
+
84
+ # Set this non-0 to enable extra code that attempts to detect misuse of the
85
+ # SQLite API.
86
+ #
87
+ !IFNDEF API_ARMOR
88
+ API_ARMOR = 0
89
+ !ENDIF
90
+
91
+ # If necessary, create a list of harmless compiler warnings to disable when
92
+ # compiling the various tools. For the SQLite source code itself, warnings,
93
+ # if any, will be disabled from within it.
94
+ #
95
+ !IFNDEF NO_WARN
96
+ !IF $(USE_FULLWARN)!=0
97
+ NO_WARN = -wd4054 -wd4055 -wd4100 -wd4127 -wd4130 -wd4152 -wd4189 -wd4206
98
+ NO_WARN = $(NO_WARN) -wd4210 -wd4232 -wd4244 -wd4305 -wd4306 -wd4702 -wd4706
99
+ !ENDIF
100
+ !ENDIF
101
+
102
+ # Set this non-0 to use the library paths and other options necessary for
103
+ # Windows Phone 8.1.
104
+ #
105
+ !IFNDEF USE_WP81_OPTS
106
+ USE_WP81_OPTS = 0
107
+ !ENDIF
108
+
109
+ # Set this non-0 to split the SQLite amalgamation file into chunks to
110
+ # be used for debugging with Visual Studio.
111
+ #
112
+ !IFNDEF SPLIT_AMALGAMATION
113
+ SPLIT_AMALGAMATION = 0
114
+ !ENDIF
115
+
116
+
117
+ # Set this non-0 to dynamically link to the MSVC runtime library.
118
+ #
119
+ !IFNDEF USE_CRT_DLL
120
+ USE_CRT_DLL = 0
121
+ !ENDIF
122
+
123
+ # Set this non-0 to link to the RPCRT4 library.
124
+ #
125
+ !IFNDEF USE_RPCRT4_LIB
126
+ USE_RPCRT4_LIB = 0
127
+ !ENDIF
128
+
129
+ # Set this non-0 to generate assembly code listings for the source code
130
+ # files.
131
+ #
132
+ !IFNDEF USE_LISTINGS
133
+ USE_LISTINGS = 0
134
+ !ENDIF
135
+
136
+ # Set this non-0 to attempt setting the native compiler automatically
137
+ # for cross-compiling the command line tools needed during the compilation
138
+ # process.
139
+ #
140
+ !IFNDEF XCOMPILE
141
+ XCOMPILE = 0
142
+ !ENDIF
143
+
144
+ # Set this non-0 to use the native libraries paths for cross-compiling
145
+ # the command line tools needed during the compilation process.
146
+ #
147
+ !IFNDEF USE_NATIVE_LIBPATHS
148
+ USE_NATIVE_LIBPATHS = 0
149
+ !ENDIF
150
+
151
+ # Set this 0 to skip the compiling and embedding of version resources.
152
+ #
153
+ !IFNDEF USE_RC
154
+ USE_RC = 1
155
+ !ENDIF
156
+
157
+ # Set this non-0 to compile binaries suitable for the WinRT environment.
158
+ # This setting does not apply to any binaries that require Tcl to operate
159
+ # properly (i.e. the text fixture, etc).
160
+ #
161
+ !IFNDEF FOR_WINRT
162
+ FOR_WINRT = 0
163
+ !ENDIF
164
+
165
+ # Set this non-0 to compile binaries suitable for the UWP environment.
166
+ # This setting does not apply to any binaries that require Tcl to operate
167
+ # properly (i.e. the text fixture, etc).
168
+ #
169
+ !IFNDEF FOR_UWP
170
+ FOR_UWP = 0
171
+ !ENDIF
172
+
173
+ # Set this non-0 to compile binaries suitable for the Windows 10 platform.
174
+ #
175
+ !IFNDEF FOR_WIN10
176
+ FOR_WIN10 = 0
177
+ !ENDIF
178
+
179
+
180
+ # Set this to non-0 to create and use PDBs.
181
+ #
182
+ !IFNDEF SYMBOLS
183
+ SYMBOLS = 1
184
+ !ENDIF
185
+
186
+ # Set this to non-0 to use the SQLite debugging heap subsystem.
187
+ #
188
+ !IFNDEF MEMDEBUG
189
+ MEMDEBUG = 0
190
+ !ENDIF
191
+
192
+ # Set this to non-0 to use the Win32 native heap subsystem.
193
+ #
194
+ !IFNDEF WIN32HEAP
195
+ WIN32HEAP = 0
196
+ !ENDIF
197
+
198
+ # Set this to non-0 to enable OSTRACE() macros, which can be useful when
199
+ # debugging.
200
+ #
201
+ !IFNDEF OSTRACE
202
+ OSTRACE = 0
203
+ !ENDIF
204
+
205
+ # enable address sanitizer using ASAN=1 on the command-line.
206
+ #
207
+ !IFNDEF ASAN
208
+ ASAN = 0
209
+ !ENDIF
210
+
211
+ # Set this to one of the following values to enable various debugging
212
+ # features. Each level includes the debugging options from the previous
213
+ # levels. Currently, the recognized values for DEBUG are:
214
+ #
215
+ # 0 == NDEBUG: Disables assert() and other runtime diagnostics.
216
+ # 1 == SQLITE_ENABLE_API_ARMOR: extra attempts to detect misuse of the API.
217
+ # 2 == Disables NDEBUG and all optimizations and then enables PDBs.
218
+ # 3 == SQLITE_DEBUG: Enables various diagnostics messages and code.
219
+ # 4 == SQLITE_WIN32_MALLOC_VALIDATE: Validate the Win32 native heap per call.
220
+ # 5 == SQLITE_DEBUG_OS_TRACE: Enables output from the OSTRACE() macros.
221
+ # 6 == SQLITE_ENABLE_IOTRACE: Enables output from the IOTRACE() macros.
222
+ #
223
+ !IFNDEF DEBUG
224
+ DEBUG = 0
225
+ !ENDIF
226
+
227
+
228
+ # Enable use of available compiler optimizations? Normally, this should be
229
+ # non-zero. Setting this to zero, thus disabling all compiler optimizations,
230
+ # can be useful for testing.
231
+ #
232
+ !IFNDEF OPTIMIZATIONS
233
+ OPTIMIZATIONS = 2
234
+ !ENDIF
235
+
236
+ # Set this to non-0 to enable support for the session extension.
237
+ #
238
+ !IFNDEF SESSION
239
+ SESSION = 0
240
+ !ENDIF
241
+
242
+ # Set this to non-0 to enable support for the rbu extension.
243
+ #
244
+ !IFNDEF RBU
245
+ RBU = 0
246
+ !ENDIF
247
+
248
+ # Set the source code file to be used by executables and libraries when
249
+ # they need the amalgamation.
250
+ #
251
+ !IFNDEF SQLITE3C
252
+ !IF $(SPLIT_AMALGAMATION)!=0
253
+ SQLITE3C = sqlite3-all.c
254
+ !ELSE
255
+ SQLITE3C = sqlite3.c
256
+ !ENDIF
257
+ !ENDIF
258
+
259
+ # Set the include code file to be used by executables and libraries when
260
+ # they need SQLite.
261
+ #
262
+ !IFNDEF SQLITE3H
263
+ SQLITE3H = sqlite3.h
264
+ !ENDIF
265
+
266
+ # This is the name to use for the SQLite dynamic link library (DLL).
267
+ #
268
+ !IFNDEF SQLITE3DLL
269
+ !IF $(FOR_WIN10)!=0
270
+ SQLITE3DLL = winsqlite3.dll
271
+ !ELSE
272
+ SQLITE3DLL = sqlite3.dll
273
+ !ENDIF
274
+ !ENDIF
275
+
276
+ # This is the name to use for the SQLite import library (LIB).
277
+ #
278
+ !IFNDEF SQLITE3LIB
279
+ !IF $(FOR_WIN10)!=0
280
+ SQLITE3LIB = winsqlite3.lib
281
+ !ELSE
282
+ SQLITE3LIB = sqlite3.lib
283
+ !ENDIF
284
+ !ENDIF
285
+
286
+ # This is the name to use for the SQLite shell executable (EXE).
287
+ #
288
+ !IFNDEF SQLITE3EXE
289
+ !IF $(FOR_WIN10)!=0
290
+ SQLITE3EXE = winsqlite3shell.exe
291
+ !ELSE
292
+ SQLITE3EXE = sqlite3.exe
293
+ !ENDIF
294
+ !ENDIF
295
+
296
+ # This is the argument used to set the program database (PDB) file for the
297
+ # SQLite shell executable (EXE).
298
+ #
299
+ !IFNDEF SQLITE3EXEPDB
300
+ !IF $(FOR_WIN10)!=0
301
+ SQLITE3EXEPDB =
302
+ !ELSE
303
+ SQLITE3EXEPDB = /pdb:sqlite3sh.pdb
304
+ !ENDIF
305
+ !ENDIF
306
+
307
+
308
+ # These are the "standard" SQLite compilation options used when compiling for
309
+ # the Windows platform.
310
+ #
311
+ !IFNDEF OPT_FEATURE_FLAGS
312
+ OPT_FEATURE_FLAGS = $(OPT_XTRA)
313
+ !IF $(MINIMAL_AMALGAMATION)==0
314
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1
315
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS5=1
316
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1
317
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_GEOPOLY=1
318
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_STMTVTAB=1
319
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBPAGE_VTAB=1
320
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBSTAT_VTAB=1
321
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_BYTECODE_VTAB=1
322
+ !ENDIF
323
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1
324
+ !ENDIF
325
+
326
+ # Additional feature-options above and beyond what are normally used can be
327
+ # be added using OPTIONS=.... on the command-line. These values are
328
+ # appended to the OPT_FEATURE_FLAGS variable.
329
+ #
330
+ !IFDEF OPTIONS
331
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) $(OPTIONS)
332
+ !ENDIF
333
+
334
+ # Should the session extension be enabled? If so, add compilation options
335
+ # to enable it.
336
+ #
337
+ !IF $(SESSION)!=0
338
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1
339
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1
340
+ !ENDIF
341
+
342
+ # Always enable math functions on Windows
343
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_MATH_FUNCTIONS
344
+
345
+ # Should the rbu extension be enabled? If so, add compilation options
346
+ # to enable it.
347
+ #
348
+ !IF $(RBU)!=0
349
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RBU=1
350
+ !ENDIF
351
+
352
+ # Should structured exception handling (SEH) be enabled for WAL mode in
353
+ # the core library? It is on by default. Only omit it if the
354
+ # USE_SEH=0 option is provided on the nmake command-line.
355
+ #
356
+ !IF $(USE_SEH)==0
357
+ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_OMIT_SEH=1
358
+ !ENDIF
359
+
360
+ # These are the "extended" SQLite compilation options used when compiling for
361
+ # the Windows 10 platform.
362
+ #
363
+ !IFNDEF EXT_FEATURE_FLAGS
364
+ !IF $(FOR_WIN10)!=0
365
+ EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS4=1
366
+ EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_SYSTEM_MALLOC=1
367
+ EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_OMIT_LOCALTIME=1
368
+ !ELSE
369
+ EXT_FEATURE_FLAGS =
370
+ !ENDIF
371
+ !ENDIF
372
+
373
+ ###############################################################################
374
+ ############################### END OF OPTIONS ################################
375
+ ###############################################################################
376
+
377
+ # When compiling for the Windows 10 platform, the PLATFORM macro must be set
378
+ # to an appropriate value (e.g. x86, x64, arm, arm64, etc).
379
+ #
380
+ !IF $(FOR_WIN10)!=0
381
+ !IFNDEF PLATFORM
382
+ !ERROR Using the FOR_WIN10 option requires a value for PLATFORM.
383
+ !ENDIF
384
+ !ENDIF
385
+
386
+ # This assumes that MSVC is always installed in 32-bit Program Files directory
387
+ # and sets the variable for use in locating other 32-bit installs accordingly.
388
+ #
389
+ PROGRAMFILES_X86 = $(VCINSTALLDIR)\..\..
390
+ PROGRAMFILES_X86 = $(PROGRAMFILES_X86:\\=\)
391
+
392
+ # Check for the predefined command macro CC. This should point to the compiler
393
+ # binary for the target platform. If it is not defined, simply define it to
394
+ # the legacy default value 'cl.exe'.
395
+ #
396
+ !IFNDEF CC
397
+ CC = cl.exe
398
+ !ENDIF
399
+
400
+ # Check for the predefined command macro CSC. This should point to a working
401
+ # C Sharp compiler binary. If it is not defined, simply define it to the
402
+ # legacy default value 'csc.exe'.
403
+ #
404
+ !IFNDEF CSC
405
+ CSC = csc.exe
406
+ !ENDIF
407
+
408
+ # Check for the command macro LD. This should point to the linker binary for
409
+ # the target platform. If it is not defined, simply define it to the legacy
410
+ # default value 'link.exe'.
411
+ #
412
+ !IFNDEF LD
413
+ LD = link.exe
414
+ !ENDIF
415
+
416
+ # Check for the predefined command macro RC. This should point to the resource
417
+ # compiler binary for the target platform. If it is not defined, simply define
418
+ # it to the legacy default value 'rc.exe'.
419
+ #
420
+ !IFNDEF RC
421
+ RC = rc.exe
422
+ !ENDIF
423
+
424
+ # Check for the MSVC runtime library path macro. Otherwise, this value will
425
+ # default to the 'lib' directory underneath the MSVC installation directory.
426
+ #
427
+ !IFNDEF CRTLIBPATH
428
+ CRTLIBPATH = $(VCINSTALLDIR)\lib
429
+ !ENDIF
430
+
431
+ CRTLIBPATH = $(CRTLIBPATH:\\=\)
432
+
433
+ # Check for the command macro NCC. This should point to the compiler binary
434
+ # for the platform the compilation process is taking place on. If it is not
435
+ # defined, simply define it to have the same value as the CC macro. When
436
+ # cross-compiling, it is suggested that this macro be modified via the command
437
+ # line (since nmake itself does not provide a built-in method to guess it).
438
+ # For example, to use the x86 compiler when cross-compiling for x64, a command
439
+ # line similar to the following could be used (all on one line):
440
+ #
441
+ # nmake /f Makefile.msc sqlite3.dll
442
+ # XCOMPILE=1 USE_NATIVE_LIBPATHS=1
443
+ #
444
+ # Alternatively, the full path and file name to the compiler binary for the
445
+ # platform the compilation process is taking place may be specified (all on
446
+ # one line):
447
+ #
448
+ # nmake /f Makefile.msc sqlite3.dll
449
+ # "NCC=""%VCINSTALLDIR%\bin\cl.exe"""
450
+ # USE_NATIVE_LIBPATHS=1
451
+ #
452
+ !IFDEF NCC
453
+ NCC = $(NCC:\\=\)
454
+ !ELSEIF $(XCOMPILE)!=0
455
+ NCC = "$(VCINSTALLDIR)\bin\$(CC)"
456
+ NCC = $(NCC:\\=\)
457
+ !ELSE
458
+ NCC = $(CC)
459
+ !ENDIF
460
+
461
+ # Check for the MSVC native runtime library path macro. Otherwise,
462
+ # this value will default to the 'lib' directory underneath the MSVC
463
+ # installation directory.
464
+ #
465
+ !IFNDEF NCRTLIBPATH
466
+ NCRTLIBPATH = $(VCINSTALLDIR)\lib
467
+ !ENDIF
468
+
469
+ NCRTLIBPATH = $(NCRTLIBPATH:\\=\)
470
+
471
+ # Check for the Platform SDK library path macro. Otherwise, this
472
+ # value will default to the 'lib' directory underneath the Windows
473
+ # SDK installation directory (the environment variable used appears
474
+ # to be available when using Visual C++ 2008 or later via the
475
+ # command line).
476
+ #
477
+ !IFNDEF NSDKLIBPATH
478
+ NSDKLIBPATH = $(WINDOWSSDKDIR)\lib
479
+ !ENDIF
480
+
481
+ NSDKLIBPATH = $(NSDKLIBPATH:\\=\)
482
+
483
+ # Check for the UCRT library path macro. Otherwise, this value will
484
+ # default to the version-specific, platform-specific 'lib' directory
485
+ # underneath the Windows SDK installation directory.
486
+ #
487
+ !IFNDEF UCRTLIBPATH
488
+ UCRTLIBPATH = $(WINDOWSSDKDIR)\lib\$(WINDOWSSDKLIBVERSION)\ucrt\$(PLATFORM)
489
+ !ENDIF
490
+
491
+ UCRTLIBPATH = $(UCRTLIBPATH:\\=\)
492
+
493
+ # C compiler and options for use in building executables that
494
+ # will run on the platform that is doing the build.
495
+ #
496
+ !IF $(USE_FULLWARN)!=0
497
+ BCC = $(NCC) -nologo -W4 -Fd$*.pdb $(CCOPTS) $(BCCOPTS)
498
+ !ELSE
499
+ BCC = $(NCC) -nologo -W3 -Fd$*.pdb $(CCOPTS) $(BCCOPTS)
500
+ !ENDIF
501
+
502
+ # Check if assembly code listings should be generated for the source
503
+ # code files to be compiled.
504
+ #
505
+ !IF $(USE_LISTINGS)!=0
506
+ BCC = $(BCC) -FAcs
507
+ !ENDIF
508
+
509
+ # Check if the native library paths should be used when compiling
510
+ # the command line tools used during the compilation process. If
511
+ # so, set the necessary macro now.
512
+ #
513
+ !IF $(USE_NATIVE_LIBPATHS)!=0
514
+ NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)"
515
+
516
+ !IFDEF NUCRTLIBPATH
517
+ NUCRTLIBPATH = $(NUCRTLIBPATH:\\=\)
518
+ NLTLIBPATHS = $(NLTLIBPATHS) "/LIBPATH:$(NUCRTLIBPATH)"
519
+ !ENDIF
520
+ !ENDIF
521
+
522
+ # C compiler and options for use in building executables that
523
+ # will run on the target platform. (BCC and TCC are usually the
524
+ # same unless your are cross-compiling.)
525
+ #
526
+ !IF $(USE_FULLWARN)!=0
527
+ TCC = $(CC) -nologo -W4 -DINCLUDE_MSVC_H=1 $(CCOPTS) $(TCCOPTS)
528
+ !ELSE
529
+ TCC = $(CC) -nologo -W3 $(CCOPTS) $(TCCOPTS)
530
+ !ENDIF
531
+
532
+ # Check if warnings should be treated as errors when compiling.
533
+ #
534
+ !IF $(USE_FATAL_WARN)!=0
535
+ TCC = $(TCC) -WX
536
+ !ENDIF
537
+
538
+ TCC = $(TCC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -fp:precise
539
+ RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) $(RCOPTS) $(RCCOPTS)
540
+
541
+ # Check if we want to use the "stdcall" calling convention when compiling.
542
+ # This is not supported by the compilers for non-x86 platforms. It should
543
+ # also be noted here that building any target with these "stdcall" options
544
+ # will most likely fail if the Tcl library is also required. This is due
545
+ # to how the Tcl library functions are declared and exported (i.e. without
546
+ # an explicit calling convention, which results in "cdecl").
547
+ #
548
+ !IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
549
+ !IF "$(PLATFORM)"=="x86"
550
+ CORE_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
551
+ SHELL_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
552
+ !ELSE
553
+ !IFNDEF PLATFORM
554
+ CORE_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
555
+ SHELL_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
556
+ !ELSE
557
+ CORE_CCONV_OPTS =
558
+ SHELL_CCONV_OPTS =
559
+ !ENDIF
560
+ !ENDIF
561
+ !ELSE
562
+ CORE_CCONV_OPTS =
563
+ SHELL_CCONV_OPTS =
564
+ !ENDIF
565
+
566
+ # These are additional compiler options used for the core library.
567
+ #
568
+ !IFNDEF CORE_COMPILE_OPTS
569
+ !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
570
+ CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS) -DSQLITE_API=__declspec(dllexport)
571
+ !ELSE
572
+ CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS)
573
+ !ENDIF
574
+ !ENDIF
575
+
576
+ # These are the additional targets that the core library should depend on
577
+ # when linking.
578
+ #
579
+ !IFNDEF CORE_LINK_DEP
580
+ !IF $(DYNAMIC_SHELL)!=0
581
+ CORE_LINK_DEP =
582
+ !ELSEIF $(FOR_WIN10)==0 || "$(PLATFORM)"=="x86"
583
+ CORE_LINK_DEP = sqlite3.def
584
+ !ELSE
585
+ CORE_LINK_DEP =
586
+ !ENDIF
587
+ !ENDIF
588
+
589
+ # These are additional linker options used for the core library.
590
+ #
591
+ !IFNDEF CORE_LINK_OPTS
592
+ !IF $(DYNAMIC_SHELL)!=0
593
+ CORE_LINK_OPTS =
594
+ !ELSEIF $(FOR_WIN10)==0 || "$(PLATFORM)"=="x86"
595
+ CORE_LINK_OPTS = /DEF:sqlite3.def
596
+ !ELSE
597
+ CORE_LINK_OPTS =
598
+ !ENDIF
599
+ !ENDIF
600
+
601
+ # These are additional compiler options used for the shell executable.
602
+ #
603
+ !IFNDEF SHELL_COMPILE_OPTS
604
+ !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
605
+ SHELL_COMPILE_OPTS = $(SHELL_CCONV_OPTS) -DSQLITE_API=__declspec(dllimport)
606
+ !ELSE
607
+ SHELL_COMPILE_OPTS = $(SHELL_CCONV_OPTS)
608
+ !ENDIF
609
+ !ENDIF
610
+
611
+ # This is the source code that the shell executable should be compiled
612
+ # with.
613
+ #
614
+ !IFNDEF SHELL_CORE_SRC
615
+ !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
616
+ SHELL_CORE_SRC =
617
+ !ELSE
618
+ SHELL_CORE_SRC = $(SQLITE3C)
619
+ !ENDIF
620
+ !ENDIF
621
+
622
+ # This is the core library that the shell executable should depend on.
623
+ #
624
+ !IFNDEF SHELL_CORE_DEP
625
+ !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
626
+ SHELL_CORE_DEP = $(SQLITE3DLL)
627
+ !ELSE
628
+ SHELL_CORE_DEP =
629
+ !ENDIF
630
+ !ENDIF
631
+
632
+
633
+ # This is the core library that the shell executable should link with.
634
+ #
635
+ !IFNDEF SHELL_CORE_LIB
636
+ !IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
637
+ SHELL_CORE_LIB = $(SQLITE3LIB)
638
+ !ELSE
639
+ SHELL_CORE_LIB =
640
+ !ENDIF
641
+ !ENDIF
642
+
643
+ # These are additional linker options used for the shell executable.
644
+ #
645
+ !IFNDEF SHELL_LINK_OPTS
646
+ SHELL_LINK_OPTS = $(SHELL_CORE_LIB)
647
+ !ENDIF
648
+
649
+ # Check if assembly code listings should be generated for the source
650
+ # code files to be compiled.
651
+ #
652
+ !IF $(USE_LISTINGS)!=0
653
+ TCC = $(TCC) -FAcs
654
+ !ENDIF
655
+
656
+ # When compiling the library for use in the WinRT environment,
657
+ # the following compile-time options must be used as well to
658
+ # disable use of Win32 APIs that are not available and to enable
659
+ # use of Win32 APIs that are specific to Windows 8 and/or WinRT.
660
+ #
661
+ !IF $(FOR_WINRT)!=0
662
+ TCC = $(TCC) -DSQLITE_OS_WINRT=1
663
+ RCC = $(RCC) -DSQLITE_OS_WINRT=1
664
+ TCC = $(TCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP
665
+ RCC = $(RCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP
666
+ !ENDIF
667
+
668
+ # C compiler options for the Windows 10 platform (needs MSVC 2015).
669
+ #
670
+ !IF $(FOR_WIN10)!=0
671
+ TCC = $(TCC) /d2guard4 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
672
+ BCC = $(BCC) /d2guard4 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
673
+ !ENDIF
674
+
675
+ # Also, we need to dynamically link to the correct MSVC runtime
676
+ # when compiling for WinRT (e.g. debug or release) OR if the
677
+ # USE_CRT_DLL option is set to force dynamically linking to the
678
+ # MSVC runtime library.
679
+ #
680
+ !IF $(FOR_WINRT)!=0 || $(USE_CRT_DLL)!=0
681
+ !IF $(DEBUG)>1
682
+ TCC = $(TCC) -MDd
683
+ BCC = $(BCC) -MDd
684
+ !ELSE
685
+ TCC = $(TCC) -MD
686
+ BCC = $(BCC) -MD
687
+ !ENDIF
688
+ !ELSE
689
+ !IF $(DEBUG)>1
690
+ TCC = $(TCC) -MTd
691
+ BCC = $(BCC) -MTd
692
+ !ELSE
693
+ TCC = $(TCC) -MT
694
+ BCC = $(BCC) -MT
695
+ !ENDIF
696
+ !ENDIF
697
+
698
+
699
+ # Define -DNDEBUG to compile without debugging (i.e., for production usage)
700
+ # Omitting the define will cause extra debugging code to be inserted and
701
+ # includes extra comments when "EXPLAIN stmt" is used.
702
+ #
703
+ !IF $(DEBUG)==0
704
+ TCC = $(TCC) -DNDEBUG
705
+ BCC = $(BCC) -DNDEBUG
706
+ RCC = $(RCC) -DNDEBUG
707
+ !ENDIF
708
+
709
+ !IF $(DEBUG)>0 || $(API_ARMOR)!=0 || $(FOR_WIN10)!=0
710
+ TCC = $(TCC) -DSQLITE_ENABLE_API_ARMOR=1
711
+ RCC = $(RCC) -DSQLITE_ENABLE_API_ARMOR=1
712
+ !ENDIF
713
+
714
+ !IF $(DEBUG)>2
715
+ TCC = $(TCC) -DSQLITE_DEBUG=1
716
+ RCC = $(RCC) -DSQLITE_DEBUG=1
717
+ !IF $(DYNAMIC_SHELL)==0
718
+ TCC = $(TCC) -DSQLITE_ENABLE_WHERETRACE -DSQLITE_ENABLE_SELECTTRACE
719
+ RCC = $(RCC) -DSQLITE_ENABLE_WHERETRACE -DSQLITE_ENABLE_SELECTTRACE
720
+ !ENDIF
721
+ !ENDIF
722
+
723
+ !IF $(DEBUG)>4 || $(OSTRACE)!=0
724
+ TCC = $(TCC) -DSQLITE_FORCE_OS_TRACE=1 -DSQLITE_DEBUG_OS_TRACE=1
725
+ RCC = $(RCC) -DSQLITE_FORCE_OS_TRACE=1 -DSQLITE_DEBUG_OS_TRACE=1
726
+ !ENDIF
727
+
728
+ !IF $(DEBUG)>5
729
+ TCC = $(TCC) -DSQLITE_ENABLE_IOTRACE=1
730
+ RCC = $(RCC) -DSQLITE_ENABLE_IOTRACE=1
731
+ !ENDIF
732
+
733
+ # Prevent warnings about "insecure" MSVC runtime library functions
734
+ # being used.
735
+ #
736
+ TCC = $(TCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
737
+ BCC = $(BCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
738
+ RCC = $(RCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
739
+
740
+ # Prevent warnings about "deprecated" POSIX functions being used.
741
+ #
742
+ TCC = $(TCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
743
+ BCC = $(BCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
744
+ RCC = $(RCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
745
+
746
+ # Use the SQLite debugging heap subsystem?
747
+ #
748
+ !IF $(MEMDEBUG)!=0
749
+ TCC = $(TCC) -DSQLITE_MEMDEBUG=1
750
+ RCC = $(RCC) -DSQLITE_MEMDEBUG=1
751
+
752
+ # Use native Win32 heap subsystem instead of malloc/free?
753
+ #
754
+ !ELSEIF $(WIN32HEAP)!=0
755
+ TCC = $(TCC) -DSQLITE_WIN32_MALLOC=1
756
+ RCC = $(RCC) -DSQLITE_WIN32_MALLOC=1
757
+
758
+ # Validate the heap on every call into the native Win32 heap subsystem?
759
+ #
760
+ !IF $(DEBUG)>3
761
+ TCC = $(TCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1
762
+ RCC = $(RCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1
763
+ !ENDIF
764
+ !ENDIF
765
+
766
+
767
+ # Address sanitizer if ASAN=1
768
+ #
769
+ !IF $(ASAN)>0
770
+ TCC = $(TCC) /fsanitize=address
771
+ !ENDIF
772
+
773
+
774
+ # Compiler options needed for programs that use the readline() library.
775
+ #
776
+ !IFNDEF READLINE_FLAGS
777
+ READLINE_FLAGS = -DHAVE_READLINE=0
778
+ !ENDIF
779
+
780
+ # The library that programs using readline() must link against.
781
+ #
782
+ !IFNDEF LIBREADLINE
783
+ LIBREADLINE =
784
+ !ENDIF
785
+
786
+ # Should the database engine be compiled threadsafe
787
+ #
788
+ TCC = $(TCC) -DSQLITE_THREADSAFE=1
789
+ RCC = $(RCC) -DSQLITE_THREADSAFE=1
790
+
791
+ # Do threads override each others locks by default (1), or do we test (-1)
792
+ #
793
+ TCC = $(TCC) -DSQLITE_THREAD_OVERRIDE_LOCK=-1
794
+ RCC = $(RCC) -DSQLITE_THREAD_OVERRIDE_LOCK=-1
795
+
796
+ # Any target libraries which libsqlite must be linked against
797
+ #
798
+ !IFNDEF TLIBS
799
+ TLIBS =
800
+ !ENDIF
801
+
802
+ # Flags controlling use of the in memory btree implementation
803
+ #
804
+ # SQLITE_TEMP_STORE is 0 to force temporary tables to be in a file, 1 to
805
+ # default to file, 2 to default to memory, and 3 to force temporary
806
+ # tables to always be in memory.
807
+ #
808
+ TCC = $(TCC) -DSQLITE_TEMP_STORE=1
809
+ RCC = $(RCC) -DSQLITE_TEMP_STORE=1
810
+
811
+ # Enable/disable loadable extensions, and other optional features
812
+ # based on configuration. (-DSQLITE_OMIT*, -DSQLITE_ENABLE*).
813
+ # The same set of OMIT and ENABLE flags should be passed to the
814
+ # LEMON parser generator and the mkkeywordhash tool as well.
815
+
816
+ # These are the required SQLite compilation options used when compiling for
817
+ # the Windows platform.
818
+ #
819
+ REQ_FEATURE_FLAGS = $(REQ_FEATURE_FLAGS) -DSQLITE_MAX_TRIGGER_DEPTH=100
820
+
821
+ # If we are linking to the RPCRT4 library, enable features that need it.
822
+ #
823
+ !IF $(USE_RPCRT4_LIB)!=0
824
+ REQ_FEATURE_FLAGS = $(REQ_FEATURE_FLAGS) -DSQLITE_WIN32_USE_UUID=1
825
+ !ENDIF
826
+
827
+ # Add the required and optional SQLite compilation options into the command
828
+ # lines used to invoke the MSVC code and resource compilers.
829
+ #
830
+ TCC = $(TCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS)
831
+ RCC = $(RCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS)
832
+
833
+ # Add in any optional parameters specified on the commane line, e.g.
834
+ # nmake /f Makefile.msc all "OPTS=-DSQLITE_ENABLE_FOO=1 -DSQLITE_OMIT_FOO=1"
835
+ #
836
+ TCC = $(TCC) $(OPTS)
837
+ RCC = $(RCC) $(OPTS)
838
+
839
+ # If compiling for debugging, add some defines.
840
+ #
841
+ !IF $(DEBUG)>1
842
+ TCC = $(TCC) -D_DEBUG
843
+ BCC = $(BCC) -D_DEBUG
844
+ RCC = $(RCC) -D_DEBUG
845
+ !ENDIF
846
+
847
+ # If optimizations are enabled or disabled (either implicitly or
848
+ # explicitly), add the necessary flags.
849
+ #
850
+ !IF $(DEBUG)>1 || $(OPTIMIZATIONS)==0
851
+ TCC = $(TCC) -Od
852
+ BCC = $(BCC) -Od
853
+ !IF $(USE_RUNTIME_CHECKS)!=0
854
+ TCC = $(TCC) -RTC1
855
+ BCC = $(BCC) -RTC1
856
+ !ENDIF
857
+ !ELSEIF $(OPTIMIZATIONS)>=3
858
+ TCC = $(TCC) -Ox
859
+ BCC = $(BCC) -Ox
860
+ !ELSEIF $(OPTIMIZATIONS)==2
861
+ TCC = $(TCC) -O2
862
+ BCC = $(BCC) -O2
863
+ !ELSEIF $(OPTIMIZATIONS)==1
864
+ TCC = $(TCC) -O1
865
+ BCC = $(BCC) -O1
866
+ !ENDIF
867
+
868
+ # If symbols are enabled (or compiling for debugging), enable PDBs.
869
+ #
870
+ !IF $(DEBUG)>1 || $(SYMBOLS)!=0
871
+ TCC = $(TCC) -Zi
872
+ BCC = $(BCC) -Zi
873
+ !ENDIF
874
+
875
+
876
+ # Command line prefixes for compiling code, compiling resources,
877
+ # linking, etc.
878
+ #
879
+ LTCOMPILE = $(TCC) -Fo$@ -Fd$*.pdb
880
+ LTRCOMPILE = $(RCC) -r
881
+ LTLIB = lib.exe
882
+ LTLINK = $(TCC) -Fe$@
883
+
884
+ # If requested, link to the RPCRT4 library.
885
+ #
886
+ !IF $(USE_RPCRT4_LIB)!=0
887
+ LTLIBS = $(LTLIBS) rpcrt4.lib
888
+ !ENDIF
889
+
890
+ # If a platform was set, force the linker to target that.
891
+ # Note that the vcvars*.bat family of batch files typically
892
+ # set this for you. Otherwise, the linker will attempt
893
+ # to deduce the binary type based on the object files.
894
+ !IFDEF PLATFORM
895
+ LTLINKOPTS = /NOLOGO /MACHINE:$(PLATFORM)
896
+ LTLIBOPTS = /NOLOGO /MACHINE:$(PLATFORM)
897
+ !ELSEIF "$(VISUALSTUDIOVERSION)"=="12.0" || \
898
+ "$(VISUALSTUDIOVERSION)"=="14.0" || \
899
+ "$(VISUALSTUDIOVERSION)"=="15.0"
900
+ LTLINKOPTS = /NOLOGO /MACHINE:x86
901
+ LTLIBOPTS = /NOLOGO /MACHINE:x86
902
+ !ELSE
903
+ LTLINKOPTS = /NOLOGO
904
+ LTLIBOPTS = /NOLOGO
905
+ !ENDIF
906
+
907
+ # When compiling for use in the WinRT environment, the following
908
+ # linker option must be used to mark the executable as runnable
909
+ # only in the context of an application container.
910
+ #
911
+ !IF $(FOR_WINRT)!=0
912
+ LTLINKOPTS = $(LTLINKOPTS) /APPCONTAINER
913
+ !IF "$(VISUALSTUDIOVERSION)"=="12.0" || "$(VISUALSTUDIOVERSION)"=="14.0"
914
+ !IFNDEF STORELIBPATH
915
+ !IF "$(PLATFORM)"=="x86"
916
+ STORELIBPATH = $(CRTLIBPATH)\store
917
+ !ELSEIF "$(PLATFORM)"=="x64"
918
+ STORELIBPATH = $(CRTLIBPATH)\store\amd64
919
+ !ELSEIF "$(PLATFORM)"=="ARM"
920
+ STORELIBPATH = $(CRTLIBPATH)\store\arm
921
+ !ELSE
922
+ STORELIBPATH = $(CRTLIBPATH)\store
923
+ !ENDIF
924
+ !ENDIF
925
+ STORELIBPATH = $(STORELIBPATH:\\=\)
926
+ LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(STORELIBPATH)"
927
+ !ENDIF
928
+ !ENDIF
929
+
930
+ # When compiling for Windows Phone 8.1, an extra library path is
931
+ # required.
932
+ #
933
+ !IF $(USE_WP81_OPTS)!=0
934
+ !IFNDEF WP81LIBPATH
935
+ !IF "$(PLATFORM)"=="x86"
936
+ WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\x86
937
+ !ELSEIF "$(PLATFORM)"=="ARM"
938
+ WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\ARM
939
+ !ELSE
940
+ WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\x86
941
+ !ENDIF
942
+ !ENDIF
943
+ !ENDIF
944
+
945
+ # When compiling for Windows Phone 8.1, some extra linker options
946
+ # are also required.
947
+ #
948
+ !IF $(USE_WP81_OPTS)!=0
949
+ !IFDEF WP81LIBPATH
950
+ LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(WP81LIBPATH)"
951
+ !ENDIF
952
+ LTLINKOPTS = $(LTLINKOPTS) /DYNAMICBASE
953
+ LTLINKOPTS = $(LTLINKOPTS) WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib
954
+ LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:ole32.lib
955
+ !ENDIF
956
+
957
+ # When compiling for UWP or the Windows 10 platform, some extra linker
958
+ # options are also required.
959
+ #
960
+ !IF $(FOR_UWP)!=0 || $(FOR_WIN10)!=0
961
+ LTLINKOPTS = $(LTLINKOPTS) /DYNAMICBASE /NODEFAULTLIB:kernel32.lib
962
+ LTLINKOPTS = $(LTLINKOPTS) mincore.lib
963
+ !IFDEF PSDKLIBPATH
964
+ LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(PSDKLIBPATH)"
965
+ !ENDIF
966
+ !ENDIF
967
+
968
+ !IF $(FOR_WIN10)!=0
969
+ LTLINKOPTS = $(LTLINKOPTS) /guard:cf "/LIBPATH:$(UCRTLIBPATH)"
970
+ !IF $(DEBUG)>1
971
+ LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:libucrtd.lib /DEFAULTLIB:ucrtd.lib
972
+ !ELSE
973
+ LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib
974
+ !ENDIF
975
+ !ENDIF
976
+
977
+ # If either debugging or symbols are enabled, enable PDBs.
978
+ #
979
+ !IF $(DEBUG)>1 || $(SYMBOLS)!=0
980
+ LDFLAGS = /DEBUG $(LDOPTS)
981
+ !ELSE
982
+ LDFLAGS = $(LDOPTS)
983
+ !ENDIF
984
+
985
+
986
+ # You should not have to change anything below this line
987
+ ###############################################################################
988
+
989
+
990
+ # Object files for the amalgamation.
991
+ #
992
+ LIBOBJS1 = sqlite3.lo
993
+
994
+ # Determine the real value of LIBOBJ based on the 'configure' script
995
+ #
996
+ LIBOBJ = $(LIBOBJS1)
997
+
998
+ # Determine if embedded resource compilation and usage are enabled.
999
+ #
1000
+ !IF $(USE_RC)!=0
1001
+ LIBRESOBJS = sqlite3res.lo
1002
+ !ELSE
1003
+ LIBRESOBJS =
1004
+ !ENDIF
1005
+
1006
+
1007
+ # Additional compiler options for the shell. These are only effective
1008
+ # when the shell is not being dynamically linked.
1009
+ #
1010
+ !IF $(DYNAMIC_SHELL)==0 && $(FOR_WIN10)==0
1011
+ SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_DQS=0
1012
+ SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_FTS4=1
1013
+ SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_EXPLAIN_COMMENTS=1
1014
+ SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_OFFSET_SQL_FUNC=1
1015
+ SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION=1
1016
+ SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_STMT_SCANSTATUS=1
1017
+ SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_STRICT_SUBTYPE=1
1018
+ !ENDIF
1019
+
1020
+
1021
+ # This is the default Makefile target. The objects listed here
1022
+ # are what get build when you type just "make" with no arguments.
1023
+ #
1024
+ core: dll shell
1025
+
1026
+ # Targets that require the Tcl library.
1027
+ #
1028
+ tcl: $(ALL_TCL_TARGETS)
1029
+
1030
+ # This Makefile target builds all of the standard binaries.
1031
+ #
1032
+ all: core tcl
1033
+
1034
+ # Dynamic link library section.
1035
+ #
1036
+ dll: $(SQLITE3DLL)
1037
+
1038
+ # Shell executable.
1039
+ #
1040
+ shell: $(SQLITE3EXE)
1041
+
1042
+ # jimsh0 - replacement for tclsh
1043
+ #
1044
+ jimsh0.exe: $(TOP)\autosetup\jimsh0.c
1045
+ cl -DHAVE__FULLPATH=1 $(TOP)\autosetup\jimsh0.c
1046
+
1047
+
1048
+ $(SQLITE3DLL): $(LIBOBJ) $(LIBRESOBJS) $(CORE_LINK_DEP)
1049
+ $(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL $(CORE_LINK_OPTS) /OUT:$@ $(LIBOBJ) $(LIBRESOBJS) $(LTLIBS) $(TLIBS)
1050
+
1051
+ Replace.exe:
1052
+ $(CSC) /target:exe $(TOP)\Replace.cs
1053
+
1054
+ sqlite3.def: Replace.exe $(LIBOBJ)
1055
+ echo EXPORTS > sqlite3.def
1056
+ dumpbin /all $(LIBOBJ) \
1057
+ | .\Replace.exe "^\s+/EXPORT:_?(sqlite3(?:session|changeset|changegroup|rebaser|rbu)?_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \
1058
+ | sort >> sqlite3.def
1059
+
1060
+ $(SQLITE3EXE): shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLITE3H)
1061
+ $(LTLINK) $(SHELL_COMPILE_OPTS) $(READLINE_FLAGS) shell.c $(SHELL_CORE_SRC) \
1062
+ /link $(SQLITE3EXEPDB) $(LDFLAGS) $(LTLINKOPTS) $(SHELL_LINK_OPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS)
1063
+
1064
+
1065
+ # Rule to build the amalgamation
1066
+ #
1067
+ sqlite3.lo: $(SQLITE3C)
1068
+ $(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(SQLITE3C)
1069
+
1070
+
1071
+ # Rule to build the Win32 resources object file.
1072
+ #
1073
+ !IF $(USE_RC)!=0
1074
+ _HASHCHAR=^#
1075
+ !IF ![echo !IFNDEF VERSION > rcver.vc] && \
1076
+ ![for /F "delims=" %V in ('type "$(SQLITE3H)" ^| "%SystemRoot%\System32\find.exe" "$(_HASHCHAR)define SQLITE_VERSION "') do (echo VERSION = ^^%V >> rcver.vc)] && \
1077
+ ![echo !ENDIF >> rcver.vc]
1078
+ !INCLUDE rcver.vc
1079
+ !ENDIF
1080
+
1081
+ RESOURCE_VERSION = $(VERSION:^#=)
1082
+ RESOURCE_VERSION = $(RESOURCE_VERSION:define=)
1083
+ RESOURCE_VERSION = $(RESOURCE_VERSION:SQLITE_VERSION=)
1084
+ RESOURCE_VERSION = $(RESOURCE_VERSION:"=)
1085
+ RESOURCE_VERSION = $(RESOURCE_VERSION:.=,)
1086
+
1087
+ $(LIBRESOBJS): $(TOP)\sqlite3.rc rcver.vc $(SQLITE3H)
1088
+ echo #ifndef SQLITE_RESOURCE_VERSION > sqlite3rc.h
1089
+ echo #define SQLITE_RESOURCE_VERSION $(RESOURCE_VERSION) >> sqlite3rc.h
1090
+ echo #endif >> sqlite3rc.h
1091
+ $(LTRCOMPILE) -fo $(LIBRESOBJS) -DRC_VERONLY $(TOP)\sqlite3.rc
1092
+ !ENDIF
1093
+
1094
+
1095
+ clean:
1096
+ del /Q *.exp *.lo *.ilk *.lib *.obj *.ncb *.pdb *.sdf *.suo 2>NUL
1097
+ del /Q *.bsc *.def *.cod *.da *.bb *.bbg *.vc gmon.out 2>NUL
1098
+ del /Q $(SQLITE3EXE) $(SQLITE3DLL) Replace.exe 2>NUL
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/README.first ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This directory contains components use to build an autoconf-ready package
2
+ of the SQLite amalgamation: sqlite-autoconf-30XXXXXX.tar.gz
3
+
4
+ To build the autoconf amalgamation, run from the top-level:
5
+
6
+ ./configure
7
+ make amalgamation-tarball
8
+
9
+ The amalgamation-tarball target (also available in "main.mk") runs the
10
+ script tool/mkautoconfamal.sh which does the work. Refer to that script
11
+ for details.
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/README.txt ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This package contains:
2
+
3
+ * the SQLite library amalgamation source code file: sqlite3.c
4
+ * the sqlite3.h and sqlite3ext.h header files that define the C-language
5
+ interface to the sqlite3.c library file
6
+ * the shell.c file used to build the sqlite3 command-line shell program
7
+ * autoconf/automake installation infrastucture for building on POSIX
8
+ compliant systems
9
+ * a Makefile.msc, sqlite3.rc, and Replace.cs for building with Microsoft
10
+ Visual C++ on Windows
11
+
12
+ WHY USE THIS PACKAGE?
13
+ =====================
14
+
15
+ The canonical make system for SQLite requires TCL as part of the build
16
+ process. Various TCL scripts are used to generate parts of the code and
17
+ TCL is used to run tests. But some people would prefer to build SQLite
18
+ using only generic tools and without having to install TCL. The purpose
19
+ of this package is to provide that capability.
20
+
21
+ This package contains a pre-build SQLite amalgamation file "sqlite3.c"
22
+ (and its associated header file "sqlite3.h"). Because the amalgamation
23
+ has been pre-built, no TCL is required.
24
+
25
+ REASONS TO USE THE CANONICAL BUILD SYSTEM RATHER THAN THIS PACKAGE
26
+ ==================================================================
27
+
28
+ * the cononical build system allows you to run tests to verify that
29
+ the build worked
30
+ * the canonical build system supports more compile-time options
31
+ * the canonical build system works for any arbitrary check-in to
32
+ the SQLite source tree
33
+
34
+ Step-by-step instructions on how to build using the canonical make
35
+ system for SQLite can be found at:
36
+
37
+ https://sqlite.org/src/doc/trunk/doc/compile-for-unix.md
38
+ https://sqlite.org/src/doc/trunk/doc/compile-for-windows.md
39
+
40
+
41
+ SUMMARY OF HOW TO BUILD USING THIS PACKAGE
42
+ ==========================================
43
+
44
+ Unix: ./configure; make
45
+ Windows: nmake /f Makefile.msc
46
+
47
+ BUILDING ON POSIX
48
+ =================
49
+
50
+ The generic installation instructions for autoconf/automake are found
51
+ in the INSTALL file.
52
+
53
+ The following SQLite specific boolean options are supported:
54
+
55
+ --enable-readline use readline in shell tool [default=yes]
56
+ --enable-threadsafe build a thread-safe library [default=yes]
57
+ --enable-dynamic-extensions support loadable extensions [default=yes]
58
+
59
+ The default value for the CFLAGS variable (options passed to the C
60
+ compiler) includes debugging symbols in the build, resulting in larger
61
+ binaries than are necessary. Override it on the configure command
62
+ line like this:
63
+
64
+ $ CFLAGS="-Os" ./configure
65
+
66
+ to produce a smaller installation footprint.
67
+
68
+ Other SQLite compilation parameters can also be set using CFLAGS. For
69
+ example:
70
+
71
+ $ CFLAGS="-Os -DSQLITE_THREADSAFE=0" ./configure
72
+
73
+
74
+ BUILDING WITH MICROSOFT VISUAL C++
75
+ ==================================
76
+
77
+ To compile for Windows using Microsoft Visual C++:
78
+
79
+ $ nmake /f Makefile.msc
80
+
81
+ Using Microsoft Visual C++ 2005 (or later) is recommended. Several Windows
82
+ platform variants may be built by adding additional macros to the NMAKE
83
+ command line.
84
+
85
+
86
+ Other preprocessor defines
87
+ --------------------------
88
+
89
+ Additionally, preprocessor defines may be specified by using the OPTS macro
90
+ on the NMAKE command line. However, not all possible preprocessor defines
91
+ may be specified in this manner as some require the amalgamation to be built
92
+ with them enabled (see http://www.sqlite.org/compile.html). For example, the
93
+ following will work:
94
+
95
+ "OPTS=-DSQLITE_ENABLE_STAT4=1 -DSQLITE_OMIT_JSON=1"
96
+
97
+ However, the following will not compile unless the amalgamation was built
98
+ with it enabled:
99
+
100
+ "OPTS=-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1"
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/configure.ac ADDED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #-----------------------------------------------------------------------
3
+ # Supports the following non-standard switches.
4
+ #
5
+ # --enable-threadsafe
6
+ # --enable-readline
7
+ # --enable-editline
8
+ # --enable-static-shell
9
+ # --enable-dynamic-extensions
10
+ #
11
+
12
+ AC_PREREQ(2.61)
13
+ AC_INIT(sqlite, --SQLITE-VERSION--, http://www.sqlite.org)
14
+ AC_CONFIG_SRCDIR([sqlite3.c])
15
+ AC_CONFIG_AUX_DIR([.])
16
+
17
+ # Use automake.
18
+ AM_INIT_AUTOMAKE([foreign])
19
+
20
+ AC_SYS_LARGEFILE
21
+
22
+ # Check for required programs.
23
+ AC_PROG_CC
24
+ AC_PROG_LIBTOOL
25
+ AC_PROG_MKDIR_P
26
+
27
+ # Check for library functions that SQLite can optionally use.
28
+ AC_CHECK_FUNCS([fdatasync usleep fullfsync localtime_r gmtime_r])
29
+ AC_FUNC_STRERROR_R
30
+
31
+ AC_CONFIG_FILES([Makefile sqlite3.pc])
32
+ BUILD_CFLAGS=
33
+ AC_SUBST(BUILD_CFLAGS)
34
+
35
+ #-------------------------------------------------------------------------
36
+ # Two options to enable readline compatible libraries:
37
+ #
38
+ # --enable-editline
39
+ # --enable-readline
40
+ #
41
+ # Both are enabled by default. If, after command line processing both are
42
+ # still enabled, the script searches for editline first and automatically
43
+ # disables readline if it is found. So, to use readline explicitly, the
44
+ # user must pass "--disable-editline". To disable command line editing
45
+ # support altogether, "--disable-editline --disable-readline".
46
+ #
47
+ # When searching for either library, check for headers before libraries
48
+ # as some distros supply packages that contain libraries but not header
49
+ # files, which come as a separate development package.
50
+ #
51
+ AC_ARG_ENABLE(editline, [AS_HELP_STRING([--enable-editline],[use BSD libedit])])
52
+ AC_ARG_ENABLE(readline, [AS_HELP_STRING([--enable-readline],[use readline])])
53
+
54
+ AS_IF([ test x"$enable_editline" != xno ],[
55
+ AC_CHECK_HEADERS([editline/readline.h],[
56
+ sLIBS=$LIBS
57
+ LIBS=""
58
+ AC_SEARCH_LIBS([readline],[edit],[
59
+ AC_DEFINE([HAVE_EDITLINE],1,Define to use BSD editline)
60
+ READLINE_LIBS="$LIBS -ltinfo"
61
+ enable_readline=no
62
+ ],[],[-ltinfo])
63
+ AS_UNSET(ac_cv_search_readline)
64
+ LIBS=$sLIBS
65
+ ])
66
+ ])
67
+
68
+ AS_IF([ test x"$enable_readline" != xno ],[
69
+ AC_CHECK_HEADERS([readline/readline.h],[
70
+ sLIBS=$LIBS
71
+ LIBS=""
72
+ AC_SEARCH_LIBS(tgetent, termcap curses ncurses ncursesw, [], [])
73
+ AC_SEARCH_LIBS(readline,[readline edit], [
74
+ AC_DEFINE([HAVE_READLINE],1,Define to use readline or wrapper)
75
+ READLINE_LIBS=$LIBS
76
+ ])
77
+ LIBS=$sLIBS
78
+ ])
79
+ ])
80
+
81
+ AC_SUBST(READLINE_LIBS)
82
+ #-----------------------------------------------------------------------
83
+
84
+ #-----------------------------------------------------------------------
85
+ # --enable-threadsafe
86
+ #
87
+ AC_ARG_ENABLE(threadsafe, [AS_HELP_STRING(
88
+ [--enable-threadsafe], [build a thread-safe library [default=yes]])],
89
+ [], [enable_threadsafe=yes])
90
+ if test x"$enable_threadsafe" == "xno"; then
91
+ BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_THREADSAFE=0"
92
+ else
93
+ BUILD_CFLAGS="$BUILD_CFLAGS -D_REENTRANT=1 -DSQLITE_THREADSAFE=1"
94
+ AC_SEARCH_LIBS(pthread_create, pthread)
95
+ AC_SEARCH_LIBS(pthread_mutexattr_init, pthread)
96
+ fi
97
+ #-----------------------------------------------------------------------
98
+
99
+ #-----------------------------------------------------------------------
100
+ # --enable-dynamic-extensions
101
+ #
102
+ AC_ARG_ENABLE(dynamic-extensions, [AS_HELP_STRING(
103
+ [--enable-dynamic-extensions], [support loadable extensions [default=yes]])],
104
+ [], [enable_dynamic_extensions=yes])
105
+ if test x"$enable_dynamic_extensions" != "xno"; then
106
+ AC_SEARCH_LIBS(dlopen, dl)
107
+ else
108
+ BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_OMIT_LOAD_EXTENSION=1"
109
+ fi
110
+ AC_MSG_CHECKING([for whether to support dynamic extensions])
111
+ AC_MSG_RESULT($enable_dynamic_extensions)
112
+ #-----------------------------------------------------------------------
113
+
114
+ #-----------------------------------------------------------------------
115
+ # --enable-math
116
+ #
117
+ AC_ARG_ENABLE(math, [AS_HELP_STRING(
118
+ [--enable-math], [SQL math functions [default=yes]])],
119
+ [], [enable_math=yes])
120
+ AC_MSG_CHECKING([SQL math functions])
121
+ if test x"$enable_math" = "xyes"; then
122
+ BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_MATH_FUNCTIONS"
123
+ AC_MSG_RESULT([enabled])
124
+ AC_SEARCH_LIBS(ceil, m)
125
+ else
126
+ AC_MSG_RESULT([disabled])
127
+ fi
128
+ #-----------------------------------------------------------------------
129
+
130
+ #-----------------------------------------------------------------------
131
+ # --enable-fts4
132
+ #
133
+ AC_ARG_ENABLE(fts4, [AS_HELP_STRING(
134
+ [--enable-fts4], [include fts4 support [default=yes]])],
135
+ [], [enable_fts4=yes])
136
+ AC_MSG_CHECKING([FTS4 extension])
137
+ if test x"$enable_fts4" = "xyes"; then
138
+ BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS4"
139
+ AC_MSG_RESULT([enabled])
140
+ else
141
+ AC_MSG_RESULT([disabled])
142
+ fi
143
+ #-----------------------------------------------------------------------
144
+
145
+ #-----------------------------------------------------------------------
146
+ # --enable-fts3
147
+ #
148
+ AC_ARG_ENABLE(fts3, [AS_HELP_STRING(
149
+ [--enable-fts3], [include fts3 support [default=no]])],
150
+ [], [])
151
+ AC_MSG_CHECKING([FTS3 extension])
152
+ if test x"$enable_fts3" = "xyes" -a x"$enable_fts4" = "xno"; then
153
+ BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS3"
154
+ AC_MSG_RESULT([enabled])
155
+ else
156
+ AC_MSG_RESULT([disabled])
157
+ fi
158
+ #-----------------------------------------------------------------------
159
+
160
+ #-----------------------------------------------------------------------
161
+ # --enable-fts5
162
+ #
163
+ AC_ARG_ENABLE(fts5, [AS_HELP_STRING(
164
+ [--enable-fts5], [include fts5 support [default=yes]])],
165
+ [], [enable_fts5=yes])
166
+ AC_MSG_CHECKING([FTS5 extension])
167
+ if test x"$enable_fts5" = "xyes"; then
168
+ AC_MSG_RESULT([enabled])
169
+ AC_SEARCH_LIBS(log, m)
170
+ BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_FTS5"
171
+ else
172
+ AC_MSG_RESULT([disabled])
173
+ fi
174
+ #-----------------------------------------------------------------------
175
+
176
+ #-----------------------------------------------------------------------
177
+ # --enable-rtree
178
+ #
179
+ AC_ARG_ENABLE(rtree, [AS_HELP_STRING(
180
+ [--enable-rtree], [include rtree support [default=yes]])],
181
+ [], [enable_rtree=yes])
182
+ AC_MSG_CHECKING([RTREE extension])
183
+ if test x"$enable_rtree" = "xyes"; then
184
+ BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_GEOPOLY"
185
+ AC_MSG_RESULT([enabled])
186
+ else
187
+ AC_MSG_RESULT([disabled])
188
+ fi
189
+ #-----------------------------------------------------------------------
190
+
191
+ #-----------------------------------------------------------------------
192
+ # --enable-session
193
+ #
194
+ AC_ARG_ENABLE(session, [AS_HELP_STRING(
195
+ [--enable-session], [enable the session extension [default=no]])],
196
+ [], [])
197
+ AC_MSG_CHECKING([Session extension])
198
+ if test x"$enable_session" = "xyes"; then
199
+ BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK"
200
+ AC_MSG_RESULT([enabled])
201
+ else
202
+ AC_MSG_RESULT([disabled])
203
+ fi
204
+ #-----------------------------------------------------------------------
205
+
206
+ #-----------------------------------------------------------------------
207
+ # --enable-debug
208
+ #
209
+ AC_ARG_ENABLE(debug, [AS_HELP_STRING(
210
+ [--enable-debug], [build with debugging features enabled [default=no]])],
211
+ [], [])
212
+ AC_MSG_CHECKING([Build type])
213
+ if test x"$enable_debug" = "xyes"; then
214
+ BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_DEBUG -DSQLITE_ENABLE_SELECTTRACE -DSQLITE_ENABLE_WHERETRACE"
215
+ CFLAGS="-g -O0"
216
+ AC_MSG_RESULT([debug])
217
+ else
218
+ AC_MSG_RESULT([release])
219
+ fi
220
+ #-----------------------------------------------------------------------
221
+
222
+ #-----------------------------------------------------------------------
223
+ # --enable-static-shell
224
+ #
225
+ AC_ARG_ENABLE(static-shell, [AS_HELP_STRING(
226
+ [--enable-static-shell],
227
+ [statically link libsqlite3 into shell tool [default=yes]])],
228
+ [], [enable_static_shell=yes])
229
+ if test x"$enable_static_shell" = "xyes"; then
230
+ EXTRA_SHELL_OBJ=sqlite3-sqlite3.$OBJEXT
231
+ else
232
+ EXTRA_SHELL_OBJ=libsqlite3.la
233
+ fi
234
+ AC_SUBST(EXTRA_SHELL_OBJ)
235
+ #-----------------------------------------------------------------------
236
+
237
+ AC_CHECK_FUNCS(posix_fallocate)
238
+ AC_CHECK_HEADERS(zlib.h,[
239
+ AC_SEARCH_LIBS(deflate,z,[BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_HAVE_ZLIB"])
240
+ ])
241
+
242
+ AC_SEARCH_LIBS(system,,,[SHELL_CFLAGS="-DSQLITE_NOHAVE_SYSTEM"])
243
+ AC_SUBST(SHELL_CFLAGS)
244
+
245
+ #-----------------------------------------------------------------------
246
+ # UPDATE: Maybe it's better if users just set CFLAGS before invoking
247
+ # configure. This option doesn't really add much...
248
+ #
249
+ # --enable-tempstore
250
+ #
251
+ # AC_ARG_ENABLE(tempstore, [AS_HELP_STRING(
252
+ # [--enable-tempstore],
253
+ # [in-memory temporary tables (never, no, yes, always) [default=no]])],
254
+ # [], [enable_tempstore=no])
255
+ # AC_MSG_CHECKING([for whether or not to store temp tables in-memory])
256
+ # case "$enable_tempstore" in
257
+ # never ) TEMP_STORE=0 ;;
258
+ # no ) TEMP_STORE=1 ;;
259
+ # always ) TEMP_STORE=3 ;;
260
+ # yes ) TEMP_STORE=3 ;;
261
+ # * )
262
+ # TEMP_STORE=1
263
+ # enable_tempstore=yes
264
+ # ;;
265
+ # esac
266
+ # AC_MSG_RESULT($enable_tempstore)
267
+ # AC_SUBST(TEMP_STORE)
268
+ #-----------------------------------------------------------------------
269
+
270
+ AC_OUTPUT
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/Makefile.in ADDED
@@ -0,0 +1,463 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Makefile.in --
2
+ #
3
+ # This file is a Makefile for Sample TEA Extension. If it has the name
4
+ # "Makefile.in" then it is a template for a Makefile; to generate the
5
+ # actual Makefile, run "./configure", which is a configuration script
6
+ # generated by the "autoconf" program (constructs like "@foo@" will get
7
+ # replaced in the actual Makefile.
8
+ #
9
+ # Copyright (c) 1999 Scriptics Corporation.
10
+ # Copyright (c) 2002-2005 ActiveState Corporation.
11
+ #
12
+ # See the file "license.terms" for information on usage and redistribution
13
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14
+
15
+ #========================================================================
16
+ # Add additional lines to handle any additional AC_SUBST cases that
17
+ # have been added in a customized configure script.
18
+ #========================================================================
19
+
20
+ #SAMPLE_NEW_VAR = @SAMPLE_NEW_VAR@
21
+
22
+ #========================================================================
23
+ # Nothing of the variables below this line should need to be changed.
24
+ # Please check the TARGETS section below to make sure the make targets
25
+ # are correct.
26
+ #========================================================================
27
+
28
+ #========================================================================
29
+ # The names of the source files is defined in the configure script.
30
+ # The object files are used for linking into the final library.
31
+ # This will be used when a dist target is added to the Makefile.
32
+ # It is not important to specify the directory, as long as it is the
33
+ # $(srcdir) or in the generic, win or unix subdirectory.
34
+ #========================================================================
35
+
36
+ PKG_SOURCES = @PKG_SOURCES@
37
+ PKG_OBJECTS = @PKG_OBJECTS@
38
+
39
+ PKG_STUB_SOURCES = @PKG_STUB_SOURCES@
40
+ PKG_STUB_OBJECTS = @PKG_STUB_OBJECTS@
41
+
42
+ #========================================================================
43
+ # PKG_TCL_SOURCES identifies Tcl runtime files that are associated with
44
+ # this package that need to be installed, if any.
45
+ #========================================================================
46
+
47
+ PKG_TCL_SOURCES = @PKG_TCL_SOURCES@
48
+
49
+ #========================================================================
50
+ # This is a list of public header files to be installed, if any.
51
+ #========================================================================
52
+
53
+ PKG_HEADERS = @PKG_HEADERS@
54
+
55
+ #========================================================================
56
+ # "PKG_LIB_FILE" refers to the library (dynamic or static as per
57
+ # configuration options) composed of the named objects.
58
+ #========================================================================
59
+
60
+ PKG_LIB_FILE = @PKG_LIB_FILE@
61
+ PKG_LIB_FILE8 = @PKG_LIB_FILE8@
62
+ PKG_LIB_FILE9 = @PKG_LIB_FILE9@
63
+ PKG_STUB_LIB_FILE = @PKG_STUB_LIB_FILE@
64
+
65
+ lib_BINARIES = $(PKG_LIB_FILE)
66
+ BINARIES = $(lib_BINARIES)
67
+
68
+ SHELL = @SHELL@
69
+
70
+ srcdir = @srcdir@
71
+ prefix = @prefix@
72
+ exec_prefix = @exec_prefix@
73
+
74
+ bindir = @bindir@
75
+ libdir = @libdir@
76
+ includedir = @includedir@
77
+ datarootdir = @datarootdir@
78
+ runstatedir = @runstatedir@
79
+ datadir = @datadir@
80
+ mandir = @mandir@
81
+
82
+ DESTDIR =
83
+
84
+ PKG_DIR = $(PACKAGE_NAME)$(PACKAGE_VERSION)
85
+ pkgdatadir = $(datadir)/$(PKG_DIR)
86
+ pkglibdir = $(libdir)/$(PKG_DIR)
87
+ pkgincludedir = $(includedir)/$(PKG_DIR)
88
+
89
+ top_builddir = @abs_top_builddir@
90
+
91
+ INSTALL_OPTIONS =
92
+ INSTALL = @INSTALL@ $(INSTALL_OPTIONS)
93
+ INSTALL_DATA_DIR = @INSTALL_DATA_DIR@
94
+ INSTALL_DATA = @INSTALL_DATA@
95
+ INSTALL_PROGRAM = @INSTALL_PROGRAM@
96
+ INSTALL_SCRIPT = @INSTALL_SCRIPT@
97
+ INSTALL_LIBRARY = @INSTALL_LIBRARY@
98
+
99
+ PACKAGE_NAME = @PACKAGE_NAME@
100
+ PACKAGE_VERSION = @PACKAGE_VERSION@
101
+ CC = @CC@
102
+ CFLAGS_DEFAULT = @CFLAGS_DEFAULT@
103
+ CFLAGS_WARNING = @CFLAGS_WARNING@
104
+ EXEEXT = @EXEEXT@
105
+ LDFLAGS_DEFAULT = @LDFLAGS_DEFAULT@
106
+ MAKE_LIB = @MAKE_LIB@
107
+ MAKE_STUB_LIB = @MAKE_STUB_LIB@
108
+ OBJEXT = @OBJEXT@
109
+ RANLIB = @RANLIB@
110
+ RANLIB_STUB = @RANLIB_STUB@
111
+ SHLIB_CFLAGS = @SHLIB_CFLAGS@
112
+ SHLIB_LD = @SHLIB_LD@
113
+ SHLIB_LD_LIBS = @SHLIB_LD_LIBS@
114
+ STLIB_LD = @STLIB_LD@
115
+ #TCL_DEFS = @TCL_DEFS@
116
+ TCL_BIN_DIR = @TCL_BIN_DIR@
117
+ TCL_SRC_DIR = @TCL_SRC_DIR@
118
+ #TK_BIN_DIR = @TK_BIN_DIR@
119
+ #TK_SRC_DIR = @TK_SRC_DIR@
120
+
121
+ # Not used, but retained for reference of what libs Tcl required
122
+ #TCL_LIBS = @TCL_LIBS@
123
+
124
+ #========================================================================
125
+ # TCLLIBPATH seeds the auto_path in Tcl's init.tcl so we can test our
126
+ # package without installing. The other environment variables allow us
127
+ # to test against an uninstalled Tcl. Add special env vars that you
128
+ # require for testing here (like TCLX_LIBRARY).
129
+ #========================================================================
130
+
131
+ EXTRA_PATH = $(top_builddir):$(TCL_BIN_DIR)
132
+ #EXTRA_PATH = $(top_builddir):$(TCL_BIN_DIR):$(TK_BIN_DIR)
133
+ TCLLIBPATH = $(top_builddir)
134
+ TCLSH_ENV = TCL_LIBRARY=`@CYGPATH@ $(TCL_SRC_DIR)/library`
135
+ PKG_ENV = @LD_LIBRARY_PATH_VAR@="$(EXTRA_PATH):$(@LD_LIBRARY_PATH_VAR@)" \
136
+ PATH="$(EXTRA_PATH):$(PATH)" \
137
+ TCLLIBPATH="$(TCLLIBPATH)"
138
+
139
+ TCLSH_PROG = @TCLSH_PROG@
140
+ TCLSH = $(TCLSH_ENV) $(PKG_ENV) $(TCLSH_PROG)
141
+
142
+ #WISH_ENV = TK_LIBRARY=`@CYGPATH@ $(TK_SRC_DIR)/library`
143
+ #WISH_PROG = @WISH_PROG@
144
+ #WISH = $(TCLSH_ENV) $(WISH_ENV) $(PKG_ENV) $(WISH_PROG)
145
+
146
+ SHARED_BUILD = @SHARED_BUILD@
147
+
148
+ INCLUDES = @PKG_INCLUDES@ @TCL_INCLUDES@ -I. -I$(srcdir)/..
149
+ #INCLUDES = @PKG_INCLUDES@ @TCL_INCLUDES@ @TK_INCLUDES@ @TK_XINCLUDES@
150
+
151
+ PKG_CFLAGS = @PKG_CFLAGS@
152
+
153
+ # TCL_DEFS is not strictly need here, but if you remove it, then you
154
+ # must make sure that configure.ac checks for the necessary components
155
+ # that your library may use. TCL_DEFS can actually be a problem if
156
+ # you do not compile with a similar machine setup as the Tcl core was
157
+ # compiled with.
158
+ #DEFS = $(TCL_DEFS) @DEFS@ $(PKG_CFLAGS)
159
+ DEFS = @DEFS@ $(PKG_CFLAGS)
160
+
161
+ # Move pkgIndex.tcl to 'BINARIES' var if it is generated in the Makefile
162
+ CONFIG_CLEAN_FILES = Makefile pkgIndex.tcl
163
+ CLEANFILES = @CLEANFILES@
164
+
165
+ CPPFLAGS = @CPPFLAGS@
166
+ LIBS = @PKG_LIBS@ @LIBS@
167
+ AR = @AR@
168
+ CFLAGS = @CFLAGS@
169
+ LDFLAGS = @LDFLAGS@
170
+ LDFLAGS_DEFAULT = @LDFLAGS_DEFAULT@
171
+ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) \
172
+ $(CFLAGS_DEFAULT) $(CFLAGS_WARNING) $(SHLIB_CFLAGS) $(CFLAGS)
173
+
174
+ GDB = gdb
175
+ VALGRIND = valgrind
176
+ VALGRINDARGS = --tool=memcheck --num-callers=8 --leak-resolution=high \
177
+ --leak-check=yes --show-reachable=yes -v
178
+
179
+ .SUFFIXES: .c .$(OBJEXT)
180
+
181
+ #========================================================================
182
+ # Start of user-definable TARGETS section
183
+ #========================================================================
184
+
185
+ #========================================================================
186
+ # TEA TARGETS. Please note that the "libraries:" target refers to platform
187
+ # independent files, and the "binaries:" target includes executable programs and
188
+ # platform-dependent libraries. Modify these targets so that they install
189
+ # the various pieces of your package. The make and install rules
190
+ # for the BINARIES that you specified above have already been done.
191
+ #========================================================================
192
+
193
+ all: binaries libraries doc
194
+
195
+ #========================================================================
196
+ # The binaries target builds executable programs, Windows .dll's, unix
197
+ # shared/static libraries, and any other platform-dependent files.
198
+ # The list of targets to build for "binaries:" is specified at the top
199
+ # of the Makefile, in the "BINARIES" variable.
200
+ #========================================================================
201
+
202
+ binaries: $(BINARIES)
203
+
204
+ libraries:
205
+
206
+ #========================================================================
207
+ # Your doc target should differentiate from doc builds (by the developer)
208
+ # and doc installs (see install-doc), which just install the docs on the
209
+ # end user machine when building from source.
210
+ #========================================================================
211
+
212
+ doc:
213
+ @echo "If you have documentation to create, place the commands to"
214
+ @echo "build the docs in the 'doc:' target. For example:"
215
+ @echo " xml2nroff sample.xml > sample.n"
216
+ @echo " xml2html sample.xml > sample.html"
217
+
218
+ install: all install-binaries install-libraries install-doc
219
+
220
+ install-binaries: binaries install-lib-binaries install-bin-binaries
221
+
222
+ #========================================================================
223
+ # This rule installs platform-independent files, such as header files.
224
+ # The list=...; for p in $$list handles the empty list case x-platform.
225
+ #========================================================================
226
+
227
+ install-libraries: libraries
228
+ @$(INSTALL_DATA_DIR) "$(DESTDIR)$(includedir)"
229
+ @echo "Installing header files in $(DESTDIR)$(includedir)"
230
+ @list='$(PKG_HEADERS)'; for i in $$list; do \
231
+ echo "Installing $(srcdir)/$$i" ; \
232
+ $(INSTALL_DATA) $(srcdir)/$$i "$(DESTDIR)$(includedir)" ; \
233
+ done;
234
+
235
+ #========================================================================
236
+ # Install documentation. Unix manpages should go in the $(mandir)
237
+ # directory.
238
+ #========================================================================
239
+
240
+ install-doc: doc
241
+ @$(INSTALL_DATA_DIR) "$(DESTDIR)$(mandir)/mann"
242
+ @echo "Installing documentation in $(DESTDIR)$(mandir)"
243
+ @list='$(srcdir)/doc/*.n'; for i in $$list; do \
244
+ echo "Installing $$i"; \
245
+ $(INSTALL_DATA) $$i "$(DESTDIR)$(mandir)/mann" ; \
246
+ done
247
+
248
+ test: binaries libraries
249
+ @echo "SQLite TEA distribution does not include tests"
250
+
251
+ shell: binaries libraries
252
+ @$(TCLSH) $(SCRIPT)
253
+
254
+ gdb:
255
+ $(TCLSH_ENV) $(PKG_ENV) $(GDB) $(TCLSH_PROG) $(SCRIPT)
256
+
257
+ gdb-test: binaries libraries
258
+ $(TCLSH_ENV) $(PKG_ENV) $(GDB) \
259
+ --args $(TCLSH_PROG) `@CYGPATH@ $(srcdir)/tests/all.tcl` \
260
+ $(TESTFLAGS) -singleproc 1 \
261
+ -load "package ifneeded $(PACKAGE_NAME) $(PACKAGE_VERSION) \
262
+ [list load `@CYGPATH@ $(PKG_LIB_FILE)` [string totitle $(PACKAGE_NAME)]]"
263
+
264
+ valgrind: binaries libraries
265
+ $(TCLSH_ENV) $(PKG_ENV) $(VALGRIND) $(VALGRINDARGS) $(TCLSH_PROG) \
266
+ `@CYGPATH@ $(srcdir)/tests/all.tcl` $(TESTFLAGS)
267
+
268
+ valgrindshell: binaries libraries
269
+ $(TCLSH_ENV) $(PKG_ENV) $(VALGRIND) $(VALGRINDARGS) $(TCLSH_PROG) $(SCRIPT)
270
+
271
+ depend:
272
+
273
+ #========================================================================
274
+ # $(PKG_LIB_FILE) should be listed as part of the BINARIES variable
275
+ # mentioned above. That will ensure that this target is built when you
276
+ # run "make binaries".
277
+ #
278
+ # The $(PKG_OBJECTS) objects are created and linked into the final
279
+ # library. In most cases these object files will correspond to the
280
+ # source files above.
281
+ #========================================================================
282
+
283
+ $(PKG_LIB_FILE): $(PKG_OBJECTS)
284
+ -rm -f $(PKG_LIB_FILE)
285
+ ${MAKE_LIB}
286
+ $(RANLIB) $(PKG_LIB_FILE)
287
+
288
+ $(PKG_STUB_LIB_FILE): $(PKG_STUB_OBJECTS)
289
+ -rm -f $(PKG_STUB_LIB_FILE)
290
+ ${MAKE_STUB_LIB}
291
+ $(RANLIB_STUB) $(PKG_STUB_LIB_FILE)
292
+
293
+ #========================================================================
294
+ # We need to enumerate the list of .c to .o lines here.
295
+ #
296
+ # In the following lines, $(srcdir) refers to the toplevel directory
297
+ # containing your extension. If your sources are in a subdirectory,
298
+ # you will have to modify the paths to reflect this:
299
+ #
300
+ # sample.$(OBJEXT): $(srcdir)/generic/sample.c
301
+ # $(COMPILE) -c `@CYGPATH@ $(srcdir)/generic/sample.c` -o $@
302
+ #
303
+ # Setting the VPATH variable to a list of paths will cause the makefile
304
+ # to look into these paths when resolving .c to .obj dependencies.
305
+ # As necessary, add $(srcdir):$(srcdir)/compat:....
306
+ #========================================================================
307
+
308
+ VPATH = $(srcdir):$(srcdir)/generic:$(srcdir)/unix:$(srcdir)/win:$(srcdir)/macosx
309
+
310
+ .c.@OBJEXT@:
311
+ $(COMPILE) -c `@CYGPATH@ $<` -o $@
312
+
313
+
314
+ #========================================================================
315
+ # Distribution creation
316
+ # You may need to tweak this target to make it work correctly.
317
+ #========================================================================
318
+
319
+ #COMPRESS = tar cvf $(PKG_DIR).tar $(PKG_DIR); compress $(PKG_DIR).tar
320
+ COMPRESS = tar zcvf $(PKG_DIR).tar.gz $(PKG_DIR)
321
+ DIST_ROOT = /tmp/dist
322
+ DIST_DIR = $(DIST_ROOT)/$(PKG_DIR)
323
+
324
+ DIST_INSTALL_DATA = CPPROG='cp -p' $(INSTALL) -m 644
325
+ DIST_INSTALL_SCRIPT = CPPROG='cp -p' $(INSTALL) -m 755
326
+
327
+ dist-clean:
328
+ rm -rf $(DIST_DIR) $(DIST_ROOT)/$(PKG_DIR).tar.*
329
+
330
+ dist: dist-clean $(srcdir)/manifest.uuid
331
+ $(INSTALL_DATA_DIR) $(DIST_DIR)
332
+
333
+ # TEA files
334
+ $(DIST_INSTALL_DATA) $(srcdir)/Makefile.in \
335
+ $(srcdir)/aclocal.m4 $(srcdir)/configure.ac \
336
+ $(DIST_DIR)/
337
+ $(DIST_INSTALL_SCRIPT) $(srcdir)/configure $(DIST_DIR)/
338
+
339
+ $(INSTALL_DATA_DIR) $(DIST_DIR)/tclconfig
340
+ $(DIST_INSTALL_DATA) $(srcdir)/tclconfig/README.txt \
341
+ $(srcdir)/manifest.uuid \
342
+ $(srcdir)/tclconfig/tcl.m4 $(srcdir)/tclconfig/install-sh \
343
+ $(DIST_DIR)/tclconfig/
344
+
345
+ # Extension files
346
+ $(DIST_INSTALL_DATA) \
347
+ $(srcdir)/ChangeLog \
348
+ $(srcdir)/README.sha \
349
+ $(srcdir)/license.terms \
350
+ $(srcdir)/README \
351
+ $(srcdir)/pkgIndex.tcl.in \
352
+ $(DIST_DIR)/
353
+
354
+ list='demos doc generic library macosx tests unix win'; \
355
+ for p in $$list; do \
356
+ if test -d $(srcdir)/$$p ; then \
357
+ $(INSTALL_DATA_DIR) $(DIST_DIR)/$$p; \
358
+ $(DIST_INSTALL_DATA) $(srcdir)/$$p/* $(DIST_DIR)/$$p/; \
359
+ fi; \
360
+ done
361
+
362
+ (cd $(DIST_ROOT); $(COMPRESS);)
363
+
364
+ #========================================================================
365
+ # End of user-definable section
366
+ #========================================================================
367
+
368
+ #========================================================================
369
+ # Don't modify the file to clean here. Instead, set the "CLEANFILES"
370
+ # variable in configure.ac
371
+ #========================================================================
372
+
373
+ clean:
374
+ -test -z "$(BINARIES)" || rm -f $(BINARIES)
375
+ -rm -f *.$(OBJEXT) core *.core
376
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
377
+
378
+ distclean: clean
379
+ -rm -f *.tab.c
380
+ -rm -f $(CONFIG_CLEAN_FILES)
381
+ -rm -f config.cache config.log config.status
382
+
383
+ #========================================================================
384
+ # Install binary object libraries. On Windows this includes both .dll and
385
+ # .lib files. Because the .lib files are not explicitly listed anywhere,
386
+ # we need to deduce their existence from the .dll file of the same name.
387
+ # Library files go into the lib directory.
388
+ # In addition, this will generate the pkgIndex.tcl
389
+ # file in the install location (assuming it can find a usable tclsh shell)
390
+ #
391
+ # You should not have to modify this target.
392
+ #========================================================================
393
+
394
+ install-lib-binaries: binaries
395
+ @$(INSTALL_DATA_DIR) "$(DESTDIR)$(pkglibdir)"
396
+ @list='$(lib_BINARIES)'; for p in $$list; do \
397
+ if test -f $$p; then \
398
+ echo " $(INSTALL_LIBRARY) $$p $(DESTDIR)$(pkglibdir)/$$p"; \
399
+ $(INSTALL_LIBRARY) $$p "$(DESTDIR)$(pkglibdir)/$$p"; \
400
+ ext=`echo $$p|sed -e "s/.*\.//"`; \
401
+ if test "x$$ext" = "xdll"; then \
402
+ lib=`basename $$p|sed -e 's/.[^.]*$$//'`.lib; \
403
+ if test -f $$lib; then \
404
+ echo " $(INSTALL_DATA) $$lib $(DESTDIR)$(pkglibdir)/$$lib"; \
405
+ $(INSTALL_DATA) $$lib "$(DESTDIR)$(pkglibdir)/$$lib"; \
406
+ fi; \
407
+ fi; \
408
+ fi; \
409
+ done
410
+ @list='$(PKG_TCL_SOURCES)'; for p in $$list; do \
411
+ if test -f $(srcdir)/$$p; then \
412
+ destp=`basename $$p`; \
413
+ echo " Install $$destp $(DESTDIR)$(pkglibdir)/$$destp"; \
414
+ $(INSTALL_DATA) $(srcdir)/$$p "$(DESTDIR)$(pkglibdir)/$$destp"; \
415
+ fi; \
416
+ done
417
+ @if test "x$(SHARED_BUILD)" = "x1"; then \
418
+ echo " Install pkgIndex.tcl $(DESTDIR)$(pkglibdir)"; \
419
+ $(INSTALL_DATA) pkgIndex.tcl "$(DESTDIR)$(pkglibdir)"; \
420
+ fi
421
+
422
+ #========================================================================
423
+ # Install binary executables (e.g. .exe files and dependent .dll files)
424
+ # This is for files that must go in the bin directory (located next to
425
+ # wish and tclsh), like dependent .dll files on Windows.
426
+ #
427
+ # You should not have to modify this target, except to define bin_BINARIES
428
+ # above if necessary.
429
+ #========================================================================
430
+
431
+ install-bin-binaries: binaries
432
+ @$(INSTALL_DATA_DIR) "$(DESTDIR)$(bindir)"
433
+ @list='$(bin_BINARIES)'; for p in $$list; do \
434
+ if test -f $$p; then \
435
+ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$p"; \
436
+ $(INSTALL_PROGRAM) $$p "$(DESTDIR)$(bindir)/$$p"; \
437
+ fi; \
438
+ done
439
+
440
+ .SUFFIXES: .c .$(OBJEXT)
441
+
442
+ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
443
+ cd $(top_builddir) \
444
+ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
445
+
446
+ uninstall-binaries:
447
+ list='$(lib_BINARIES)'; for p in $$list; do \
448
+ rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
449
+ done
450
+ list='$(PKG_TCL_SOURCES)'; for p in $$list; do \
451
+ p=`basename $$p`; \
452
+ rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
453
+ done
454
+ list='$(bin_BINARIES)'; for p in $$list; do \
455
+ rm -f "$(DESTDIR)$(bindir)/$$p"; \
456
+ done
457
+
458
+ .PHONY: all binaries clean depend distclean doc install libraries test
459
+ .PHONY: gdb gdb-test valgrind valgrindshell
460
+
461
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
462
+ # Otherwise a system limit (for SysV at least) may be exceeded.
463
+ .NOEXPORT:
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/README.txt ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This is the SQLite extension for Tcl using the Tcl Extension
2
+ Architecture (TEA).
3
+
4
+ ----------------------- A BETTER WAY ---------------------------
5
+
6
+ A better way to build the TCL extension for SQLite is to use the
7
+ canonical source code tarball. For Unix:
8
+
9
+ ./configure --with-tclsh=$(TCLSH)
10
+ make tclextension-install
11
+
12
+ For Windows:
13
+
14
+ nmake /f Makefile.msc tclextension-install TCLSH_CMD=$(TCLSH)
15
+
16
+ In both of the above, replace $(TCLSH) with the full pathname of
17
+ of the tclsh that you want the SQLite extension to work with. See
18
+ step-by-step instructions at the links below for more information:
19
+
20
+ https://sqlite.org/src/doc/trunk/doc/compile-for-unix.md
21
+ https://sqlite.org/src/doc/trunk/doc/compile-for-windows.md
22
+
23
+ The whole point of the amalgamation-autoconf tarball (in which this
24
+ README.txt file is embedded) is to provide a means of compiling
25
+ SQLite that does not require first installing TCL and/or "tclsh".
26
+ The canonical Makefile in the SQLite source tree provides more
27
+ capabilities (such as the the ability to run test cases to ensure
28
+ that the build worked) and is better maintained. The only
29
+ downside of the canonical Makfile is that it requires a TCL
30
+ installation. But if you are wanting to build the TCL extension for
31
+ SQLite, then presumably you already have a TCL installation. So why
32
+ not just use the more-capable and better-maintained canoncal Makefile?
33
+
34
+ This TEA builder is derived from code found at
35
+
36
+ http://core.tcl-lang.org/tclconfig
37
+ http://core.tcl-lang.org/sampleextension
38
+
39
+ The SQLite developers do not understand how it works. It seems to
40
+ work for us. It might also work for you. But we cannot promise that.
41
+
42
+ If you want to use this TEA builder and it works for you, that's fine.
43
+ But if you have trouble, the first thing you should do is go back
44
+ to using the canonical Makefile in the SQLite source tree.
45
+
46
+ ------------------------------------------------------------------
47
+
48
+
49
+ UNIX BUILD
50
+ ==========
51
+
52
+ Building under most UNIX systems is easy, just run the configure script
53
+ and then run make. For more information about the build process, see
54
+ the tcl/unix/README file in the Tcl src dist. The following minimal
55
+ example will install the extension in the /opt/tcl directory.
56
+
57
+ $ cd sqlite-*-tea
58
+ $ ./configure --prefix=/opt/tcl
59
+ $ make
60
+ $ make install
61
+
62
+ WINDOWS BUILD
63
+ =============
64
+
65
+ The recommended method to build extensions under windows is to use the
66
+ Msys + Mingw build process. This provides a Unix-style build while
67
+ generating native Windows binaries. Using the Msys + Mingw build tools
68
+ means that you can use the same configure script as per the Unix build
69
+ to create a Makefile. See the tcl/win/README file for the URL of
70
+ the Msys + Mingw download.
71
+
72
+ If you have VC++ then you may wish to use the files in the win
73
+ subdirectory and build the extension using just VC++. These files have
74
+ been designed to be as generic as possible but will require some
75
+ additional maintenance by the project developer to synchronise with
76
+ the TEA configure.in and Makefile.in files. Instructions for using the
77
+ VC++ makefile are written in the first part of the Makefile.vc
78
+ file.
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/aclocal.m4 ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Include the TEA standard macro set
3
+ #
4
+
5
+ builtin(include,tclconfig/tcl.m4)
6
+
7
+ #
8
+ # Add here whatever m4 macros you want to define for your package
9
+ #
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/configure.ac ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -norc
2
+ dnl This file is an input file used by the GNU "autoconf" program to
3
+ dnl generate the file "configure", which is run during Tcl installation
4
+ dnl to configure the system for the local environment.
5
+
6
+ #-----------------------------------------------------------------------
7
+ # Sample configure.ac for Tcl Extensions. The only places you should
8
+ # need to modify this file are marked by the string __CHANGE__
9
+ #-----------------------------------------------------------------------
10
+
11
+ #-----------------------------------------------------------------------
12
+ # __CHANGE__
13
+ # Set your package name and version numbers here.
14
+ #
15
+ # This initializes the environment with PACKAGE_NAME and PACKAGE_VERSION
16
+ # set as provided. These will also be added as -D defs in your Makefile
17
+ # so you can encode the package version directly into the source files.
18
+ # This will also define a special symbol for Windows (BUILD_<PACKAGE_NAME>
19
+ # so that we create the export library with the dll.
20
+ #-----------------------------------------------------------------------
21
+
22
+ AC_INIT([sqlite],[3.48.0])
23
+
24
+ #--------------------------------------------------------------------
25
+ # Call TEA_INIT as the first TEA_ macro to set up initial vars.
26
+ # This will define a ${TEA_PLATFORM} variable == "unix" or "windows"
27
+ # as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE.
28
+ #--------------------------------------------------------------------
29
+
30
+ TEA_INIT()
31
+
32
+ AC_CONFIG_AUX_DIR(tclconfig)
33
+
34
+ #--------------------------------------------------------------------
35
+ # Load the tclConfig.sh file
36
+ #--------------------------------------------------------------------
37
+
38
+ TEA_PATH_TCLCONFIG
39
+ TEA_LOAD_TCLCONFIG
40
+
41
+ #--------------------------------------------------------------------
42
+ # Load the tkConfig.sh file if necessary (Tk extension)
43
+ #--------------------------------------------------------------------
44
+
45
+ #TEA_PATH_TKCONFIG
46
+ #TEA_LOAD_TKCONFIG
47
+
48
+ #-----------------------------------------------------------------------
49
+ # Handle the --prefix=... option by defaulting to what Tcl gave.
50
+ # Must be called after TEA_LOAD_TCLCONFIG and before TEA_SETUP_COMPILER.
51
+ #-----------------------------------------------------------------------
52
+
53
+ TEA_PREFIX
54
+
55
+ #-----------------------------------------------------------------------
56
+ # Standard compiler checks.
57
+ # This sets up CC by using the CC env var, or looks for gcc otherwise.
58
+ # This also calls AC_PROG_CC and a few others to create the basic setup
59
+ # necessary to compile executables.
60
+ #-----------------------------------------------------------------------
61
+
62
+ TEA_SETUP_COMPILER
63
+
64
+ #-----------------------------------------------------------------------
65
+ # __CHANGE__
66
+ # Specify the C source files to compile in TEA_ADD_SOURCES,
67
+ # public headers that need to be installed in TEA_ADD_HEADERS,
68
+ # stub library C source files to compile in TEA_ADD_STUB_SOURCES,
69
+ # and runtime Tcl library files in TEA_ADD_TCL_SOURCES.
70
+ # This defines PKG(_STUB)_SOURCES, PKG(_STUB)_OBJECTS, PKG_HEADERS
71
+ # and PKG_TCL_SOURCES.
72
+ #-----------------------------------------------------------------------
73
+
74
+ TEA_ADD_SOURCES([tclsqlite3.c])
75
+ TEA_ADD_HEADERS([])
76
+ TEA_ADD_INCLUDES([])
77
+ TEA_ADD_LIBS([])
78
+ TEA_ADD_CFLAGS([-DSQLITE_ENABLE_FTS3=1])
79
+ TEA_ADD_CFLAGS([-DSQLITE_ENABLE_FTS4=1])
80
+ TEA_ADD_CFLAGS([-DSQLITE_ENABLE_FTS5=1])
81
+ TEA_ADD_CFLAGS([-DSQLITE_3_SUFFIX_ONLY=1])
82
+ TEA_ADD_CFLAGS([-DSQLITE_ENABLE_RTREE=1])
83
+ TEA_ADD_CFLAGS([-DSQLITE_ENABLE_GEOPOLY=1])
84
+ TEA_ADD_CFLAGS([-DSQLITE_ENABLE_MATH_FUNCTIONS=1])
85
+ TEA_ADD_CFLAGS([-DSQLITE_ENABLE_DESERIALIZE=1])
86
+ TEA_ADD_CFLAGS([-DSQLITE_ENABLE_DBPAGE_VTAB=1])
87
+ TEA_ADD_CFLAGS([-DSQLITE_ENABLE_BYTECODE_VTAB=1])
88
+ TEA_ADD_CFLAGS([-DSQLITE_ENABLE_DBSTAT_VTAB=1])
89
+ TEA_ADD_STUB_SOURCES([])
90
+ TEA_ADD_TCL_SOURCES([])
91
+
92
+ #--------------------------------------------------------------------
93
+ # The --with-system-sqlite causes the TCL bindings to SQLite to use
94
+ # the system shared library for SQLite rather than statically linking
95
+ # against its own private copy. This is dangerous and leads to
96
+ # undersirable dependences and is not recommended.
97
+ # Patchs from rmax.
98
+ #--------------------------------------------------------------------
99
+ AC_ARG_WITH([system-sqlite],
100
+ [AS_HELP_STRING([--with-system-sqlite],
101
+ [use a system-supplied libsqlite3 instead of the bundled one])],
102
+ [], [with_system_sqlite=no])
103
+ if test x$with_system_sqlite != xno; then
104
+ AC_CHECK_HEADER([sqlite3.h],
105
+ [AC_CHECK_LIB([sqlite3],[sqlite3_initialize],
106
+ [AC_DEFINE(USE_SYSTEM_SQLITE)
107
+ LIBS="$LIBS -lsqlite3"])])
108
+ fi
109
+
110
+ #--------------------------------------------------------------------
111
+ # __CHANGE__
112
+ #
113
+ # You can add more files to clean if your extension creates any extra
114
+ # files by extending CLEANFILES.
115
+ # Add pkgIndex.tcl if it is generated in the Makefile instead of ./configure
116
+ # and change Makefile.in to move it from CONFIG_CLEAN_FILES to BINARIES var.
117
+ #
118
+ # A few miscellaneous platform-specific items:
119
+ # TEA_ADD_* any platform specific compiler/build info here.
120
+ #--------------------------------------------------------------------
121
+
122
+ #CLEANFILES="$CLEANFILES pkgIndex.tcl"
123
+ if test "${TEA_PLATFORM}" = "windows" ; then
124
+ # Ensure no empty if clauses
125
+ :
126
+ #TEA_ADD_SOURCES([win/winFile.c])
127
+ #TEA_ADD_INCLUDES([-I\"$(${CYGPATH} ${srcdir}/win)\"])
128
+ else
129
+ # Ensure no empty else clauses
130
+ :
131
+ #TEA_ADD_SOURCES([unix/unixFile.c])
132
+ #TEA_ADD_LIBS([-lsuperfly])
133
+ fi
134
+
135
+ #--------------------------------------------------------------------
136
+ # __CHANGE__
137
+ # Choose which headers you need. Extension authors should try very
138
+ # hard to only rely on the Tcl public header files. Internal headers
139
+ # contain private data structures and are subject to change without
140
+ # notice.
141
+ # This MUST be called after TEA_LOAD_TCLCONFIG / TEA_LOAD_TKCONFIG
142
+ #--------------------------------------------------------------------
143
+
144
+ TEA_PUBLIC_TCL_HEADERS
145
+ #TEA_PRIVATE_TCL_HEADERS
146
+
147
+ #TEA_PUBLIC_TK_HEADERS
148
+ #TEA_PRIVATE_TK_HEADERS
149
+ #TEA_PATH_X
150
+
151
+ #--------------------------------------------------------------------
152
+ # Check whether --enable-threads or --disable-threads was given.
153
+ # This auto-enables if Tcl was compiled threaded.
154
+ #--------------------------------------------------------------------
155
+
156
+ TEA_ENABLE_THREADS
157
+ if test "${TCL_THREADS}" = "1" ; then
158
+ AC_DEFINE(SQLITE_THREADSAFE, 1, [Trigger sqlite threadsafe build])
159
+ # Not automatically added by Tcl because its assumed Tcl links to them,
160
+ # but it may not if it isn't really a threaded build.
161
+ TEA_ADD_LIBS([$THREADS_LIBS])
162
+ else
163
+ AC_DEFINE(SQLITE_THREADSAFE, 0, [Trigger sqlite non-threadsafe build])
164
+ fi
165
+
166
+ #--------------------------------------------------------------------
167
+ # The statement below defines a collection of symbols related to
168
+ # building as a shared library instead of a static library.
169
+ #--------------------------------------------------------------------
170
+
171
+ TEA_ENABLE_SHARED
172
+
173
+ #--------------------------------------------------------------------
174
+ # This macro figures out what flags to use with the compiler/linker
175
+ # when building shared/static debug/optimized objects. This information
176
+ # can be taken from the tclConfig.sh file, but this figures it all out.
177
+ #--------------------------------------------------------------------
178
+
179
+ TEA_CONFIG_CFLAGS
180
+
181
+ #--------------------------------------------------------------------
182
+ # Set the default compiler switches based on the --enable-symbols option.
183
+ #--------------------------------------------------------------------
184
+
185
+ TEA_ENABLE_SYMBOLS
186
+
187
+ #--------------------------------------------------------------------
188
+ # This macro generates a line to use when building a library. It
189
+ # depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS,
190
+ # and TEA_LOAD_TCLCONFIG macros above.
191
+ #--------------------------------------------------------------------
192
+
193
+ TEA_MAKE_LIB
194
+
195
+ #--------------------------------------------------------------------
196
+ # Determine the name of the tclsh and/or wish executables in the
197
+ # Tcl and Tk build directories or the location they were installed
198
+ # into. These paths are used to support running test cases only,
199
+ # the Makefile should not be making use of these paths to generate
200
+ # a pkgIndex.tcl file or anything else at extension build time.
201
+ #--------------------------------------------------------------------
202
+
203
+ TEA_PROG_TCLSH
204
+ #TEA_PROG_WISH
205
+
206
+ #--------------------------------------------------------------------
207
+ # Setup a *Config.sh.in configuration file.
208
+ #--------------------------------------------------------------------
209
+
210
+ #TEA_EXPORT_CONFIG([sample])
211
+ #AC_SUBST(SAMPLE_VAR)
212
+
213
+ #--------------------------------------------------------------------
214
+ # Specify files to substitute AC variables in. You may alternatively
215
+ # have a special pkgIndex.tcl.in or other files which require
216
+ # substituting the AC variables in. Include these here.
217
+ #--------------------------------------------------------------------
218
+
219
+ AC_CONFIG_FILES([Makefile pkgIndex.tcl])
220
+ #AC_CONFIG_FILES([sampleConfig.sh])
221
+
222
+ #--------------------------------------------------------------------
223
+ # Finally, substitute all of the various values into the files
224
+ # specified with AC_CONFIG_FILES.
225
+ #--------------------------------------------------------------------
226
+
227
+ AC_OUTPUT
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/doc/sqlite3.n ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .TH sqlite3 n 4.1 "Tcl-Extensions"
2
+ .HS sqlite3 tcl
3
+ .BS
4
+ .SH NAME
5
+ sqlite3 \- an interface to the SQLite3 database engine
6
+ .SH SYNOPSIS
7
+ \fBsqlite3\fI command_name ?filename?\fR
8
+ .br
9
+ .SH DESCRIPTION
10
+ SQLite3 is a self-contains, zero-configuration, transactional SQL database
11
+ engine. This extension provides an easy to use interface for accessing
12
+ SQLite database files from Tcl.
13
+ .PP
14
+ For full documentation see \fIhttp://www.sqlite.org/\fR and
15
+ in particular \fIhttp://www.sqlite.org/tclsqlite.html\fR.
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/license.terms ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ The author disclaims copyright to this source code. In place of
2
+ a legal notice, here is a blessing:
3
+
4
+ May you do good and not evil.
5
+ May you find forgiveness for yourself and forgive others.
6
+ May you share freely, never taking more than you give.
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/pkgIndex.tcl.in ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- tcl -*-
2
+ # Tcl package index file, version 1.1
3
+ #
4
+ if {[package vsatisfies [package provide Tcl] 9.0-]} {
5
+ package ifneeded sqlite3 @PACKAGE_VERSION@ \
6
+ [list load [file join $dir @PKG_LIB_FILE9@] Sqlite3]
7
+ } else {
8
+ package ifneeded sqlite3 @PACKAGE_VERSION@ \
9
+ [list load [file join $dir @PKG_LIB_FILE8@] Sqlite3]
10
+ }
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/tclconfig/install-sh ADDED
@@ -0,0 +1,541 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # install - install a program, script, or datafile
3
+
4
+ scriptversion=2020-11-14.01; # UTC
5
+
6
+ # This originates from X11R5 (mit/util/scripts/install.sh), which was
7
+ # later released in X11R6 (xc/config/util/install.sh) with the
8
+ # following copyright and license.
9
+ #
10
+ # Copyright (C) 1994 X Consortium
11
+ #
12
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ # of this software and associated documentation files (the "Software"), to
14
+ # deal in the Software without restriction, including without limitation the
15
+ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16
+ # sell copies of the Software, and to permit persons to whom the Software is
17
+ # furnished to do so, subject to the following conditions:
18
+ #
19
+ # The above copyright notice and this permission notice shall be included in
20
+ # all copies or substantial portions of the Software.
21
+ #
22
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26
+ # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
27
+ # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
+ #
29
+ # Except as contained in this notice, the name of the X Consortium shall not
30
+ # be used in advertising or otherwise to promote the sale, use or other deal-
31
+ # ings in this Software without prior written authorization from the X Consor-
32
+ # tium.
33
+ #
34
+ #
35
+ # FSF changes to this file are in the public domain.
36
+ #
37
+ # Calling this script install-sh is preferred over install.sh, to prevent
38
+ # 'make' implicit rules from creating a file called install from it
39
+ # when there is no Makefile.
40
+ #
41
+ # This script is compatible with the BSD install script, but was written
42
+ # from scratch.
43
+
44
+ tab=' '
45
+ nl='
46
+ '
47
+ IFS=" $tab$nl"
48
+
49
+ # Set DOITPROG to "echo" to test this script.
50
+
51
+ doit=${DOITPROG-}
52
+ doit_exec=${doit:-exec}
53
+
54
+ # Put in absolute file names if you don't have them in your path;
55
+ # or use environment vars.
56
+
57
+ chgrpprog=${CHGRPPROG-chgrp}
58
+ chmodprog=${CHMODPROG-chmod}
59
+ chownprog=${CHOWNPROG-chown}
60
+ cmpprog=${CMPPROG-cmp}
61
+ cpprog=${CPPROG-cp}
62
+ mkdirprog=${MKDIRPROG-mkdir}
63
+ mvprog=${MVPROG-mv}
64
+ rmprog=${RMPROG-rm}
65
+ stripprog=${STRIPPROG-strip}
66
+
67
+ posix_mkdir=
68
+
69
+ # Desired mode of installed file.
70
+ mode=0755
71
+
72
+ # Create dirs (including intermediate dirs) using mode 755.
73
+ # This is like GNU 'install' as of coreutils 8.32 (2020).
74
+ mkdir_umask=22
75
+
76
+ backupsuffix=
77
+ chgrpcmd=
78
+ chmodcmd=$chmodprog
79
+ chowncmd=
80
+ mvcmd=$mvprog
81
+ rmcmd="$rmprog -f"
82
+ stripcmd=
83
+
84
+ src=
85
+ dst=
86
+ dir_arg=
87
+ dst_arg=
88
+
89
+ copy_on_change=false
90
+ is_target_a_directory=possibly
91
+
92
+ usage="\
93
+ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
94
+ or: $0 [OPTION]... SRCFILES... DIRECTORY
95
+ or: $0 [OPTION]... -t DIRECTORY SRCFILES...
96
+ or: $0 [OPTION]... -d DIRECTORIES...
97
+
98
+ In the 1st form, copy SRCFILE to DSTFILE.
99
+ In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
100
+ In the 4th, create DIRECTORIES.
101
+
102
+ Options:
103
+ --help display this help and exit.
104
+ --version display version info and exit.
105
+
106
+ -c (ignored)
107
+ -C install only if different (preserve data modification time)
108
+ -d create directories instead of installing files.
109
+ -g GROUP $chgrpprog installed files to GROUP.
110
+ -m MODE $chmodprog installed files to MODE.
111
+ -o USER $chownprog installed files to USER.
112
+ -p pass -p to $cpprog.
113
+ -s $stripprog installed files.
114
+ -S SUFFIX attempt to back up existing files, with suffix SUFFIX.
115
+ -t DIRECTORY install into DIRECTORY.
116
+ -T report an error if DSTFILE is a directory.
117
+
118
+ Environment variables override the default commands:
119
+ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
120
+ RMPROG STRIPPROG
121
+
122
+ By default, rm is invoked with -f; when overridden with RMPROG,
123
+ it's up to you to specify -f if you want it.
124
+
125
+ If -S is not specified, no backups are attempted.
126
+
127
+ Email bug reports to [email protected].
128
+ Automake home page: https://www.gnu.org/software/automake/
129
+ "
130
+
131
+ while test $# -ne 0; do
132
+ case $1 in
133
+ -c) ;;
134
+
135
+ -C) copy_on_change=true;;
136
+
137
+ -d) dir_arg=true;;
138
+
139
+ -g) chgrpcmd="$chgrpprog $2"
140
+ shift;;
141
+
142
+ --help) echo "$usage"; exit $?;;
143
+
144
+ -m) mode=$2
145
+ case $mode in
146
+ *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
147
+ echo "$0: invalid mode: $mode" >&2
148
+ exit 1;;
149
+ esac
150
+ shift;;
151
+
152
+ -o) chowncmd="$chownprog $2"
153
+ shift;;
154
+
155
+ -p) cpprog="$cpprog -p";;
156
+
157
+ -s) stripcmd=$stripprog;;
158
+
159
+ -S) backupsuffix="$2"
160
+ shift;;
161
+
162
+ -t)
163
+ is_target_a_directory=always
164
+ dst_arg=$2
165
+ # Protect names problematic for 'test' and other utilities.
166
+ case $dst_arg in
167
+ -* | [=\(\)!]) dst_arg=./$dst_arg;;
168
+ esac
169
+ shift;;
170
+
171
+ -T) is_target_a_directory=never;;
172
+
173
+ --version) echo "$0 $scriptversion"; exit $?;;
174
+
175
+ --) shift
176
+ break;;
177
+
178
+ -*) echo "$0: invalid option: $1" >&2
179
+ exit 1;;
180
+
181
+ *) break;;
182
+ esac
183
+ shift
184
+ done
185
+
186
+ # We allow the use of options -d and -T together, by making -d
187
+ # take the precedence; this is for compatibility with GNU install.
188
+
189
+ if test -n "$dir_arg"; then
190
+ if test -n "$dst_arg"; then
191
+ echo "$0: target directory not allowed when installing a directory." >&2
192
+ exit 1
193
+ fi
194
+ fi
195
+
196
+ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
197
+ # When -d is used, all remaining arguments are directories to create.
198
+ # When -t is used, the destination is already specified.
199
+ # Otherwise, the last argument is the destination. Remove it from $@.
200
+ for arg
201
+ do
202
+ if test -n "$dst_arg"; then
203
+ # $@ is not empty: it contains at least $arg.
204
+ set fnord "$@" "$dst_arg"
205
+ shift # fnord
206
+ fi
207
+ shift # arg
208
+ dst_arg=$arg
209
+ # Protect names problematic for 'test' and other utilities.
210
+ case $dst_arg in
211
+ -* | [=\(\)!]) dst_arg=./$dst_arg;;
212
+ esac
213
+ done
214
+ fi
215
+
216
+ if test $# -eq 0; then
217
+ if test -z "$dir_arg"; then
218
+ echo "$0: no input file specified." >&2
219
+ exit 1
220
+ fi
221
+ # It's OK to call 'install-sh -d' without argument.
222
+ # This can happen when creating conditional directories.
223
+ exit 0
224
+ fi
225
+
226
+ if test -z "$dir_arg"; then
227
+ if test $# -gt 1 || test "$is_target_a_directory" = always; then
228
+ if test ! -d "$dst_arg"; then
229
+ echo "$0: $dst_arg: Is not a directory." >&2
230
+ exit 1
231
+ fi
232
+ fi
233
+ fi
234
+
235
+ if test -z "$dir_arg"; then
236
+ do_exit='(exit $ret); exit $ret'
237
+ trap "ret=129; $do_exit" 1
238
+ trap "ret=130; $do_exit" 2
239
+ trap "ret=141; $do_exit" 13
240
+ trap "ret=143; $do_exit" 15
241
+
242
+ # Set umask so as not to create temps with too-generous modes.
243
+ # However, 'strip' requires both read and write access to temps.
244
+ case $mode in
245
+ # Optimize common cases.
246
+ *644) cp_umask=133;;
247
+ *755) cp_umask=22;;
248
+
249
+ *[0-7])
250
+ if test -z "$stripcmd"; then
251
+ u_plus_rw=
252
+ else
253
+ u_plus_rw='% 200'
254
+ fi
255
+ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
256
+ *)
257
+ if test -z "$stripcmd"; then
258
+ u_plus_rw=
259
+ else
260
+ u_plus_rw=,u+rw
261
+ fi
262
+ cp_umask=$mode$u_plus_rw;;
263
+ esac
264
+ fi
265
+
266
+ for src
267
+ do
268
+ # Protect names problematic for 'test' and other utilities.
269
+ case $src in
270
+ -* | [=\(\)!]) src=./$src;;
271
+ esac
272
+
273
+ if test -n "$dir_arg"; then
274
+ dst=$src
275
+ dstdir=$dst
276
+ test -d "$dstdir"
277
+ dstdir_status=$?
278
+ # Don't chown directories that already exist.
279
+ if test $dstdir_status = 0; then
280
+ chowncmd=""
281
+ fi
282
+ else
283
+
284
+ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
285
+ # might cause directories to be created, which would be especially bad
286
+ # if $src (and thus $dsttmp) contains '*'.
287
+ if test ! -f "$src" && test ! -d "$src"; then
288
+ echo "$0: $src does not exist." >&2
289
+ exit 1
290
+ fi
291
+
292
+ if test -z "$dst_arg"; then
293
+ echo "$0: no destination specified." >&2
294
+ exit 1
295
+ fi
296
+ dst=$dst_arg
297
+
298
+ # If destination is a directory, append the input filename.
299
+ if test -d "$dst"; then
300
+ if test "$is_target_a_directory" = never; then
301
+ echo "$0: $dst_arg: Is a directory" >&2
302
+ exit 1
303
+ fi
304
+ dstdir=$dst
305
+ dstbase=`basename "$src"`
306
+ case $dst in
307
+ */) dst=$dst$dstbase;;
308
+ *) dst=$dst/$dstbase;;
309
+ esac
310
+ dstdir_status=0
311
+ else
312
+ dstdir=`dirname "$dst"`
313
+ test -d "$dstdir"
314
+ dstdir_status=$?
315
+ fi
316
+ fi
317
+
318
+ case $dstdir in
319
+ */) dstdirslash=$dstdir;;
320
+ *) dstdirslash=$dstdir/;;
321
+ esac
322
+
323
+ obsolete_mkdir_used=false
324
+
325
+ if test $dstdir_status != 0; then
326
+ case $posix_mkdir in
327
+ '')
328
+ # With -d, create the new directory with the user-specified mode.
329
+ # Otherwise, rely on $mkdir_umask.
330
+ if test -n "$dir_arg"; then
331
+ mkdir_mode=-m$mode
332
+ else
333
+ mkdir_mode=
334
+ fi
335
+
336
+ posix_mkdir=false
337
+ # The $RANDOM variable is not portable (e.g., dash). Use it
338
+ # here however when possible just to lower collision chance.
339
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
340
+
341
+ trap '
342
+ ret=$?
343
+ rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
344
+ exit $ret
345
+ ' 0
346
+
347
+ # Because "mkdir -p" follows existing symlinks and we likely work
348
+ # directly in world-writeable /tmp, make sure that the '$tmpdir'
349
+ # directory is successfully created first before we actually test
350
+ # 'mkdir -p'.
351
+ if (umask $mkdir_umask &&
352
+ $mkdirprog $mkdir_mode "$tmpdir" &&
353
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
354
+ then
355
+ if test -z "$dir_arg" || {
356
+ # Check for POSIX incompatibilities with -m.
357
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
358
+ # other-writable bit of parent directory when it shouldn't.
359
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
360
+ test_tmpdir="$tmpdir/a"
361
+ ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
362
+ case $ls_ld_tmpdir in
363
+ d????-?r-*) different_mode=700;;
364
+ d????-?--*) different_mode=755;;
365
+ *) false;;
366
+ esac &&
367
+ $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
368
+ ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
369
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
370
+ }
371
+ }
372
+ then posix_mkdir=:
373
+ fi
374
+ rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
375
+ else
376
+ # Remove any dirs left behind by ancient mkdir implementations.
377
+ rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
378
+ fi
379
+ trap '' 0;;
380
+ esac
381
+
382
+ if
383
+ $posix_mkdir && (
384
+ umask $mkdir_umask &&
385
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
386
+ )
387
+ then :
388
+ else
389
+
390
+ # mkdir does not conform to POSIX,
391
+ # or it failed possibly due to a race condition. Create the
392
+ # directory the slow way, step by step, checking for races as we go.
393
+
394
+ case $dstdir in
395
+ /*) prefix='/';;
396
+ [-=\(\)!]*) prefix='./';;
397
+ *) prefix='';;
398
+ esac
399
+
400
+ oIFS=$IFS
401
+ IFS=/
402
+ set -f
403
+ set fnord $dstdir
404
+ shift
405
+ set +f
406
+ IFS=$oIFS
407
+
408
+ prefixes=
409
+
410
+ for d
411
+ do
412
+ test X"$d" = X && continue
413
+
414
+ prefix=$prefix$d
415
+ if test -d "$prefix"; then
416
+ prefixes=
417
+ else
418
+ if $posix_mkdir; then
419
+ (umask $mkdir_umask &&
420
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
421
+ # Don't fail if two instances are running concurrently.
422
+ test -d "$prefix" || exit 1
423
+ else
424
+ case $prefix in
425
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
426
+ *) qprefix=$prefix;;
427
+ esac
428
+ prefixes="$prefixes '$qprefix'"
429
+ fi
430
+ fi
431
+ prefix=$prefix/
432
+ done
433
+
434
+ if test -n "$prefixes"; then
435
+ # Don't fail if two instances are running concurrently.
436
+ (umask $mkdir_umask &&
437
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
438
+ test -d "$dstdir" || exit 1
439
+ obsolete_mkdir_used=true
440
+ fi
441
+ fi
442
+ fi
443
+
444
+ if test -n "$dir_arg"; then
445
+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
446
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
447
+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
448
+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
449
+ else
450
+
451
+ # Make a couple of temp file names in the proper directory.
452
+ dsttmp=${dstdirslash}_inst.$$_
453
+ rmtmp=${dstdirslash}_rm.$$_
454
+
455
+ # Trap to clean up those temp files at exit.
456
+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
457
+
458
+ # Copy the file name to the temp name.
459
+ (umask $cp_umask &&
460
+ { test -z "$stripcmd" || {
461
+ # Create $dsttmp read-write so that cp doesn't create it read-only,
462
+ # which would cause strip to fail.
463
+ if test -z "$doit"; then
464
+ : >"$dsttmp" # No need to fork-exec 'touch'.
465
+ else
466
+ $doit touch "$dsttmp"
467
+ fi
468
+ }
469
+ } &&
470
+ $doit_exec $cpprog "$src" "$dsttmp") &&
471
+
472
+ # and set any options; do chmod last to preserve setuid bits.
473
+ #
474
+ # If any of these fail, we abort the whole thing. If we want to
475
+ # ignore errors from any of these, just make sure not to ignore
476
+ # errors from the above "$doit $cpprog $src $dsttmp" command.
477
+ #
478
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
479
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
480
+ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
481
+ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
482
+
483
+ # If -C, don't bother to copy if it wouldn't change the file.
484
+ if $copy_on_change &&
485
+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
486
+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
487
+ set -f &&
488
+ set X $old && old=:$2:$4:$5:$6 &&
489
+ set X $new && new=:$2:$4:$5:$6 &&
490
+ set +f &&
491
+ test "$old" = "$new" &&
492
+ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
493
+ then
494
+ rm -f "$dsttmp"
495
+ else
496
+ # If $backupsuffix is set, and the file being installed
497
+ # already exists, attempt a backup. Don't worry if it fails,
498
+ # e.g., if mv doesn't support -f.
499
+ if test -n "$backupsuffix" && test -f "$dst"; then
500
+ $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
501
+ fi
502
+
503
+ # Rename the file to the real destination.
504
+ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
505
+
506
+ # The rename failed, perhaps because mv can't rename something else
507
+ # to itself, or perhaps because mv is so ancient that it does not
508
+ # support -f.
509
+ {
510
+ # Now remove or move aside any old file at destination location.
511
+ # We try this two ways since rm can't unlink itself on some
512
+ # systems and the destination file might be busy for other
513
+ # reasons. In this case, the final cleanup might fail but the new
514
+ # file should still install successfully.
515
+ {
516
+ test ! -f "$dst" ||
517
+ $doit $rmcmd "$dst" 2>/dev/null ||
518
+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
519
+ { $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
520
+ } ||
521
+ { echo "$0: cannot unlink or rename $dst" >&2
522
+ (exit 1); exit 1
523
+ }
524
+ } &&
525
+
526
+ # Now rename the file to the real destination.
527
+ $doit $mvcmd "$dsttmp" "$dst"
528
+ }
529
+ fi || exit 1
530
+
531
+ trap '' 0
532
+ fi
533
+ done
534
+
535
+ # Local variables:
536
+ # eval: (add-hook 'before-save-hook 'time-stamp)
537
+ # time-stamp-start: "scriptversion="
538
+ # time-stamp-format: "%:y-%02m-%02d.%02H"
539
+ # time-stamp-time-zone: "UTC0"
540
+ # time-stamp-end: "; # UTC"
541
+ # End:
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/tclconfig/tcl.m4 ADDED
The diff for this file is too large to render. See raw diff
 
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/win/makefile.vc ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #------------------------------------------------------------- -*- makefile -*-
2
+ #
3
+ # Sample makefile for building Tcl extensions.
4
+ #
5
+ # Basic build, test and install
6
+ # nmake /s /nologo /f makefile.vc INSTALLDIR=c:\path\to\tcl
7
+ # nmake /s /nologo /f makefile.vc INSTALLDIR=c:\path\to\tcl test
8
+ # nmake /s /nologo /f makefile.vc INSTALLDIR=c:\path\to\tcl install
9
+ #
10
+ # For other build options (debug, static etc.)
11
+ # See TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for
12
+ # detailed documentation.
13
+ #
14
+ # See the file "license.terms" for information on usage and redistribution
15
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
16
+ #
17
+ #------------------------------------------------------------------------------
18
+
19
+ # PROJECT is sqlite, not sqlite3 to match TEA AC_INIT definition.
20
+ # This makes the generated DLL name also consistent between the two
21
+ # except for the "t" suffix which is the convention for nmake builds.
22
+ PROJECT = sqlite
23
+ PRJ_PACKAGE_TCLNAME = sqlite3
24
+
25
+ !include "rules-ext.vc"
26
+
27
+ PRJ_OBJS = $(TMP_DIR)\tclsqlite3.obj
28
+
29
+ # Preprocessor macros specific to sqlite3.
30
+ PRJ_DEFINES = -I"$(ROOT)\.." -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
31
+ -DSQLITE_ENABLE_DBPAGE_VTAB=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 \
32
+ -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS4=1 \
33
+ -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 \
34
+ -DSQLITE_ENABLE_JSON1=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
35
+ -DSQLITE_3_SUFFIX_ONLY=1 -DSQLITE_ENABLE_RTREE=1 \
36
+ -DSQLITE_UNTESTABLE=1 -DSQLITE_OMIT_LOOKASIDE=1 \
37
+ -DSQLITE_SECURE_DELETE=1 -DSQLITE_SOUNDEX=1 -DSQLITE_ENABLE_GEOPOLY=1 \
38
+ -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1 \
39
+ -DSQLITE_ENABLE_MATH_FUNCTIONS=1 -DDSQLITE_USE_ALLOCA=1 \
40
+ -DSQLITE_ENABLE_STAT4=1 -DSQLITE_OMIT_DEPRECATED=1 \
41
+ -DSQLITE_WIN32_GETVERSIONEX=0 -DSQLITE_WIN32_NO_ANSI=1
42
+ PRJ_DEFINES = $(PRJ_DEFINES) -I$(TMP_DIR)
43
+
44
+ # Standard targets to build, install, test etc.
45
+ !include "$(_RULESDIR)\targets.vc"
46
+
47
+ # The built-in pkgindex does no suffice for our extension as
48
+ # the PROJECT name (sqlite) is not same as init function name (Sqlite3)
49
+ pkgindex:
50
+ @echo if {[package vsatisfies [package provide Tcl] 9.0-]} { > $(OUT_DIR)\pkgIndex.tcl
51
+ @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
52
+ [list load [file join $$dir $(PRJLIBNAME9)] [string totitle $(PRJ_PACKAGE_TCLNAME)]] >> $(OUT_DIR)\pkgIndex.tcl
53
+ @echo } else { >> $(OUT_DIR)\pkgIndex.tcl
54
+ @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
55
+ [list load [file join $$dir $(PRJLIBNAME8)] [string totitle $(PRJ_PACKAGE_TCLNAME)]] >> $(OUT_DIR)\pkgIndex.tcl
56
+ @echo } >> $(OUT_DIR)\pkgIndex.tcl
57
+
58
+ # Install the manpage though on Windows, doubt it does much good
59
+ install: default-install-docs-n
60
+
61
+ # Explicit dependency rules
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/win/nmakehlp.c ADDED
@@ -0,0 +1,815 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * ----------------------------------------------------------------------------
3
+ * nmakehlp.c --
4
+ *
5
+ * This is used to fix limitations within nmake and the environment.
6
+ *
7
+ * Copyright (c) 2002 by David Gravereaux.
8
+ * Copyright (c) 2006 by Pat Thoyts
9
+ *
10
+ * See the file "license.terms" for information on usage and redistribution of
11
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
+ * ----------------------------------------------------------------------------
13
+ */
14
+
15
+ #define _CRT_SECURE_NO_DEPRECATE
16
+ #include <windows.h>
17
+ #ifdef _MSC_VER
18
+ #pragma comment (lib, "user32.lib")
19
+ #pragma comment (lib, "kernel32.lib")
20
+ #endif
21
+ #include <stdio.h>
22
+ #include <math.h>
23
+
24
+ /*
25
+ * This library is required for x64 builds with _some_ versions of MSVC
26
+ */
27
+ #if defined(_M_IA64) || defined(_M_AMD64)
28
+ #if _MSC_VER >= 1400 && _MSC_VER < 1500
29
+ #pragma comment(lib, "bufferoverflowU")
30
+ #endif
31
+ #endif
32
+
33
+ /* ISO hack for dumb VC++ */
34
+ #ifdef _MSC_VER
35
+ #define snprintf _snprintf
36
+ #endif
37
+
38
+
39
+ /* protos */
40
+
41
+ static int CheckForCompilerFeature(const char *option);
42
+ static int CheckForLinkerFeature(char **options, int count);
43
+ static int IsIn(const char *string, const char *substring);
44
+ static int SubstituteFile(const char *substs, const char *filename);
45
+ static int QualifyPath(const char *path);
46
+ static int LocateDependency(const char *keyfile);
47
+ static const char *GetVersionFromFile(const char *filename, const char *match, int numdots);
48
+ static DWORD WINAPI ReadFromPipe(LPVOID args);
49
+
50
+ /* globals */
51
+
52
+ #define CHUNK 25
53
+ #define STATICBUFFERSIZE 1000
54
+ typedef struct {
55
+ HANDLE pipe;
56
+ char buffer[STATICBUFFERSIZE];
57
+ } pipeinfo;
58
+
59
+ pipeinfo Out = {INVALID_HANDLE_VALUE, ""};
60
+ pipeinfo Err = {INVALID_HANDLE_VALUE, ""};
61
+
62
+ /*
63
+ * exitcodes: 0 == no, 1 == yes, 2 == error
64
+ */
65
+
66
+ int
67
+ main(
68
+ int argc,
69
+ char *argv[])
70
+ {
71
+ char msg[300];
72
+ DWORD dwWritten;
73
+ int chars;
74
+ const char *s;
75
+
76
+ /*
77
+ * Make sure children (cl.exe and link.exe) are kept quiet.
78
+ */
79
+
80
+ SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
81
+
82
+ /*
83
+ * Make sure the compiler and linker aren't effected by the outside world.
84
+ */
85
+
86
+ SetEnvironmentVariable("CL", "");
87
+ SetEnvironmentVariable("LINK", "");
88
+
89
+ if (argc > 1 && *argv[1] == '-') {
90
+ switch (*(argv[1]+1)) {
91
+ case 'c':
92
+ if (argc != 3) {
93
+ chars = snprintf(msg, sizeof(msg) - 1,
94
+ "usage: %s -c <compiler option>\n"
95
+ "Tests for whether cl.exe supports an option\n"
96
+ "exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
97
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
98
+ &dwWritten, NULL);
99
+ return 2;
100
+ }
101
+ return CheckForCompilerFeature(argv[2]);
102
+ case 'l':
103
+ if (argc < 3) {
104
+ chars = snprintf(msg, sizeof(msg) - 1,
105
+ "usage: %s -l <linker option> ?<mandatory option> ...?\n"
106
+ "Tests for whether link.exe supports an option\n"
107
+ "exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
108
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
109
+ &dwWritten, NULL);
110
+ return 2;
111
+ }
112
+ return CheckForLinkerFeature(&argv[2], argc-2);
113
+ case 'f':
114
+ if (argc == 2) {
115
+ chars = snprintf(msg, sizeof(msg) - 1,
116
+ "usage: %s -f <string> <substring>\n"
117
+ "Find a substring within another\n"
118
+ "exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
119
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
120
+ &dwWritten, NULL);
121
+ return 2;
122
+ } else if (argc == 3) {
123
+ /*
124
+ * If the string is blank, there is no match.
125
+ */
126
+
127
+ return 0;
128
+ } else {
129
+ return IsIn(argv[2], argv[3]);
130
+ }
131
+ case 's':
132
+ if (argc == 2) {
133
+ chars = snprintf(msg, sizeof(msg) - 1,
134
+ "usage: %s -s <substitutions file> <file>\n"
135
+ "Perform a set of string map type substutitions on a file\n"
136
+ "exitcodes: 0\n",
137
+ argv[0]);
138
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
139
+ &dwWritten, NULL);
140
+ return 2;
141
+ }
142
+ return SubstituteFile(argv[2], argv[3]);
143
+ case 'V':
144
+ if (argc != 4) {
145
+ chars = snprintf(msg, sizeof(msg) - 1,
146
+ "usage: %s -V filename matchstring\n"
147
+ "Extract a version from a file:\n"
148
+ "eg: pkgIndex.tcl \"package ifneeded http\"",
149
+ argv[0]);
150
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
151
+ &dwWritten, NULL);
152
+ return 0;
153
+ }
154
+ s = GetVersionFromFile(argv[2], argv[3], *(argv[1]+2) - '0');
155
+ if (s && *s) {
156
+ printf("%s\n", s);
157
+ return 0;
158
+ } else
159
+ return 1; /* Version not found. Return non-0 exit code */
160
+
161
+ case 'Q':
162
+ if (argc != 3) {
163
+ chars = snprintf(msg, sizeof(msg) - 1,
164
+ "usage: %s -Q path\n"
165
+ "Emit the fully qualified path\n"
166
+ "exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
167
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
168
+ &dwWritten, NULL);
169
+ return 2;
170
+ }
171
+ return QualifyPath(argv[2]);
172
+
173
+ case 'L':
174
+ if (argc != 3) {
175
+ chars = snprintf(msg, sizeof(msg) - 1,
176
+ "usage: %s -L keypath\n"
177
+ "Emit the fully qualified path of directory containing keypath\n"
178
+ "exitcodes: 0 == success, 1 == not found, 2 == error\n", argv[0]);
179
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
180
+ &dwWritten, NULL);
181
+ return 2;
182
+ }
183
+ return LocateDependency(argv[2]);
184
+ }
185
+ }
186
+ chars = snprintf(msg, sizeof(msg) - 1,
187
+ "usage: %s -c|-f|-l|-Q|-s|-V ...\n"
188
+ "This is a little helper app to equalize shell differences between WinNT and\n"
189
+ "Win9x and get nmake.exe to accomplish its job.\n",
190
+ argv[0]);
191
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL);
192
+ return 2;
193
+ }
194
+
195
+ static int
196
+ CheckForCompilerFeature(
197
+ const char *option)
198
+ {
199
+ STARTUPINFO si;
200
+ PROCESS_INFORMATION pi;
201
+ SECURITY_ATTRIBUTES sa;
202
+ DWORD threadID;
203
+ char msg[300];
204
+ BOOL ok;
205
+ HANDLE hProcess, h, pipeThreads[2];
206
+ char cmdline[100];
207
+
208
+ hProcess = GetCurrentProcess();
209
+
210
+ ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
211
+ ZeroMemory(&si, sizeof(STARTUPINFO));
212
+ si.cb = sizeof(STARTUPINFO);
213
+ si.dwFlags = STARTF_USESTDHANDLES;
214
+ si.hStdInput = INVALID_HANDLE_VALUE;
215
+
216
+ ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
217
+ sa.nLength = sizeof(SECURITY_ATTRIBUTES);
218
+ sa.lpSecurityDescriptor = NULL;
219
+ sa.bInheritHandle = FALSE;
220
+
221
+ /*
222
+ * Create a non-inheritible pipe.
223
+ */
224
+
225
+ CreatePipe(&Out.pipe, &h, &sa, 0);
226
+
227
+ /*
228
+ * Dupe the write side, make it inheritible, and close the original.
229
+ */
230
+
231
+ DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput, 0, TRUE,
232
+ DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
233
+
234
+ /*
235
+ * Same as above, but for the error side.
236
+ */
237
+
238
+ CreatePipe(&Err.pipe, &h, &sa, 0);
239
+ DuplicateHandle(hProcess, h, hProcess, &si.hStdError, 0, TRUE,
240
+ DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
241
+
242
+ /*
243
+ * Base command line.
244
+ */
245
+
246
+ lstrcpy(cmdline, "cl.exe -nologo -c -TC -Zs -X -Fp.\\_junk.pch ");
247
+
248
+ /*
249
+ * Append our option for testing
250
+ */
251
+
252
+ lstrcat(cmdline, option);
253
+
254
+ /*
255
+ * Filename to compile, which exists, but is nothing and empty.
256
+ */
257
+
258
+ lstrcat(cmdline, " .\\nul");
259
+
260
+ ok = CreateProcess(
261
+ NULL, /* Module name. */
262
+ cmdline, /* Command line. */
263
+ NULL, /* Process handle not inheritable. */
264
+ NULL, /* Thread handle not inheritable. */
265
+ TRUE, /* yes, inherit handles. */
266
+ DETACHED_PROCESS, /* No console for you. */
267
+ NULL, /* Use parent's environment block. */
268
+ NULL, /* Use parent's starting directory. */
269
+ &si, /* Pointer to STARTUPINFO structure. */
270
+ &pi); /* Pointer to PROCESS_INFORMATION structure. */
271
+
272
+ if (!ok) {
273
+ DWORD err = GetLastError();
274
+ int chars = snprintf(msg, sizeof(msg) - 1,
275
+ "Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
276
+
277
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
278
+ FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPSTR)&msg[chars],
279
+ (300-chars), 0);
280
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, lstrlen(msg), &err,NULL);
281
+ return 2;
282
+ }
283
+
284
+ /*
285
+ * Close our references to the write handles that have now been inherited.
286
+ */
287
+
288
+ CloseHandle(si.hStdOutput);
289
+ CloseHandle(si.hStdError);
290
+
291
+ WaitForInputIdle(pi.hProcess, 5000);
292
+ CloseHandle(pi.hThread);
293
+
294
+ /*
295
+ * Start the pipe reader threads.
296
+ */
297
+
298
+ pipeThreads[0] = CreateThread(NULL, 0, ReadFromPipe, &Out, 0, &threadID);
299
+ pipeThreads[1] = CreateThread(NULL, 0, ReadFromPipe, &Err, 0, &threadID);
300
+
301
+ /*
302
+ * Block waiting for the process to end.
303
+ */
304
+
305
+ WaitForSingleObject(pi.hProcess, INFINITE);
306
+ CloseHandle(pi.hProcess);
307
+
308
+ /*
309
+ * Wait for our pipe to get done reading, should it be a little slow.
310
+ */
311
+
312
+ WaitForMultipleObjects(2, pipeThreads, TRUE, 500);
313
+ CloseHandle(pipeThreads[0]);
314
+ CloseHandle(pipeThreads[1]);
315
+
316
+ /*
317
+ * Look for the commandline warning code in both streams.
318
+ * - in MSVC 6 & 7 we get D4002, in MSVC 8 we get D9002.
319
+ */
320
+
321
+ return !(strstr(Out.buffer, "D4002") != NULL
322
+ || strstr(Err.buffer, "D4002") != NULL
323
+ || strstr(Out.buffer, "D9002") != NULL
324
+ || strstr(Err.buffer, "D9002") != NULL
325
+ || strstr(Out.buffer, "D2021") != NULL
326
+ || strstr(Err.buffer, "D2021") != NULL);
327
+ }
328
+
329
+ static int
330
+ CheckForLinkerFeature(
331
+ char **options,
332
+ int count)
333
+ {
334
+ STARTUPINFO si;
335
+ PROCESS_INFORMATION pi;
336
+ SECURITY_ATTRIBUTES sa;
337
+ DWORD threadID;
338
+ char msg[300];
339
+ BOOL ok;
340
+ HANDLE hProcess, h, pipeThreads[2];
341
+ int i;
342
+ char cmdline[255];
343
+
344
+ hProcess = GetCurrentProcess();
345
+
346
+ ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
347
+ ZeroMemory(&si, sizeof(STARTUPINFO));
348
+ si.cb = sizeof(STARTUPINFO);
349
+ si.dwFlags = STARTF_USESTDHANDLES;
350
+ si.hStdInput = INVALID_HANDLE_VALUE;
351
+
352
+ ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
353
+ sa.nLength = sizeof(SECURITY_ATTRIBUTES);
354
+ sa.lpSecurityDescriptor = NULL;
355
+ sa.bInheritHandle = TRUE;
356
+
357
+ /*
358
+ * Create a non-inheritible pipe.
359
+ */
360
+
361
+ CreatePipe(&Out.pipe, &h, &sa, 0);
362
+
363
+ /*
364
+ * Dupe the write side, make it inheritible, and close the original.
365
+ */
366
+
367
+ DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput, 0, TRUE,
368
+ DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
369
+
370
+ /*
371
+ * Same as above, but for the error side.
372
+ */
373
+
374
+ CreatePipe(&Err.pipe, &h, &sa, 0);
375
+ DuplicateHandle(hProcess, h, hProcess, &si.hStdError, 0, TRUE,
376
+ DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
377
+
378
+ /*
379
+ * Base command line.
380
+ */
381
+
382
+ lstrcpy(cmdline, "link.exe -nologo ");
383
+
384
+ /*
385
+ * Append our option for testing.
386
+ */
387
+
388
+ for (i = 0; i < count; i++) {
389
+ lstrcat(cmdline, " \"");
390
+ lstrcat(cmdline, options[i]);
391
+ lstrcat(cmdline, "\"");
392
+ }
393
+
394
+ ok = CreateProcess(
395
+ NULL, /* Module name. */
396
+ cmdline, /* Command line. */
397
+ NULL, /* Process handle not inheritable. */
398
+ NULL, /* Thread handle not inheritable. */
399
+ TRUE, /* yes, inherit handles. */
400
+ DETACHED_PROCESS, /* No console for you. */
401
+ NULL, /* Use parent's environment block. */
402
+ NULL, /* Use parent's starting directory. */
403
+ &si, /* Pointer to STARTUPINFO structure. */
404
+ &pi); /* Pointer to PROCESS_INFORMATION structure. */
405
+
406
+ if (!ok) {
407
+ DWORD err = GetLastError();
408
+ int chars = snprintf(msg, sizeof(msg) - 1,
409
+ "Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
410
+
411
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
412
+ FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPSTR)&msg[chars],
413
+ (300-chars), 0);
414
+ WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, lstrlen(msg), &err,NULL);
415
+ return 2;
416
+ }
417
+
418
+ /*
419
+ * Close our references to the write handles that have now been inherited.
420
+ */
421
+
422
+ CloseHandle(si.hStdOutput);
423
+ CloseHandle(si.hStdError);
424
+
425
+ WaitForInputIdle(pi.hProcess, 5000);
426
+ CloseHandle(pi.hThread);
427
+
428
+ /*
429
+ * Start the pipe reader threads.
430
+ */
431
+
432
+ pipeThreads[0] = CreateThread(NULL, 0, ReadFromPipe, &Out, 0, &threadID);
433
+ pipeThreads[1] = CreateThread(NULL, 0, ReadFromPipe, &Err, 0, &threadID);
434
+
435
+ /*
436
+ * Block waiting for the process to end.
437
+ */
438
+
439
+ WaitForSingleObject(pi.hProcess, INFINITE);
440
+ CloseHandle(pi.hProcess);
441
+
442
+ /*
443
+ * Wait for our pipe to get done reading, should it be a little slow.
444
+ */
445
+
446
+ WaitForMultipleObjects(2, pipeThreads, TRUE, 500);
447
+ CloseHandle(pipeThreads[0]);
448
+ CloseHandle(pipeThreads[1]);
449
+
450
+ /*
451
+ * Look for the commandline warning code in the stderr stream.
452
+ */
453
+
454
+ return !(strstr(Out.buffer, "LNK1117") != NULL ||
455
+ strstr(Err.buffer, "LNK1117") != NULL ||
456
+ strstr(Out.buffer, "LNK4044") != NULL ||
457
+ strstr(Err.buffer, "LNK4044") != NULL ||
458
+ strstr(Out.buffer, "LNK4224") != NULL ||
459
+ strstr(Err.buffer, "LNK4224") != NULL);
460
+ }
461
+
462
+ static DWORD WINAPI
463
+ ReadFromPipe(
464
+ LPVOID args)
465
+ {
466
+ pipeinfo *pi = (pipeinfo *) args;
467
+ char *lastBuf = pi->buffer;
468
+ DWORD dwRead;
469
+ BOOL ok;
470
+
471
+ again:
472
+ if (lastBuf - pi->buffer + CHUNK > STATICBUFFERSIZE) {
473
+ CloseHandle(pi->pipe);
474
+ return (DWORD)-1;
475
+ }
476
+ ok = ReadFile(pi->pipe, lastBuf, CHUNK, &dwRead, 0L);
477
+ if (!ok || dwRead == 0) {
478
+ CloseHandle(pi->pipe);
479
+ return 0;
480
+ }
481
+ lastBuf += dwRead;
482
+ goto again;
483
+
484
+ return 0; /* makes the compiler happy */
485
+ }
486
+
487
+ static int
488
+ IsIn(
489
+ const char *string,
490
+ const char *substring)
491
+ {
492
+ return (strstr(string, substring) != NULL);
493
+ }
494
+
495
+ /*
496
+ * GetVersionFromFile --
497
+ * Looks for a match string in a file and then returns the version
498
+ * following the match where a version is anything acceptable to
499
+ * package provide or package ifneeded.
500
+ */
501
+
502
+ static const char *
503
+ GetVersionFromFile(
504
+ const char *filename,
505
+ const char *match,
506
+ int numdots)
507
+ {
508
+ static char szBuffer[100];
509
+ char *szResult = NULL;
510
+ FILE *fp = fopen(filename, "rt");
511
+
512
+ if (fp != NULL) {
513
+ /*
514
+ * Read data until we see our match string.
515
+ */
516
+
517
+ while (fgets(szBuffer, sizeof(szBuffer), fp) != NULL) {
518
+ LPSTR p, q;
519
+
520
+ p = strstr(szBuffer, match);
521
+ if (p != NULL) {
522
+ /*
523
+ * Skip to first digit after the match.
524
+ */
525
+
526
+ p += strlen(match);
527
+ while (*p && !isdigit((unsigned char)*p)) {
528
+ ++p;
529
+ }
530
+
531
+ /*
532
+ * Find ending whitespace.
533
+ */
534
+
535
+ q = p;
536
+ while (*q && (strchr("0123456789.ab", *q)) && (((!strchr(".ab", *q)
537
+ && !strchr("ab", q[-1])) || --numdots))) {
538
+ ++q;
539
+ }
540
+
541
+ *q = 0;
542
+ szResult = p;
543
+ break;
544
+ }
545
+ }
546
+ fclose(fp);
547
+ }
548
+ return szResult;
549
+ }
550
+
551
+ /*
552
+ * List helpers for the SubstituteFile function
553
+ */
554
+
555
+ typedef struct list_item_t {
556
+ struct list_item_t *nextPtr;
557
+ char * key;
558
+ char * value;
559
+ } list_item_t;
560
+
561
+ /* insert a list item into the list (list may be null) */
562
+ static list_item_t *
563
+ list_insert(list_item_t **listPtrPtr, const char *key, const char *value)
564
+ {
565
+ list_item_t *itemPtr = (list_item_t *)malloc(sizeof(list_item_t));
566
+ if (itemPtr) {
567
+ itemPtr->key = strdup(key);
568
+ itemPtr->value = strdup(value);
569
+ itemPtr->nextPtr = NULL;
570
+
571
+ while(*listPtrPtr) {
572
+ listPtrPtr = &(*listPtrPtr)->nextPtr;
573
+ }
574
+ *listPtrPtr = itemPtr;
575
+ }
576
+ return itemPtr;
577
+ }
578
+
579
+ static void
580
+ list_free(list_item_t **listPtrPtr)
581
+ {
582
+ list_item_t *tmpPtr, *listPtr = *listPtrPtr;
583
+ while (listPtr) {
584
+ tmpPtr = listPtr;
585
+ listPtr = listPtr->nextPtr;
586
+ free(tmpPtr->key);
587
+ free(tmpPtr->value);
588
+ free(tmpPtr);
589
+ }
590
+ }
591
+
592
+ /*
593
+ * SubstituteFile --
594
+ * As windows doesn't provide anything useful like sed and it's unreliable
595
+ * to use the tclsh you are building against (consider x-platform builds -
596
+ * eg compiling AMD64 target from IX86) we provide a simple substitution
597
+ * option here to handle autoconf style substitutions.
598
+ * The substitution file is whitespace and line delimited. The file should
599
+ * consist of lines matching the regular expression:
600
+ * \s*\S+\s+\S*$
601
+ *
602
+ * Usage is something like:
603
+ * nmakehlp -S << $** > $@
604
+ * @PACKAGE_NAME@ $(PACKAGE_NAME)
605
+ * @PACKAGE_VERSION@ $(PACKAGE_VERSION)
606
+ * <<
607
+ */
608
+
609
+ static int
610
+ SubstituteFile(
611
+ const char *substitutions,
612
+ const char *filename)
613
+ {
614
+ static char szBuffer[1024], szCopy[1024];
615
+ list_item_t *substPtr = NULL;
616
+ FILE *fp, *sp;
617
+
618
+ fp = fopen(filename, "rt");
619
+ if (fp != NULL) {
620
+
621
+ /*
622
+ * Build a list of substutitions from the first filename
623
+ */
624
+
625
+ sp = fopen(substitutions, "rt");
626
+ if (sp != NULL) {
627
+ while (fgets(szBuffer, sizeof(szBuffer), sp) != NULL) {
628
+ unsigned char *ks, *ke, *vs, *ve;
629
+ ks = (unsigned char*)szBuffer;
630
+ while (ks && *ks && isspace(*ks)) ++ks;
631
+ ke = ks;
632
+ while (ke && *ke && !isspace(*ke)) ++ke;
633
+ vs = ke;
634
+ while (vs && *vs && isspace(*vs)) ++vs;
635
+ ve = vs;
636
+ while (ve && *ve && !(*ve == '\r' || *ve == '\n')) ++ve;
637
+ *ke = 0, *ve = 0;
638
+ list_insert(&substPtr, (char*)ks, (char*)vs);
639
+ }
640
+ fclose(sp);
641
+ }
642
+
643
+ /* debug: dump the list */
644
+ #ifndef NDEBUG
645
+ {
646
+ int n = 0;
647
+ list_item_t *p = NULL;
648
+ for (p = substPtr; p != NULL; p = p->nextPtr, ++n) {
649
+ fprintf(stderr, "% 3d '%s' => '%s'\n", n, p->key, p->value);
650
+ }
651
+ }
652
+ #endif
653
+
654
+ /*
655
+ * Run the substitutions over each line of the input
656
+ */
657
+
658
+ while (fgets(szBuffer, sizeof(szBuffer), fp) != NULL) {
659
+ list_item_t *p = NULL;
660
+ for (p = substPtr; p != NULL; p = p->nextPtr) {
661
+ char *m = strstr(szBuffer, p->key);
662
+ if (m) {
663
+ char *cp, *op, *sp;
664
+ cp = szCopy;
665
+ op = szBuffer;
666
+ while (op != m) *cp++ = *op++;
667
+ sp = p->value;
668
+ while (sp && *sp) *cp++ = *sp++;
669
+ op += strlen(p->key);
670
+ while (*op) *cp++ = *op++;
671
+ *cp = 0;
672
+ memcpy(szBuffer, szCopy, sizeof(szCopy));
673
+ }
674
+ }
675
+ printf("%s", szBuffer);
676
+ }
677
+
678
+ list_free(&substPtr);
679
+ }
680
+ fclose(fp);
681
+ return 0;
682
+ }
683
+
684
+ BOOL FileExists(LPCTSTR szPath)
685
+ {
686
+ #ifndef INVALID_FILE_ATTRIBUTES
687
+ #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
688
+ #endif
689
+ DWORD pathAttr = GetFileAttributes(szPath);
690
+ return (pathAttr != INVALID_FILE_ATTRIBUTES &&
691
+ !(pathAttr & FILE_ATTRIBUTE_DIRECTORY));
692
+ }
693
+
694
+
695
+ /*
696
+ * QualifyPath --
697
+ *
698
+ * This composes the current working directory with a provided path
699
+ * and returns the fully qualified and normalized path.
700
+ * Mostly needed to setup paths for testing.
701
+ */
702
+
703
+ static int
704
+ QualifyPath(
705
+ const char *szPath)
706
+ {
707
+ char szCwd[MAX_PATH + 1];
708
+
709
+ GetFullPathName(szPath, sizeof(szCwd)-1, szCwd, NULL);
710
+ printf("%s\n", szCwd);
711
+ return 0;
712
+ }
713
+
714
+ /*
715
+ * Implements LocateDependency for a single directory. See that command
716
+ * for an explanation.
717
+ * Returns 0 if found after printing the directory.
718
+ * Returns 1 if not found but no errors.
719
+ * Returns 2 on any kind of error
720
+ * Basically, these are used as exit codes for the process.
721
+ */
722
+ static int LocateDependencyHelper(const char *dir, const char *keypath)
723
+ {
724
+ HANDLE hSearch;
725
+ char path[MAX_PATH+1];
726
+ size_t dirlen;
727
+ int keylen, ret;
728
+ WIN32_FIND_DATA finfo;
729
+
730
+ if (dir == NULL || keypath == NULL)
731
+ return 2; /* Have no real error reporting mechanism into nmake */
732
+ dirlen = strlen(dir);
733
+ if ((dirlen + 3) > sizeof(path))
734
+ return 2;
735
+ strncpy(path, dir, dirlen);
736
+ strncpy(path+dirlen, "\\*", 3); /* Including terminating \0 */
737
+ keylen = strlen(keypath);
738
+
739
+ #if 0 /* This function is not available in Visual C++ 6 */
740
+ /*
741
+ * Use numerics 0 -> FindExInfoStandard,
742
+ * 1 -> FindExSearchLimitToDirectories,
743
+ * as these are not defined in Visual C++ 6
744
+ */
745
+ hSearch = FindFirstFileEx(path, 0, &finfo, 1, NULL, 0);
746
+ #else
747
+ hSearch = FindFirstFile(path, &finfo);
748
+ #endif
749
+ if (hSearch == INVALID_HANDLE_VALUE)
750
+ return 1; /* Not found */
751
+
752
+ /* Loop through all subdirs checking if the keypath is under there */
753
+ ret = 1; /* Assume not found */
754
+ do {
755
+ int sublen;
756
+ /*
757
+ * We need to check it is a directory despite the
758
+ * FindExSearchLimitToDirectories in the above call. See SDK docs
759
+ */
760
+ if ((finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
761
+ continue;
762
+ sublen = strlen(finfo.cFileName);
763
+ if ((dirlen+1+sublen+1+keylen+1) > sizeof(path))
764
+ continue; /* Path does not fit, assume not matched */
765
+ strncpy(path+dirlen+1, finfo.cFileName, sublen);
766
+ path[dirlen+1+sublen] = '\\';
767
+ strncpy(path+dirlen+1+sublen+1, keypath, keylen+1);
768
+ if (FileExists(path)) {
769
+ /* Found a match, print to stdout */
770
+ path[dirlen+1+sublen] = '\0';
771
+ QualifyPath(path);
772
+ ret = 0;
773
+ break;
774
+ }
775
+ } while (FindNextFile(hSearch, &finfo));
776
+ FindClose(hSearch);
777
+ return ret;
778
+ }
779
+
780
+ /*
781
+ * LocateDependency --
782
+ *
783
+ * Locates a dependency for a package.
784
+ * keypath - a relative path within the package directory
785
+ * that is used to confirm it is the correct directory.
786
+ * The search path for the package directory is currently only
787
+ * the parent and grandparent of the current working directory.
788
+ * If found, the command prints
789
+ * name_DIRPATH=<full path of located directory>
790
+ * and returns 0. If not found, does not print anything and returns 1.
791
+ */
792
+ static int LocateDependency(const char *keypath)
793
+ {
794
+ size_t i;
795
+ int ret;
796
+ static const char *paths[] = {"..", "..\\..", "..\\..\\.."};
797
+
798
+ for (i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i) {
799
+ ret = LocateDependencyHelper(paths[i], keypath);
800
+ if (ret == 0)
801
+ return ret;
802
+ }
803
+ return ret;
804
+ }
805
+
806
+
807
+ /*
808
+ * Local variables:
809
+ * mode: c
810
+ * c-basic-offset: 4
811
+ * fill-column: 78
812
+ * indent-tabs-mode: t
813
+ * tab-width: 8
814
+ * End:
815
+ */
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/win/rules-ext.vc ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file should only be included in makefiles for Tcl extensions,
2
+ # NOT in the makefile for Tcl itself.
3
+
4
+ !ifndef _RULES_EXT_VC
5
+
6
+ # We need to run from the directory the parent makefile is located in.
7
+ # nmake does not tell us what makefile was used to invoke it so parent
8
+ # makefile has to set the MAKEFILEVC macro or we just make a guess and
9
+ # warn if we think that is not the case.
10
+ !if "$(MAKEFILEVC)" == ""
11
+
12
+ !if exist("$(PROJECT).vc")
13
+ MAKEFILEVC = $(PROJECT).vc
14
+ !elseif exist("makefile.vc")
15
+ MAKEFILEVC = makefile.vc
16
+ !endif
17
+ !endif # "$(MAKEFILEVC)" == ""
18
+
19
+ !if !exist("$(MAKEFILEVC)")
20
+ MSG = ^
21
+ You must run nmake from the directory containing the project makefile.^
22
+ If you are doing that and getting this message, set the MAKEFILEVC^
23
+ macro to the name of the project makefile.
24
+ !message WARNING: $(MSG)
25
+ !endif
26
+
27
+ !if "$(PROJECT)" == "tcl"
28
+ !error The rules-ext.vc file is not intended for Tcl itself.
29
+ !endif
30
+
31
+ # We extract version numbers using the nmakehlp program. For now use
32
+ # the local copy of nmakehlp. Once we locate Tcl, we will use that
33
+ # one if it is newer.
34
+ !if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
35
+ !if [$(CC) -nologo -DNDEBUG "nmakehlp.c" -link -subsystem:console > nul]
36
+ !endif
37
+ !else
38
+ !if [copy x86_64-w64-mingw32-nmakehlp.exe nmakehlp.exe >NUL]
39
+ !endif
40
+ !endif
41
+
42
+ # First locate the Tcl directory that we are working with.
43
+ !if "$(TCLDIR)" != ""
44
+
45
+ _RULESDIR = $(TCLDIR:/=\)
46
+
47
+ !else
48
+
49
+ # If an installation path is specified, that is also the Tcl directory.
50
+ # Also Tk never builds against an installed Tcl, it needs Tcl sources
51
+ !if defined(INSTALLDIR) && "$(PROJECT)" != "tk"
52
+ _RULESDIR=$(INSTALLDIR:/=\)
53
+ !else
54
+ # Locate Tcl sources
55
+ !if [echo _RULESDIR = \> nmakehlp.out] \
56
+ || [nmakehlp -L generic\tcl.h >> nmakehlp.out]
57
+ _RULESDIR = ..\..\tcl
58
+ !else
59
+ !include nmakehlp.out
60
+ !endif
61
+
62
+ !endif # defined(INSTALLDIR)....
63
+
64
+ !endif # ifndef TCLDIR
65
+
66
+ # Now look for the targets.vc file under the Tcl root. Note we check this
67
+ # file and not rules.vc because the latter also exists on older systems.
68
+ !if exist("$(_RULESDIR)\lib\nmake\targets.vc") # Building against installed Tcl
69
+ _RULESDIR = $(_RULESDIR)\lib\nmake
70
+ !elseif exist("$(_RULESDIR)\win\targets.vc") # Building against Tcl sources
71
+ _RULESDIR = $(_RULESDIR)\win
72
+ !else
73
+ # If we have not located Tcl's targets file, most likely we are compiling
74
+ # against an older version of Tcl and so must use our own support files.
75
+ _RULESDIR = .
76
+ !endif
77
+
78
+ !if "$(_RULESDIR)" != "."
79
+ # Potentially using Tcl's support files. If this extension has its own
80
+ # nmake support files, need to compare the versions and pick newer.
81
+
82
+ !if exist("rules.vc") # The extension has its own copy
83
+
84
+ !if [echo TCL_RULES_MAJOR = \> versions.vc] \
85
+ && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MAJOR >> versions.vc]
86
+ !endif
87
+ !if [echo TCL_RULES_MINOR = \>> versions.vc] \
88
+ && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MINOR >> versions.vc]
89
+ !endif
90
+
91
+ !if [echo OUR_RULES_MAJOR = \>> versions.vc] \
92
+ && [nmakehlp -V "rules.vc" RULES_VERSION_MAJOR >> versions.vc]
93
+ !endif
94
+ !if [echo OUR_RULES_MINOR = \>> versions.vc] \
95
+ && [nmakehlp -V "rules.vc" RULES_VERSION_MINOR >> versions.vc]
96
+ !endif
97
+ !include versions.vc
98
+ # We have a newer version of the support files, use them
99
+ !if ($(TCL_RULES_MAJOR) != $(OUR_RULES_MAJOR)) || ($(TCL_RULES_MINOR) < $(OUR_RULES_MINOR))
100
+ _RULESDIR = .
101
+ !endif
102
+
103
+ !endif # if exist("rules.vc")
104
+
105
+ !endif # if $(_RULESDIR) != "."
106
+
107
+ # Let rules.vc know what copy of nmakehlp.c to use.
108
+ NMAKEHLPC = $(_RULESDIR)\nmakehlp.c
109
+
110
+ # Get rid of our internal defines before calling rules.vc
111
+ !undef TCL_RULES_MAJOR
112
+ !undef TCL_RULES_MINOR
113
+ !undef OUR_RULES_MAJOR
114
+ !undef OUR_RULES_MINOR
115
+
116
+ !if exist("$(_RULESDIR)\rules.vc")
117
+ !message *** Using $(_RULESDIR)\rules.vc
118
+ !include "$(_RULESDIR)\rules.vc"
119
+ !else
120
+ !error *** Could not locate rules.vc in $(_RULESDIR)
121
+ !endif
122
+
123
+ !endif # _RULES_EXT_VC
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/win/rules.vc ADDED
@@ -0,0 +1,1913 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #------------------------------------------------------------- -*- makefile -*-
2
+ # rules.vc --
3
+ #
4
+ # Part of the nmake based build system for Tcl and its extensions.
5
+ # This file does all the hard work in terms of parsing build options,
6
+ # compiler switches, defining common targets and macros. The Tcl makefile
7
+ # directly includes this. Extensions include it via "rules-ext.vc".
8
+ #
9
+ # See TIP 477 (https://core.tcl-lang.org/tips/doc/main/tip/477.md) for
10
+ # detailed documentation.
11
+ #
12
+ # See the file "license.terms" for information on usage and redistribution
13
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14
+ #
15
+ # Copyright (c) 2001-2003 David Gravereaux.
16
+ # Copyright (c) 2003-2008 Patrick Thoyts
17
+ # Copyright (c) 2017 Ashok P. Nadkarni
18
+ #------------------------------------------------------------------------------
19
+
20
+ !ifndef _RULES_VC
21
+ _RULES_VC = 1
22
+
23
+ # The following macros define the version of the rules.vc nmake build system
24
+ # For modifications that are not backward-compatible, you *must* change
25
+ # the major version.
26
+ RULES_VERSION_MAJOR = 1
27
+ RULES_VERSION_MINOR = 12
28
+
29
+ # The PROJECT macro must be defined by parent makefile.
30
+ !if "$(PROJECT)" == ""
31
+ !error *** Error: Macro PROJECT not defined! Please define it before including rules.vc
32
+ !endif
33
+
34
+ !if "$(PRJ_PACKAGE_TCLNAME)" == ""
35
+ PRJ_PACKAGE_TCLNAME = $(PROJECT)
36
+ !endif
37
+
38
+ # Also special case Tcl and Tk to save some typing later
39
+ DOING_TCL = 0
40
+ DOING_TK = 0
41
+ !if "$(PROJECT)" == "tcl"
42
+ DOING_TCL = 1
43
+ !elseif "$(PROJECT)" == "tk"
44
+ DOING_TK = 1
45
+ !endif
46
+
47
+ !ifndef NEED_TK
48
+ # Backwards compatibility
49
+ !ifdef PROJECT_REQUIRES_TK
50
+ NEED_TK = $(PROJECT_REQUIRES_TK)
51
+ !else
52
+ NEED_TK = 0
53
+ !endif
54
+ !endif
55
+
56
+ !ifndef NEED_TCL_SOURCE
57
+ NEED_TCL_SOURCE = 0
58
+ !endif
59
+
60
+ !ifdef NEED_TK_SOURCE
61
+ !if $(NEED_TK_SOURCE)
62
+ NEED_TK = 1
63
+ !endif
64
+ !else
65
+ NEED_TK_SOURCE = 0
66
+ !endif
67
+
68
+ ################################################################
69
+ # Nmake is a pretty weak environment in syntax and capabilities
70
+ # so this file is necessarily verbose. It's broken down into
71
+ # the following parts.
72
+ #
73
+ # 0. Sanity check that compiler environment is set up and initialize
74
+ # any built-in settings from the parent makefile
75
+ # 1. First define the external tools used for compiling, copying etc.
76
+ # as this is independent of everything else.
77
+ # 2. Figure out our build structure in terms of the directory, whether
78
+ # we are building Tcl or an extension, etc.
79
+ # 3. Determine the compiler and linker versions
80
+ # 4. Build the nmakehlp helper application
81
+ # 5. Determine the supported compiler options and features
82
+ # 6. Extract Tcl, Tk, and possibly extensions, version numbers from the
83
+ # headers
84
+ # 7. Parse the OPTS macro value for user-specified build configuration
85
+ # 8. Parse the STATS macro value for statistics instrumentation
86
+ # 9. Parse the CHECKS macro for additional compilation checks
87
+ # 10. Based on this selected configuration, construct the output
88
+ # directory and file paths
89
+ # 11. Construct the paths where the package is to be installed
90
+ # 12. Set up the actual options passed to compiler and linker based
91
+ # on the information gathered above.
92
+ # 13. Define some standard build targets and implicit rules. These may
93
+ # be optionally disabled by the parent makefile.
94
+ # 14. (For extensions only.) Compare the configuration of the target
95
+ # Tcl and the extensions and warn against discrepancies.
96
+ #
97
+ # One final note about the macro names used. They are as they are
98
+ # for historical reasons. We would like legacy extensions to
99
+ # continue to work with this make include file so be wary of
100
+ # changing them for consistency or clarity.
101
+
102
+ # 0. Sanity check compiler environment
103
+
104
+ # Check to see we are configured to build with MSVC (MSDEVDIR, MSVCDIR or
105
+ # VCINSTALLDIR) or with the MS Platform SDK (MSSDK or WindowsSDKDir)
106
+
107
+ !if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(VCINSTALLDIR) && !defined(MSSDK) && !defined(WINDOWSSDKDIR)
108
+ MSG = ^
109
+ Visual C++ compiler environment not initialized.
110
+ !error $(MSG)
111
+ !endif
112
+
113
+ # We need to run from the directory the parent makefile is located in.
114
+ # nmake does not tell us what makefile was used to invoke it so parent
115
+ # makefile has to set the MAKEFILEVC macro or we just make a guess and
116
+ # warn if we think that is not the case.
117
+ !if "$(MAKEFILEVC)" == ""
118
+
119
+ !if exist("$(PROJECT).vc")
120
+ MAKEFILEVC = $(PROJECT).vc
121
+ !elseif exist("makefile.vc")
122
+ MAKEFILEVC = makefile.vc
123
+ !endif
124
+ !endif # "$(MAKEFILEVC)" == ""
125
+
126
+ !if !exist("$(MAKEFILEVC)")
127
+ MSG = ^
128
+ You must run nmake from the directory containing the project makefile.^
129
+ If you are doing that and getting this message, set the MAKEFILEVC^
130
+ macro to the name of the project makefile.
131
+ !message WARNING: $(MSG)
132
+ !endif
133
+
134
+
135
+ ################################################################
136
+ # 1. Define external programs being used
137
+
138
+ #----------------------------------------------------------
139
+ # Set the proper copy method to avoid overwrite questions
140
+ # to the user when copying files and selecting the right
141
+ # "delete all" method.
142
+ #----------------------------------------------------------
143
+
144
+ RMDIR = rmdir /S /Q
145
+ CPY = xcopy /i /y >NUL
146
+ CPYDIR = xcopy /e /i /y >NUL
147
+ COPY = copy /y >NUL
148
+ MKDIR = mkdir
149
+
150
+ ######################################################################
151
+ # 2. Figure out our build environment in terms of what we're building.
152
+ #
153
+ # (a) Tcl itself
154
+ # (b) Tk
155
+ # (c) a Tcl extension using libraries/includes from an *installed* Tcl
156
+ # (d) a Tcl extension using libraries/includes from Tcl source directory
157
+ #
158
+ # This last is needed because some extensions still need
159
+ # some Tcl interfaces that are not publicly exposed.
160
+ #
161
+ # The fragment will set the following macros:
162
+ # ROOT - root of this module sources
163
+ # COMPATDIR - source directory that holds compatibility sources
164
+ # DOCDIR - source directory containing documentation files
165
+ # GENERICDIR - platform-independent source directory
166
+ # WIN_DIR - Windows-specific source directory
167
+ # TESTDIR - directory containing test files
168
+ # TOOLSDIR - directory containing build tools
169
+ # _TCLDIR - root of the Tcl installation OR the Tcl sources. Not set
170
+ # when building Tcl itself.
171
+ # _INSTALLDIR - native form of the installation path. For Tcl
172
+ # this will be the root of the Tcl installation. For extensions
173
+ # this will be the lib directory under the root.
174
+ # TCLINSTALL - set to 1 if _TCLDIR refers to
175
+ # headers and libraries from an installed Tcl, and 0 if built against
176
+ # Tcl sources. Not set when building Tcl itself. Yes, not very well
177
+ # named.
178
+ # _TCL_H - native path to the tcl.h file
179
+ #
180
+ # If Tk is involved, also sets the following
181
+ # _TKDIR - native form Tk installation OR Tk source. Not set if building
182
+ # Tk itself.
183
+ # TKINSTALL - set 1 if _TKDIR refers to installed Tk and 0 if Tk sources
184
+ # _TK_H - native path to the tk.h file
185
+
186
+ # Root directory for sources and assumed subdirectories
187
+ ROOT = $(MAKEDIR)\..
188
+ # The following paths CANNOT have spaces in them as they appear on the
189
+ # left side of implicit rules.
190
+ !ifndef COMPATDIR
191
+ COMPATDIR = $(ROOT)\compat
192
+ !endif
193
+ !ifndef DOCDIR
194
+ DOCDIR = $(ROOT)\doc
195
+ !endif
196
+ !ifndef GENERICDIR
197
+ GENERICDIR = $(ROOT)\generic
198
+ !endif
199
+ !ifndef TOOLSDIR
200
+ TOOLSDIR = $(ROOT)\tools
201
+ !endif
202
+ !ifndef TESTDIR
203
+ TESTDIR = $(ROOT)\tests
204
+ !endif
205
+ !ifndef LIBDIR
206
+ !if exist("$(ROOT)\library")
207
+ LIBDIR = $(ROOT)\library
208
+ !else
209
+ LIBDIR = $(ROOT)\lib
210
+ !endif
211
+ !endif
212
+ !ifndef DEMODIR
213
+ !if exist("$(LIBDIR)\demos")
214
+ DEMODIR = $(LIBDIR)\demos
215
+ !else
216
+ DEMODIR = $(ROOT)\demos
217
+ !endif
218
+ !endif # ifndef DEMODIR
219
+ # Do NOT use WINDIR because it is Windows internal environment
220
+ # variable to point to c:\windows!
221
+ WIN_DIR = $(ROOT)\win
222
+
223
+ !ifndef RCDIR
224
+ !if exist("$(WIN_DIR)\rc")
225
+ RCDIR = $(WIN_DIR)\rc
226
+ !else
227
+ RCDIR = $(WIN_DIR)
228
+ !endif
229
+ !endif
230
+ RCDIR = $(RCDIR:/=\)
231
+
232
+ # The target directory where the built packages and binaries will be installed.
233
+ # INSTALLDIR is the (optional) path specified by the user.
234
+ # _INSTALLDIR is INSTALLDIR using the backslash separator syntax
235
+ !ifdef INSTALLDIR
236
+ ### Fix the path separators.
237
+ _INSTALLDIR = $(INSTALLDIR:/=\)
238
+ !else
239
+ ### Assume the normal default.
240
+ _INSTALLDIR = $(HOMEDRIVE)\Tcl
241
+ !endif
242
+
243
+ !if $(DOING_TCL)
244
+
245
+ # BEGIN Case 2(a) - Building Tcl itself
246
+
247
+ # Only need to define _TCL_H
248
+ _TCL_H = ..\generic\tcl.h
249
+
250
+ # END Case 2(a) - Building Tcl itself
251
+
252
+ !elseif $(DOING_TK)
253
+
254
+ # BEGIN Case 2(b) - Building Tk
255
+
256
+ TCLINSTALL = 0 # Tk always builds against Tcl source, not an installed Tcl
257
+ !if "$(TCLDIR)" == ""
258
+ !if [echo TCLDIR = \> nmakehlp.out] \
259
+ || [nmakehlp -L generic\tcl.h >> nmakehlp.out]
260
+ !error *** Could not locate Tcl source directory.
261
+ !endif
262
+ !include nmakehlp.out
263
+ !endif # TCLDIR == ""
264
+
265
+ _TCLDIR = $(TCLDIR:/=\)
266
+ _TCL_H = $(_TCLDIR)\generic\tcl.h
267
+ !if !exist("$(_TCL_H)")
268
+ !error Could not locate tcl.h. Please set the TCLDIR macro to point to the Tcl *source* directory.
269
+ !endif
270
+
271
+ _TK_H = ..\generic\tk.h
272
+
273
+ # END Case 2(b) - Building Tk
274
+
275
+ !else
276
+
277
+ # BEGIN Case 2(c) or (d) - Building an extension other than Tk
278
+
279
+ # If command line has specified Tcl location through TCLDIR, use it
280
+ # else default to the INSTALLDIR setting
281
+ !if "$(TCLDIR)" != ""
282
+
283
+ _TCLDIR = $(TCLDIR:/=\)
284
+ !if exist("$(_TCLDIR)\include\tcl.h") # Case 2(c) with TCLDIR defined
285
+ TCLINSTALL = 1
286
+ _TCL_H = $(_TCLDIR)\include\tcl.h
287
+ !elseif exist("$(_TCLDIR)\generic\tcl.h") # Case 2(d) with TCLDIR defined
288
+ TCLINSTALL = 0
289
+ _TCL_H = $(_TCLDIR)\generic\tcl.h
290
+ !endif
291
+
292
+ !else # # Case 2(c) for extensions with TCLDIR undefined
293
+
294
+ # Need to locate Tcl depending on whether it needs Tcl source or not.
295
+ # If we don't, check the INSTALLDIR for an installed Tcl first
296
+
297
+ !if exist("$(_INSTALLDIR)\include\tcl.h") && !$(NEED_TCL_SOURCE)
298
+
299
+ TCLINSTALL = 1
300
+ TCLDIR = $(_INSTALLDIR)\..
301
+ # NOTE: we will be resetting _INSTALLDIR to _INSTALLDIR/lib for extensions
302
+ # later so the \.. accounts for the /lib
303
+ _TCLDIR = $(_INSTALLDIR)\..
304
+ _TCL_H = $(_TCLDIR)\include\tcl.h
305
+
306
+ !else # exist(...) && !$(NEED_TCL_SOURCE)
307
+
308
+ !if [echo _TCLDIR = \> nmakehlp.out] \
309
+ || [nmakehlp -L generic\tcl.h >> nmakehlp.out]
310
+ !error *** Could not locate Tcl source directory.
311
+ !endif
312
+ !include nmakehlp.out
313
+ TCLINSTALL = 0
314
+ TCLDIR = $(_TCLDIR)
315
+ _TCL_H = $(_TCLDIR)\generic\tcl.h
316
+
317
+ !endif # exist(...) && !$(NEED_TCL_SOURCE)
318
+
319
+ !endif # TCLDIR
320
+
321
+ !ifndef _TCL_H
322
+ MSG =^
323
+ Failed to find tcl.h. The TCLDIR macro is set incorrectly or is not set and default path does not contain tcl.h.
324
+ !error $(MSG)
325
+ !endif
326
+
327
+ # Now do the same to locate Tk headers and libs if project requires Tk
328
+ !if $(NEED_TK)
329
+
330
+ !if "$(TKDIR)" != ""
331
+
332
+ _TKDIR = $(TKDIR:/=\)
333
+ !if exist("$(_TKDIR)\include\tk.h")
334
+ TKINSTALL = 1
335
+ _TK_H = $(_TKDIR)\include\tk.h
336
+ !elseif exist("$(_TKDIR)\generic\tk.h")
337
+ TKINSTALL = 0
338
+ _TK_H = $(_TKDIR)\generic\tk.h
339
+ !endif
340
+
341
+ !else # TKDIR not defined
342
+
343
+ # Need to locate Tcl depending on whether it needs Tcl source or not.
344
+ # If we don't, check the INSTALLDIR for an installed Tcl first
345
+
346
+ !if exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE)
347
+
348
+ TKINSTALL = 1
349
+ # NOTE: we will be resetting _INSTALLDIR to _INSTALLDIR/lib for extensions
350
+ # later so the \.. accounts for the /lib
351
+ _TKDIR = $(_INSTALLDIR)\..
352
+ _TK_H = $(_TKDIR)\include\tk.h
353
+ TKDIR = $(_TKDIR)
354
+
355
+ !else # exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE)
356
+
357
+ !if [echo _TKDIR = \> nmakehlp.out] \
358
+ || [nmakehlp -L generic\tk.h >> nmakehlp.out]
359
+ !error *** Could not locate Tk source directory.
360
+ !endif
361
+ !include nmakehlp.out
362
+ TKINSTALL = 0
363
+ TKDIR = $(_TKDIR)
364
+ _TK_H = $(_TKDIR)\generic\tk.h
365
+
366
+ !endif # exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE)
367
+
368
+ !endif # TKDIR
369
+
370
+ !ifndef _TK_H
371
+ MSG =^
372
+ Failed to find tk.h. The TKDIR macro is set incorrectly or is not set and default path does not contain tk.h.
373
+ !error $(MSG)
374
+ !endif
375
+
376
+ !endif # NEED_TK
377
+
378
+ !if $(NEED_TCL_SOURCE) && $(TCLINSTALL)
379
+ MSG = ^
380
+ *** Warning: This extension requires the source distribution of Tcl.^
381
+ *** Please set the TCLDIR macro to point to the Tcl sources.
382
+ !error $(MSG)
383
+ !endif
384
+
385
+ !if $(NEED_TK_SOURCE)
386
+ !if $(TKINSTALL)
387
+ MSG = ^
388
+ *** Warning: This extension requires the source distribution of Tk.^
389
+ *** Please set the TKDIR macro to point to the Tk sources.
390
+ !error $(MSG)
391
+ !endif
392
+ !endif
393
+
394
+
395
+ # If INSTALLDIR set to Tcl installation root dir then reset to the
396
+ # lib dir for installing extensions
397
+ !if exist("$(_INSTALLDIR)\include\tcl.h")
398
+ _INSTALLDIR=$(_INSTALLDIR)\lib
399
+ !endif
400
+
401
+ # END Case 2(c) or (d) - Building an extension
402
+ !endif # if $(DOING_TCL)
403
+
404
+ ################################################################
405
+ # 3. Determine compiler version and architecture
406
+ # In this section, we figure out the compiler version and the
407
+ # architecture for which we are building. This sets the
408
+ # following macros:
409
+ # VCVERSION - the internal compiler version as 1200, 1400, 1910 etc.
410
+ # This is also printed by the compiler in dotted form 19.10 etc.
411
+ # VCVER - the "marketing version", for example Visual C++ 6 for internal
412
+ # compiler version 1200. This is kept only for legacy reasons as it
413
+ # does not make sense for recent Microsoft compilers. Only used for
414
+ # output directory names.
415
+ # ARCH - set to IX86, ARM64 or AMD64 depending on 32- or 64-bit target
416
+ # NATIVE_ARCH - set to IX86, ARM64 or AMD64 for the host machine
417
+ # MACHINE - same as $(ARCH) - legacy
418
+ # _VC_MANIFEST_EMBED_{DLL,EXE} - commands for embedding a manifest if needed
419
+
420
+ cc32 = $(CC) # built-in default.
421
+ link32 = link
422
+ lib32 = lib
423
+ rc32 = $(RC) # built-in default.
424
+
425
+ #----------------------------------------------------------------
426
+ # Figure out the compiler architecture and version by writing
427
+ # the C macros to a file, preprocessing them with the C
428
+ # preprocessor and reading back the created file
429
+
430
+ _HASH=^#
431
+ _VC_MANIFEST_EMBED_EXE=
432
+ _VC_MANIFEST_EMBED_DLL=
433
+ VCVER=0
434
+ !if ![echo VCVERSION=_MSC_VER > vercl.x] \
435
+ && ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \
436
+ && ![echo ARCH=IX86 >> vercl.x] \
437
+ && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \
438
+ && ![echo ARCH=AMD64 >> vercl.x] \
439
+ && ![echo $(_HASH)elif defined(_M_ARM64) >> vercl.x] \
440
+ && ![echo ARCH=ARM64 >> vercl.x] \
441
+ && ![echo $(_HASH)endif >> vercl.x] \
442
+ && ![$(cc32) -nologo -TC -P vercl.x 2>NUL]
443
+ !include vercl.i
444
+ !if $(VCVERSION) < 1900
445
+ !if ![echo VCVER= ^\> vercl.vc] \
446
+ && ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc]
447
+ !include vercl.vc
448
+ !endif
449
+ !else
450
+ # The simple calculation above does not apply to new Visual Studio releases
451
+ # Keep the compiler version in its native form.
452
+ VCVER = $(VCVERSION)
453
+ !endif
454
+ !endif
455
+
456
+ !if ![del 2>NUL /q/f vercl.x vercl.i vercl.vc]
457
+ !endif
458
+
459
+ #----------------------------------------------------------------
460
+ # The MACHINE macro is used by legacy makefiles so set it as well
461
+ !ifdef MACHINE
462
+ !if "$(MACHINE)" == "x86"
463
+ !undef MACHINE
464
+ MACHINE = IX86
465
+ !elseif "$(MACHINE)" == "arm64"
466
+ !undef MACHINE
467
+ MACHINE = ARM64
468
+ !elseif "$(MACHINE)" == "x64"
469
+ !undef MACHINE
470
+ MACHINE = AMD64
471
+ !endif
472
+ !if "$(MACHINE)" != "$(ARCH)"
473
+ !error Specified MACHINE macro $(MACHINE) does not match detected target architecture $(ARCH).
474
+ !endif
475
+ !else
476
+ MACHINE=$(ARCH)
477
+ !endif
478
+
479
+ #---------------------------------------------------------------
480
+ # The PLATFORM_IDENTIFY macro matches the values returned by
481
+ # the Tcl platform::identify command
482
+ !if "$(MACHINE)" == "AMD64"
483
+ PLATFORM_IDENTIFY = win32-x86_64
484
+ !elseif "$(MACHINE)" == "ARM64"
485
+ PLATFORM_IDENTIFY = win32-arm
486
+ !else
487
+ PLATFORM_IDENTIFY = win32-ix86
488
+ !endif
489
+
490
+ # The MULTIPLATFORM macro controls whether binary extensions are installed
491
+ # in platform-specific directories. Intended to be set/used by extensions.
492
+ !ifndef MULTIPLATFORM_INSTALL
493
+ MULTIPLATFORM_INSTALL = 0
494
+ !endif
495
+
496
+ #------------------------------------------------------------
497
+ # Figure out the *host* architecture by reading the registry
498
+
499
+ !if ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i x86]
500
+ NATIVE_ARCH=IX86
501
+ !elseif ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i ARM | findstr /i 64-bit]
502
+ NATIVE_ARCH=ARM64
503
+ !else
504
+ NATIVE_ARCH=AMD64
505
+ !endif
506
+
507
+ # Since MSVC8 we must deal with manifest resources.
508
+ !if $(VCVERSION) >= 1400
509
+ _VC_MANIFEST_EMBED_EXE=if exist [email protected] mt -nologo -manifest [email protected] -outputresource:$@;1
510
+ _VC_MANIFEST_EMBED_DLL=if exist [email protected] mt -nologo -manifest [email protected] -outputresource:$@;2
511
+ !endif
512
+
513
+ ################################################################
514
+ # 4. Build the nmakehlp program
515
+ # This is a helper app we need to overcome nmake's limiting
516
+ # environment. We will call out to it to get various bits of
517
+ # information about supported compiler options etc.
518
+ #
519
+ # Tcl itself will always use the nmakehlp.c program which is
520
+ # in its own source. It will be kept updated there.
521
+ #
522
+ # Extensions built against an installed Tcl will use the installed
523
+ # copy of Tcl's nmakehlp.c if there is one and their own version
524
+ # otherwise. In the latter case, they would also be using their own
525
+ # rules.vc. Note that older versions of Tcl do not install nmakehlp.c
526
+ # or rules.vc.
527
+ #
528
+ # Extensions built against Tcl sources will use the one from the Tcl source.
529
+ #
530
+ # When building an extension using a sufficiently new version of Tcl,
531
+ # rules-ext.vc will define NMAKEHLPC appropriately to point to the
532
+ # copy of nmakehlp.c to be used.
533
+
534
+ !ifndef NMAKEHLPC
535
+ # Default to the one in the current directory (the extension's own nmakehlp.c)
536
+ NMAKEHLPC = nmakehlp.c
537
+
538
+ !if !$(DOING_TCL)
539
+ !if $(TCLINSTALL)
540
+ !if exist("$(_TCLDIR)\lib\nmake\nmakehlp.c")
541
+ NMAKEHLPC = $(_TCLDIR)\lib\nmake\nmakehlp.c
542
+ !endif
543
+ !else # !$(TCLINSTALL)
544
+ !if exist("$(_TCLDIR)\win\nmakehlp.c")
545
+ NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c
546
+ !endif
547
+ !endif # $(TCLINSTALL)
548
+ !endif # !$(DOING_TCL)
549
+
550
+ !endif # NMAKEHLPC
551
+
552
+ # We always build nmakehlp even if it exists since we do not know
553
+ # what source it was built from.
554
+ !if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
555
+ !if [$(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console > nul]
556
+ !endif
557
+ !else
558
+ !if [copy $(NMAKEHLPC:nmakehlp.c=x86_64-w64-mingw32-nmakehlp.exe) nmakehlp.exe >NUL]
559
+ !endif
560
+ !endif
561
+
562
+ ################################################################
563
+ # 5. Test for compiler features
564
+ # Visual C++ compiler options have changed over the years. Check
565
+ # which options are supported by the compiler in use.
566
+ #
567
+ # The following macros are set:
568
+ # OPTIMIZATIONS - the compiler flags to be used for optimized builds
569
+ # DEBUGFLAGS - the compiler flags to be used for debug builds
570
+ # LINKERFLAGS - Flags passed to the linker
571
+ #
572
+ # Note that these are the compiler settings *available*, not those
573
+ # that will be *used*. The latter depends on the OPTS macro settings
574
+ # which we have not yet parsed.
575
+ #
576
+ # Also note that some of the flags in OPTIMIZATIONS are not really
577
+ # related to optimization. They are placed there only for legacy reasons
578
+ # as some extensions expect them to be included in that macro.
579
+
580
+ # -Op improves float consistency. Note only needed for older compilers
581
+ # Newer compilers do not need or support this option.
582
+ !if [nmakehlp -c -Op]
583
+ FPOPTS = -Op
584
+ !endif
585
+
586
+ # Strict floating point semantics - present in newer compilers in lieu of -Op
587
+ !if [nmakehlp -c -fp:strict]
588
+ FPOPTS = $(FPOPTS) -fp:strict
589
+ !endif
590
+
591
+ !if "$(MACHINE)" == "IX86"
592
+ ### test for pentium errata
593
+ !if [nmakehlp -c -QI0f]
594
+ !message *** Compiler has 'Pentium 0x0f fix'
595
+ FPOPTS = $(FPOPTS) -QI0f
596
+ !else
597
+ !message *** Compiler does not have 'Pentium 0x0f fix'
598
+ !endif
599
+ !endif
600
+
601
+ ### test for optimizations
602
+ # /O2 optimization includes /Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy as per
603
+ # documentation. Note we do NOT want /Gs as that inserts a _chkstk
604
+ # stack probe at *every* function entry, not just those with more than
605
+ # a page of stack allocation resulting in a performance hit. However,
606
+ # /O2 documentation is misleading as its stack probes are simply the
607
+ # default page size locals allocation probes and not what is implied
608
+ # by an explicit /Gs option.
609
+
610
+ OPTIMIZATIONS = $(FPOPTS)
611
+
612
+ !if [nmakehlp -c -O2]
613
+ OPTIMIZING = 1
614
+ OPTIMIZATIONS = $(OPTIMIZATIONS) -O2
615
+ !else
616
+ # Legacy, really. All modern compilers support this
617
+ !message *** Compiler does not have 'Optimizations'
618
+ OPTIMIZING = 0
619
+ !endif
620
+
621
+ # Checks for buffer overflows in local arrays
622
+ !if [nmakehlp -c -GS]
623
+ OPTIMIZATIONS = $(OPTIMIZATIONS) -GS
624
+ !endif
625
+
626
+ # Link time optimization. Note that this option (potentially) makes
627
+ # generated libraries only usable by the specific VC++ version that
628
+ # created it. Requires /LTCG linker option
629
+ !if [nmakehlp -c -GL]
630
+ OPTIMIZATIONS = $(OPTIMIZATIONS) -GL
631
+ CC_GL_OPT_ENABLED = 1
632
+ !else
633
+ # In newer compilers -GL and -YX are incompatible.
634
+ !if [nmakehlp -c -YX]
635
+ OPTIMIZATIONS = $(OPTIMIZATIONS) -YX
636
+ !endif
637
+ !endif # [nmakehlp -c -GL]
638
+
639
+ DEBUGFLAGS = $(FPOPTS)
640
+
641
+ # Run time error checks. Not available or valid in a release, non-debug build
642
+ # RTC is for modern compilers, -GZ is legacy
643
+ !if [nmakehlp -c -RTC1]
644
+ DEBUGFLAGS = $(DEBUGFLAGS) -RTC1
645
+ !elseif [nmakehlp -c -GZ]
646
+ DEBUGFLAGS = $(DEBUGFLAGS) -GZ
647
+ !endif
648
+
649
+ #----------------------------------------------------------------
650
+ # Linker flags
651
+
652
+ # LINKER_TESTFLAGS are for internal use when we call nmakehlp to test
653
+ # if the linker supports a specific option. Without these flags link will
654
+ # return "LNK1561: entry point must be defined" error compiling from VS-IDE:
655
+ # They are not passed through to the actual application / extension
656
+ # link rules.
657
+ !ifndef LINKER_TESTFLAGS
658
+ LINKER_TESTFLAGS = /DLL /NOENTRY /OUT:nmakehlp.out
659
+ !endif
660
+
661
+ LINKERFLAGS =
662
+
663
+ # If compiler has enabled link time optimization, linker must too with -ltcg
664
+ !ifdef CC_GL_OPT_ENABLED
665
+ !if [nmakehlp -l -ltcg $(LINKER_TESTFLAGS)]
666
+ LINKERFLAGS = $(LINKERFLAGS) -ltcg
667
+ !endif
668
+ !endif
669
+
670
+
671
+ ################################################################
672
+ # 6. Extract various version numbers from headers
673
+ # For Tcl and Tk, version numbers are extracted from tcl.h and tk.h
674
+ # respectively. For extensions, versions are extracted from the
675
+ # configure.in or configure.ac from the TEA configuration if it
676
+ # exists, and unset otherwise.
677
+ # Sets the following macros:
678
+ # TCL_MAJOR_VERSION
679
+ # TCL_MINOR_VERSION
680
+ # TCL_RELEASE_SERIAL
681
+ # TCL_PATCH_LEVEL
682
+ # TCL_PATCH_LETTER
683
+ # TCL_VERSION
684
+ # TK_MAJOR_VERSION
685
+ # TK_MINOR_VERSION
686
+ # TK_RELEASE_SERIAL
687
+ # TK_PATCH_LEVEL
688
+ # TK_PATCH_LETTER
689
+ # TK_VERSION
690
+ # DOTVERSION - set as (for example) 2.5
691
+ # VERSION - set as (for example 25)
692
+ #--------------------------------------------------------------
693
+
694
+ !if [echo REM = This file is generated from rules.vc > versions.vc]
695
+ !endif
696
+ !if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
697
+ && [nmakehlp -V "$(_TCL_H)" "define TCL_MAJOR_VERSION" >> versions.vc]
698
+ !endif
699
+ !if [echo TCL_MINOR_VERSION = \>> versions.vc] \
700
+ && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc]
701
+ !endif
702
+ !if [echo TCL_RELEASE_SERIAL = \>> versions.vc] \
703
+ && [nmakehlp -V "$(_TCL_H)" TCL_RELEASE_SERIAL >> versions.vc]
704
+ !endif
705
+ !if [echo TCL_PATCH_LEVEL = \>> versions.vc] \
706
+ && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc]
707
+ !endif
708
+
709
+ !if defined(_TK_H)
710
+ !if [echo TK_MAJOR_VERSION = \>> versions.vc] \
711
+ && [nmakehlp -V $(_TK_H) "define TK_MAJOR_VERSION" >> versions.vc]
712
+ !endif
713
+ !if [echo TK_MINOR_VERSION = \>> versions.vc] \
714
+ && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc]
715
+ !endif
716
+ !if [echo TK_RELEASE_SERIAL = \>> versions.vc] \
717
+ && [nmakehlp -V "$(_TK_H)" TK_RELEASE_SERIAL >> versions.vc]
718
+ !endif
719
+ !if [echo TK_PATCH_LEVEL = \>> versions.vc] \
720
+ && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
721
+ !endif
722
+ !endif # _TK_H
723
+
724
+ !include versions.vc
725
+
726
+ TCL_VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
727
+ TCL_DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
728
+ !if [nmakehlp -f $(TCL_PATCH_LEVEL) "a"]
729
+ TCL_PATCH_LETTER = a
730
+ !elseif [nmakehlp -f $(TCL_PATCH_LEVEL) "b"]
731
+ TCL_PATCH_LETTER = b
732
+ !else
733
+ TCL_PATCH_LETTER = .
734
+ !endif
735
+
736
+ !if defined(_TK_H)
737
+
738
+ TK_VERSION = $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
739
+ TK_DOTVERSION = $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
740
+ !if [nmakehlp -f $(TK_PATCH_LEVEL) "a"]
741
+ TK_PATCH_LETTER = a
742
+ !elseif [nmakehlp -f $(TK_PATCH_LEVEL) "b"]
743
+ TK_PATCH_LETTER = b
744
+ !else
745
+ TK_PATCH_LETTER = .
746
+ !endif
747
+
748
+ !endif
749
+
750
+ # Set DOTVERSION and VERSION
751
+ !if $(DOING_TCL)
752
+
753
+ DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
754
+ VERSION = $(TCL_VERSION)
755
+
756
+ !elseif $(DOING_TK)
757
+
758
+ DOTVERSION = $(TK_DOTVERSION)
759
+ VERSION = $(TK_VERSION)
760
+
761
+ !else # Doing a non-Tk extension
762
+
763
+ # If parent makefile has not defined DOTVERSION, try to get it from TEA
764
+ # first from a configure.in file, and then from configure.ac
765
+ !ifndef DOTVERSION
766
+ !if [echo DOTVERSION = \> versions.vc] \
767
+ || [nmakehlp -V $(ROOT)\configure.in ^[$(PROJECT)^] >> versions.vc]
768
+ !if [echo DOTVERSION = \> versions.vc] \
769
+ || [nmakehlp -V $(ROOT)\configure.ac ^[$(PROJECT)^] >> versions.vc]
770
+ !error *** Could not figure out extension version. Please define DOTVERSION in parent makefile before including rules.vc.
771
+ !endif
772
+ !endif
773
+ !include versions.vc
774
+ !endif # DOTVERSION
775
+ VERSION = $(DOTVERSION:.=)
776
+
777
+ !endif # $(DOING_TCL) ... etc.
778
+
779
+ # Windows RC files have 3 version components. Ensure this irrespective
780
+ # of how many components the package has specified. Basically, ensure
781
+ # minimum 4 components by appending 4 0's and then pick out the first 4.
782
+ # Also take care of the fact that DOTVERSION may have "a" or "b" instead
783
+ # of "." separating the version components.
784
+ DOTSEPARATED=$(DOTVERSION:a=.)
785
+ DOTSEPARATED=$(DOTSEPARATED:b=.)
786
+ !if [echo RCCOMMAVERSION = \> versions.vc] \
787
+ || [for /f "tokens=1,2,3,4,5* delims=." %a in ("$(DOTSEPARATED).0.0.0.0") do echo %a,%b,%c,%d >> versions.vc]
788
+ !error *** Could not generate RCCOMMAVERSION ***
789
+ !endif
790
+ !include versions.vc
791
+
792
+ ########################################################################
793
+ # 7. Parse the OPTS macro to work out the requested build configuration.
794
+ # Based on this, we will construct the actual switches to be passed to the
795
+ # compiler and linker using the macros defined in the previous section.
796
+ # The following macros are defined by this section based on OPTS
797
+ # STATIC_BUILD - 0 -> Tcl is to be built as a shared library
798
+ # 1 -> build as a static library and shell
799
+ # TCL_THREADS - legacy but always 1 on Windows since winsock requires it.
800
+ # DEBUG - 1 -> debug build, 0 -> release builds
801
+ # SYMBOLS - 1 -> generate PDB's, 0 -> no PDB's
802
+ # PROFILE - 1 -> generate profiling info, 0 -> no profiling
803
+ # PGO - 1 -> profile based optimization, 0 -> no
804
+ # MSVCRT - 1 -> link to dynamic C runtime even when building static Tcl build
805
+ # 0 -> link to static C runtime for static Tcl build.
806
+ # Does not impact shared Tcl builds (STATIC_BUILD == 0)
807
+ # Default: 1 for Tcl 8.7 and up, 0 otherwise.
808
+ # TCL_USE_STATIC_PACKAGES - 1 -> statically link the registry and dde extensions
809
+ # in the Tcl and Wish shell. 0 -> keep them as shared libraries. Does
810
+ # not impact shared Tcl builds. Implied by STATIC_BUILD since Tcl 8.7.
811
+ # USE_THREAD_ALLOC - 1 -> Use a shared global free pool for allocation.
812
+ # 0 -> Use the non-thread allocator.
813
+ # UNCHECKED - 1 -> when doing a debug build with symbols, use the release
814
+ # C runtime, 0 -> use the debug C runtime.
815
+ # USE_STUBS - 1 -> compile to use stubs interfaces, 0 -> direct linking
816
+ # CONFIG_CHECK - 1 -> check current build configuration against Tcl
817
+ # configuration (ignored for Tcl itself)
818
+ # _USE_64BIT_TIME_T - forces a build using 64-bit time_t for 32-bit build
819
+ # (CRT library should support this, not needed for Tcl 9.x)
820
+ # Further, LINKERFLAGS are modified based on above.
821
+
822
+ # Default values for all the above
823
+ STATIC_BUILD = 0
824
+ TCL_THREADS = 1
825
+ DEBUG = 0
826
+ SYMBOLS = 0
827
+ PROFILE = 0
828
+ PGO = 0
829
+ MSVCRT = 1
830
+ TCL_USE_STATIC_PACKAGES = 0
831
+ USE_THREAD_ALLOC = 1
832
+ UNCHECKED = 0
833
+ CONFIG_CHECK = 1
834
+ !if $(DOING_TCL)
835
+ USE_STUBS = 0
836
+ !else
837
+ USE_STUBS = 1
838
+ !endif
839
+
840
+ # If OPTS is not empty AND does not contain "none" which turns off all OPTS
841
+ # set the above macros based on OPTS content
842
+ !if "$(OPTS)" != "" && ![nmakehlp -f "$(OPTS)" "none"]
843
+
844
+ # OPTS are specified, parse them
845
+
846
+ !if [nmakehlp -f $(OPTS) "static"]
847
+ !message *** Doing static
848
+ STATIC_BUILD = 1
849
+ !endif
850
+
851
+ !if [nmakehlp -f $(OPTS) "nostubs"]
852
+ !message *** Not using stubs
853
+ USE_STUBS = 0
854
+ !endif
855
+
856
+ !if [nmakehlp -f $(OPTS) "nomsvcrt"]
857
+ !message *** Doing nomsvcrt
858
+ MSVCRT = 0
859
+ !else
860
+ !if [nmakehlp -f $(OPTS) "msvcrt"]
861
+ !message *** Doing msvcrt
862
+ !else
863
+ !if $(TCL_MAJOR_VERSION) == 8 && $(TCL_MINOR_VERSION) < 7 && $(STATIC_BUILD)
864
+ MSVCRT = 0
865
+ !endif
866
+ !endif
867
+ !endif # [nmakehlp -f $(OPTS) "nomsvcrt"]
868
+
869
+ !if [nmakehlp -f $(OPTS) "staticpkg"] && $(STATIC_BUILD)
870
+ !message *** Doing staticpkg
871
+ TCL_USE_STATIC_PACKAGES = 1
872
+ !endif
873
+
874
+ !if [nmakehlp -f $(OPTS) "nothreads"]
875
+ !message *** Compile explicitly for non-threaded tcl
876
+ TCL_THREADS = 0
877
+ USE_THREAD_ALLOC= 0
878
+ !endif
879
+
880
+ !if [nmakehlp -f $(OPTS) "tcl8"]
881
+ !message *** Build for Tcl8
882
+ TCL_BUILD_FOR = 8
883
+ !endif
884
+
885
+ !if $(TCL_MAJOR_VERSION) == 8
886
+ !if [nmakehlp -f $(OPTS) "time64bit"]
887
+ !message *** Force 64-bit time_t
888
+ _USE_64BIT_TIME_T = 1
889
+ !endif
890
+ !endif
891
+
892
+ # Yes, it's weird that the "symbols" option controls DEBUG and
893
+ # the "pdbs" option controls SYMBOLS. That's historical.
894
+ !if [nmakehlp -f $(OPTS) "symbols"]
895
+ !message *** Doing symbols
896
+ DEBUG = 1
897
+ !else
898
+ DEBUG = 0
899
+ !endif
900
+
901
+ !if [nmakehlp -f $(OPTS) "pdbs"]
902
+ !message *** Doing pdbs
903
+ SYMBOLS = 1
904
+ !else
905
+ SYMBOLS = 0
906
+ !endif
907
+
908
+ !if [nmakehlp -f $(OPTS) "profile"]
909
+ !message *** Doing profile
910
+ PROFILE = 1
911
+ !else
912
+ PROFILE = 0
913
+ !endif
914
+
915
+ !if [nmakehlp -f $(OPTS) "pgi"]
916
+ !message *** Doing profile guided optimization instrumentation
917
+ PGO = 1
918
+ !elseif [nmakehlp -f $(OPTS) "pgo"]
919
+ !message *** Doing profile guided optimization
920
+ PGO = 2
921
+ !else
922
+ PGO = 0
923
+ !endif
924
+
925
+ !if [nmakehlp -f $(OPTS) "loimpact"]
926
+ !message *** Warning: ignoring option "loimpact" - deprecated on modern Windows.
927
+ !endif
928
+
929
+ # TBD - should get rid of this option
930
+ !if [nmakehlp -f $(OPTS) "thrdalloc"]
931
+ !message *** Doing thrdalloc
932
+ USE_THREAD_ALLOC = 1
933
+ !endif
934
+
935
+ !if [nmakehlp -f $(OPTS) "tclalloc"]
936
+ USE_THREAD_ALLOC = 0
937
+ !endif
938
+
939
+ !if [nmakehlp -f $(OPTS) "unchecked"]
940
+ !message *** Doing unchecked
941
+ UNCHECKED = 1
942
+ !else
943
+ UNCHECKED = 0
944
+ !endif
945
+
946
+ !if [nmakehlp -f $(OPTS) "noconfigcheck"]
947
+ CONFIG_CHECK = 1
948
+ !else
949
+ CONFIG_CHECK = 0
950
+ !endif
951
+
952
+ !endif # "$(OPTS)" != "" && ... parsing of OPTS
953
+
954
+ # Set linker flags based on above
955
+
956
+ !if $(PGO) > 1
957
+ !if [nmakehlp -l -ltcg:pgoptimize $(LINKER_TESTFLAGS)]
958
+ LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pgoptimize
959
+ !else
960
+ MSG=^
961
+ This compiler does not support profile guided optimization.
962
+ !error $(MSG)
963
+ !endif
964
+ !elseif $(PGO) > 0
965
+ !if [nmakehlp -l -ltcg:pginstrument $(LINKER_TESTFLAGS)]
966
+ LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pginstrument
967
+ !else
968
+ MSG=^
969
+ This compiler does not support profile guided optimization.
970
+ !error $(MSG)
971
+ !endif
972
+ !endif
973
+
974
+ ################################################################
975
+ # 8. Parse the STATS macro to configure code instrumentation
976
+ # The following macros are set by this section:
977
+ # TCL_MEM_DEBUG - 1 -> enables memory allocation instrumentation
978
+ # 0 -> disables
979
+ # TCL_COMPILE_DEBUG - 1 -> enables byte compiler logging
980
+ # 0 -> disables
981
+
982
+ # Default both are off
983
+ TCL_MEM_DEBUG = 0
984
+ TCL_COMPILE_DEBUG = 0
985
+
986
+ !if "$(STATS)" != "" && ![nmakehlp -f "$(STATS)" "none"]
987
+
988
+ !if [nmakehlp -f $(STATS) "memdbg"]
989
+ !message *** Doing memdbg
990
+ TCL_MEM_DEBUG = 1
991
+ !else
992
+ TCL_MEM_DEBUG = 0
993
+ !endif
994
+
995
+ !if [nmakehlp -f $(STATS) "compdbg"]
996
+ !message *** Doing compdbg
997
+ TCL_COMPILE_DEBUG = 1
998
+ !else
999
+ TCL_COMPILE_DEBUG = 0
1000
+ !endif
1001
+
1002
+ !endif
1003
+
1004
+ ####################################################################
1005
+ # 9. Parse the CHECKS macro to configure additional compiler checks
1006
+ # The following macros are set by this section:
1007
+ # WARNINGS - compiler switches that control the warnings level
1008
+ # TCL_NO_DEPRECATED - 1 -> disable support for deprecated functions
1009
+ # 0 -> enable deprecated functions
1010
+
1011
+ # Defaults - Permit deprecated functions and warning level 3
1012
+ TCL_NO_DEPRECATED = 0
1013
+ WARNINGS = -W3
1014
+
1015
+ !if "$(CHECKS)" != "" && ![nmakehlp -f "$(CHECKS)" "none"]
1016
+
1017
+ !if [nmakehlp -f $(CHECKS) "nodep"]
1018
+ !message *** Doing nodep check
1019
+ TCL_NO_DEPRECATED = 1
1020
+ !endif
1021
+
1022
+ !if [nmakehlp -f $(CHECKS) "fullwarn"]
1023
+ !message *** Doing full warnings check
1024
+ WARNINGS = -W4
1025
+ !if [nmakehlp -l -warn:3 $(LINKER_TESTFLAGS)]
1026
+ LINKERFLAGS = $(LINKERFLAGS) -warn:3
1027
+ !endif
1028
+ !endif
1029
+
1030
+ !if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64]
1031
+ !message *** Doing 64bit portability warnings
1032
+ WARNINGS = $(WARNINGS) -Wp64
1033
+ !endif
1034
+
1035
+ !endif
1036
+
1037
+
1038
+ ################################################################
1039
+ # 10. Construct output directory and file paths
1040
+ # Figure-out how to name our intermediate and output directories.
1041
+ # In order to avoid inadvertent mixing of object files built using
1042
+ # different compilers, build configurations etc.,
1043
+ #
1044
+ # Naming convention (suffixes):
1045
+ # t = full thread support. (Not used for Tcl >= 8.7)
1046
+ # s = static library (as opposed to an import library)
1047
+ # g = linked to the debug enabled C run-time.
1048
+ # x = special static build when it links to the dynamic C run-time.
1049
+ #
1050
+ # The following macros are set in this section:
1051
+ # SUFX - the suffix to use for binaries based on above naming convention
1052
+ # BUILDDIRTOP - the toplevel default output directory
1053
+ # is of the form {Release,Debug}[_AMD64][_COMPILERVERSION]
1054
+ # TMP_DIR - directory where object files are created
1055
+ # OUT_DIR - directory where output executables are created
1056
+ # Both TMP_DIR and OUT_DIR are defaulted only if not defined by the
1057
+ # parent makefile (or command line). The default values are
1058
+ # based on BUILDDIRTOP.
1059
+ # STUBPREFIX - name of the stubs library for this project
1060
+ # PRJIMPLIB - output path of the generated project import library
1061
+ # PRJLIBNAME - name of generated project library
1062
+ # PRJLIB - output path of generated project library
1063
+ # PRJSTUBLIBNAME - name of the generated project stubs library
1064
+ # PRJSTUBLIB - output path of the generated project stubs library
1065
+ # RESFILE - output resource file (only if not static build)
1066
+
1067
+ SUFX = tsgx
1068
+
1069
+ !if $(DEBUG)
1070
+ BUILDDIRTOP = Debug
1071
+ !else
1072
+ BUILDDIRTOP = Release
1073
+ !endif
1074
+
1075
+ !if "$(MACHINE)" != "IX86"
1076
+ BUILDDIRTOP =$(BUILDDIRTOP)_$(MACHINE)
1077
+ !endif
1078
+ !if $(VCVER) > 6
1079
+ BUILDDIRTOP =$(BUILDDIRTOP)_VC$(VCVER)
1080
+ !endif
1081
+
1082
+ !if !$(DEBUG) || $(TCL_VERSION) > 86 || $(DEBUG) && $(UNCHECKED)
1083
+ SUFX = $(SUFX:g=)
1084
+ !endif
1085
+
1086
+ TMP_DIRFULL = .\$(BUILDDIRTOP)\$(PROJECT)_ThreadedDynamicStaticX
1087
+
1088
+ !if !$(STATIC_BUILD)
1089
+ TMP_DIRFULL = $(TMP_DIRFULL:Static=)
1090
+ SUFX = $(SUFX:s=)
1091
+ EXT = dll
1092
+ TMP_DIRFULL = $(TMP_DIRFULL:X=)
1093
+ SUFX = $(SUFX:x=)
1094
+ !else
1095
+ TMP_DIRFULL = $(TMP_DIRFULL:Dynamic=)
1096
+ EXT = lib
1097
+ !if $(MSVCRT) && $(TCL_VERSION) > 86 || !$(MSVCRT) && $(TCL_VERSION) < 87
1098
+ TMP_DIRFULL = $(TMP_DIRFULL:X=)
1099
+ SUFX = $(SUFX:x=)
1100
+ !endif
1101
+ !endif
1102
+
1103
+ !if !$(TCL_THREADS) || $(TCL_VERSION) > 86
1104
+ TMP_DIRFULL = $(TMP_DIRFULL:Threaded=)
1105
+ SUFX = $(SUFX:t=)
1106
+ !endif
1107
+
1108
+ !ifndef TMP_DIR
1109
+ TMP_DIR = $(TMP_DIRFULL)
1110
+ !ifndef OUT_DIR
1111
+ OUT_DIR = .\$(BUILDDIRTOP)
1112
+ !endif
1113
+ !else
1114
+ !ifndef OUT_DIR
1115
+ OUT_DIR = $(TMP_DIR)
1116
+ !endif
1117
+ !endif
1118
+
1119
+ # Relative paths -> absolute
1120
+ !if [echo OUT_DIR = \> nmakehlp.out] \
1121
+ || [nmakehlp -Q "$(OUT_DIR)" >> nmakehlp.out]
1122
+ !error *** Could not fully qualify path OUT_DIR=$(OUT_DIR)
1123
+ !endif
1124
+ !if [echo TMP_DIR = \>> nmakehlp.out] \
1125
+ || [nmakehlp -Q "$(TMP_DIR)" >> nmakehlp.out]
1126
+ !error *** Could not fully qualify path TMP_DIR=$(TMP_DIR)
1127
+ !endif
1128
+ !include nmakehlp.out
1129
+
1130
+ # The name of the stubs library for the project being built
1131
+ STUBPREFIX = $(PROJECT)stub
1132
+
1133
+ #
1134
+ # Set up paths to various Tcl executables and libraries needed by extensions
1135
+ #
1136
+
1137
+ # TIP 430. Unused for 8.6 but no harm defining it to allow a common rules.vc
1138
+ TCL_ZIP_FILE = libtcl$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)$(TCL_PATCH_LETTER)$(TCL_RELEASE_SERIAL).zip
1139
+ TK_ZIP_FILE = libtk$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)$(TK_PATCH_LETTER)$(TK_RELEASE_SERIAL).zip
1140
+
1141
+ !if $(DOING_TCL)
1142
+ TCLSHNAME = $(PROJECT)sh$(VERSION)$(SUFX).exe
1143
+ TCLSH = $(OUT_DIR)\$(TCLSHNAME)
1144
+ TCLIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
1145
+ TCLLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
1146
+ TCLLIB = $(OUT_DIR)\$(TCLLIBNAME)
1147
+ TCLSCRIPTZIP = $(OUT_DIR)\$(TCL_ZIP_FILE)
1148
+
1149
+ !if $(TCL_MAJOR_VERSION) == 8
1150
+ TCLSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
1151
+ !else
1152
+ TCLSTUBLIBNAME = $(STUBPREFIX).lib
1153
+ !endif
1154
+ TCLSTUBLIB = $(OUT_DIR)\$(TCLSTUBLIBNAME)
1155
+ TCL_INCLUDES = -I"$(WIN_DIR)" -I"$(GENERICDIR)"
1156
+
1157
+ !else # !$(DOING_TCL)
1158
+
1159
+ !if $(TCLINSTALL) # Building against an installed Tcl
1160
+
1161
+ # When building extensions, we need to locate tclsh. Depending on version
1162
+ # of Tcl we are building against, this may or may not have a "t" suffix.
1163
+ # Try various possibilities in turn.
1164
+ TCLSH = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX:t=).exe
1165
+ !if !exist("$(TCLSH)")
1166
+ TCLSH = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX:t=).exe
1167
+ !endif
1168
+
1169
+ !if $(TCL_MAJOR_VERSION) == 8
1170
+ TCLSTUBLIB = $(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib
1171
+ !else
1172
+ TCLSTUBLIB = $(_TCLDIR)\lib\tclstub.lib
1173
+ !endif
1174
+ TCLIMPLIB = $(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX:t=).lib
1175
+ # When building extensions, may be linking against Tcl that does not add
1176
+ # "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
1177
+ !if !exist("$(TCLIMPLIB)")
1178
+ TCLIMPLIB = $(_TCLDIR)\lib\tcl$(TCL_VERSION)t$(SUFX:t=).lib
1179
+ !endif
1180
+ TCL_LIBRARY = $(_TCLDIR)\lib
1181
+ TCLREGLIB = $(_TCLDIR)\lib\tclreg13$(SUFX:t=).lib
1182
+ TCLDDELIB = $(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib
1183
+ TCLSCRIPTZIP = $(_TCLDIR)\lib\$(TCL_ZIP_FILE)
1184
+ TCLTOOLSDIR = \must\have\tcl\sources\to\build\this\target
1185
+ TCL_INCLUDES = -I"$(_TCLDIR)\include"
1186
+
1187
+ !else # Building against Tcl sources
1188
+
1189
+ TCLSH = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX:t=).exe
1190
+ !if !exist($(TCLSH))
1191
+ TCLSH = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)t$(SUFX:t=).exe
1192
+ !endif
1193
+ !if $(TCL_MAJOR_VERSION) == 8
1194
+ TCLSTUBLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib
1195
+ !else
1196
+ TCLSTUBLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub.lib
1197
+ !endif
1198
+ TCLIMPLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX:t=).lib
1199
+ # When building extensions, may be linking against Tcl that does not add
1200
+ # "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
1201
+ !if !exist("$(TCLIMPLIB)")
1202
+ TCLIMPLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)t$(SUFX:t=).lib
1203
+ !endif
1204
+ TCL_LIBRARY = $(_TCLDIR)\library
1205
+ TCLREGLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg13$(SUFX:t=).lib
1206
+ TCLDDELIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib
1207
+ TCLSCRIPTZIP = $(_TCLDIR)\win\$(BUILDDIRTOP)\$(TCL_ZIP_FILE)
1208
+ TCLTOOLSDIR = $(_TCLDIR)\tools
1209
+ TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
1210
+
1211
+ !endif # TCLINSTALL
1212
+
1213
+ !if !$(STATIC_BUILD) && "$(TCL_BUILD_FOR)" == "8"
1214
+ tcllibs = "$(TCLSTUBLIB)"
1215
+ !else
1216
+ tcllibs = "$(TCLSTUBLIB)" "$(TCLIMPLIB)"
1217
+ !endif
1218
+
1219
+ !endif # $(DOING_TCL)
1220
+
1221
+ # We need a tclsh that will run on the host machine as part of the build.
1222
+ # IX86 runs on all architectures.
1223
+ !ifndef TCLSH_NATIVE
1224
+ !if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
1225
+ TCLSH_NATIVE = $(TCLSH)
1226
+ !else
1227
+ !error You must explicitly set TCLSH_NATIVE for cross-compilation
1228
+ !endif
1229
+ !endif
1230
+
1231
+ # Do the same for Tk and Tk extensions that require the Tk libraries
1232
+ !if $(DOING_TK) || $(NEED_TK)
1233
+ WISHNAMEPREFIX = wish
1234
+ WISHNAME = $(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe
1235
+ TKLIBNAME8 = tk$(TK_VERSION)$(SUFX).$(EXT)
1236
+ TKLIBNAME9 = tcl9tk$(TK_VERSION)$(SUFX).$(EXT)
1237
+ !if $(TCL_MAJOR_VERSION) == 8 || "$(TCL_BUILD_FOR)" == "8"
1238
+ TKLIBNAME = tk$(TK_VERSION)$(SUFX).$(EXT)
1239
+ TKIMPLIBNAME = tk$(TK_VERSION)$(SUFX).lib
1240
+ !else
1241
+ TKLIBNAME = tcl9tk$(TK_VERSION)$(SUFX).$(EXT)
1242
+ TKIMPLIBNAME = tcl9tk$(TK_VERSION)$(SUFX).lib
1243
+ !endif
1244
+ !if $(TK_MAJOR_VERSION) == 8
1245
+ TKSTUBLIBNAME = tkstub$(TK_VERSION).lib
1246
+ !else
1247
+ TKSTUBLIBNAME = tkstub.lib
1248
+ !endif
1249
+
1250
+ !if $(DOING_TK)
1251
+ WISH = $(OUT_DIR)\$(WISHNAME)
1252
+ TKSTUBLIB = $(OUT_DIR)\$(TKSTUBLIBNAME)
1253
+ TKIMPLIB = $(OUT_DIR)\$(TKIMPLIBNAME)
1254
+ TKLIB = $(OUT_DIR)\$(TKLIBNAME)
1255
+ TK_INCLUDES = -I"$(WIN_DIR)" -I"$(GENERICDIR)"
1256
+ TKSCRIPTZIP = $(OUT_DIR)\$(TK_ZIP_FILE)
1257
+
1258
+ !else # effectively NEED_TK
1259
+
1260
+ !if $(TKINSTALL) # Building against installed Tk
1261
+ WISH = $(_TKDIR)\bin\$(WISHNAME)
1262
+ TKSTUBLIB = $(_TKDIR)\lib\$(TKSTUBLIBNAME)
1263
+ TKIMPLIB = $(_TKDIR)\lib\$(TKIMPLIBNAME)
1264
+ # When building extensions, may be linking against Tk that does not add
1265
+ # "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
1266
+ !if !exist("$(TKIMPLIB)")
1267
+ TKIMPLIBNAME = tk$(TK_VERSION)$(SUFX:t=).lib
1268
+ TKIMPLIB = $(_TKDIR)\lib\$(TKIMPLIBNAME)
1269
+ !endif
1270
+ TK_INCLUDES = -I"$(_TKDIR)\include"
1271
+ TKSCRIPTZIP = $(_TKDIR)\lib\$(TK_ZIP_FILE)
1272
+
1273
+ !else # Building against Tk sources
1274
+
1275
+ WISH = $(_TKDIR)\win\$(BUILDDIRTOP)\$(WISHNAME)
1276
+ TKSTUBLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSTUBLIBNAME)
1277
+ TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
1278
+ # When building extensions, may be linking against Tk that does not add
1279
+ # "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
1280
+ !if !exist("$(TKIMPLIB)")
1281
+ TKIMPLIBNAME = tk$(TK_VERSION)$(SUFX:t=).lib
1282
+ TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
1283
+ !endif
1284
+ TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
1285
+ TKSCRIPTZIP = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TK_ZIP_FILE)
1286
+
1287
+ !endif # TKINSTALL
1288
+
1289
+ tklibs = "$(TKSTUBLIB)" "$(TKIMPLIB)"
1290
+
1291
+ !endif # $(DOING_TK)
1292
+ !endif # $(DOING_TK) || $(NEED_TK)
1293
+
1294
+ # Various output paths
1295
+ PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
1296
+ PRJLIBNAME8 = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
1297
+ # Even when building against Tcl 8, PRJLIBNAME9 must not have "t"
1298
+ PRJLIBNAME9 = tcl9$(PROJECT)$(VERSION)$(SUFX:t=).$(EXT)
1299
+ !if $(TCL_MAJOR_VERSION) == 8 || "$(TCL_BUILD_FOR)" == "8"
1300
+ PRJLIBNAME = $(PRJLIBNAME8)
1301
+ !else
1302
+ PRJLIBNAME = $(PRJLIBNAME9)
1303
+ !endif
1304
+ PRJLIB = $(OUT_DIR)\$(PRJLIBNAME)
1305
+
1306
+ !if $(TCL_MAJOR_VERSION) == 8
1307
+ PRJSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
1308
+ !else
1309
+ PRJSTUBLIBNAME = $(STUBPREFIX).lib
1310
+ !endif
1311
+ PRJSTUBLIB = $(OUT_DIR)\$(PRJSTUBLIBNAME)
1312
+
1313
+ # If extension parent makefile has not defined a resource definition file,
1314
+ # we will generate one from standard template.
1315
+ !if !$(DOING_TCL) && !$(DOING_TK) && !$(STATIC_BUILD)
1316
+ !ifdef RCFILE
1317
+ RESFILE = $(TMP_DIR)\$(RCFILE:.rc=.res)
1318
+ !else
1319
+ RESFILE = $(TMP_DIR)\$(PROJECT).res
1320
+ !endif
1321
+ !endif
1322
+
1323
+ ###################################################################
1324
+ # 11. Construct the paths for the installation directories
1325
+ # The following macros get defined in this section:
1326
+ # LIB_INSTALL_DIR - where libraries should be installed
1327
+ # BIN_INSTALL_DIR - where the executables should be installed
1328
+ # DOC_INSTALL_DIR - where documentation should be installed
1329
+ # SCRIPT_INSTALL_DIR - where scripts should be installed
1330
+ # INCLUDE_INSTALL_DIR - where C include files should be installed
1331
+ # DEMO_INSTALL_DIR - where demos should be installed
1332
+ # PRJ_INSTALL_DIR - where package will be installed (not set for Tcl and Tk)
1333
+
1334
+ !if $(DOING_TCL) || $(DOING_TK)
1335
+ LIB_INSTALL_DIR = $(_INSTALLDIR)\lib
1336
+ BIN_INSTALL_DIR = $(_INSTALLDIR)\bin
1337
+ DOC_INSTALL_DIR = $(_INSTALLDIR)\doc
1338
+ !if $(DOING_TCL)
1339
+ SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
1340
+ MODULE_INSTALL_DIR = $(_INSTALLDIR)\lib\tcl$(TCL_MAJOR_VERSION)
1341
+ !else # DOING_TK
1342
+ SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
1343
+ !endif
1344
+ DEMO_INSTALL_DIR = $(SCRIPT_INSTALL_DIR)\demos
1345
+ INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\include
1346
+
1347
+ !else # extension other than Tk
1348
+
1349
+ PRJ_INSTALL_DIR = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION)
1350
+ !if $(MULTIPLATFORM_INSTALL)
1351
+ LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR)\$(PLATFORM_IDENTIFY)
1352
+ BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR)\$(PLATFORM_IDENTIFY)
1353
+ !else
1354
+ LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR)
1355
+ BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR)
1356
+ !endif
1357
+ DOC_INSTALL_DIR = $(PRJ_INSTALL_DIR)
1358
+ SCRIPT_INSTALL_DIR = $(PRJ_INSTALL_DIR)
1359
+ DEMO_INSTALL_DIR = $(PRJ_INSTALL_DIR)\demos
1360
+ INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\..\include
1361
+
1362
+ !endif
1363
+
1364
+ ###################################################################
1365
+ # 12. Set up actual options to be passed to the compiler and linker
1366
+ # Now we have all the information we need, set up the actual flags and
1367
+ # options that we will pass to the compiler and linker. The main
1368
+ # makefile should use these in combination with whatever other flags
1369
+ # and switches are specific to it.
1370
+ # The following macros are defined, names are for historical compatibility:
1371
+ # OPTDEFINES - /Dxxx C macro flags based on user-specified OPTS
1372
+ # COMPILERFLAGS - /Dxxx C macro flags independent of any configuration options
1373
+ # crt - Compiler switch that selects the appropriate C runtime
1374
+ # cdebug - Compiler switches related to debug AND optimizations
1375
+ # cwarn - Compiler switches that set warning levels
1376
+ # cflags - complete compiler switches (subsumes cdebug and cwarn)
1377
+ # ldebug - Linker switches controlling debug information and optimization
1378
+ # lflags - complete linker switches (subsumes ldebug) except subsystem type
1379
+ # dlllflags - complete linker switches to build DLLs (subsumes lflags)
1380
+ # conlflags - complete linker switches for console program (subsumes lflags)
1381
+ # guilflags - complete linker switches for GUI program (subsumes lflags)
1382
+ # baselibs - minimum Windows libraries required. Parent makefile can
1383
+ # define PRJ_LIBS before including rules.rc if additional libs are needed
1384
+
1385
+ OPTDEFINES = /DSTDC_HEADERS /DUSE_NMAKE=1
1386
+ !if $(VCVERSION) > 1600
1387
+ OPTDEFINES = $(OPTDEFINES) /DHAVE_STDINT_H=1
1388
+ !else
1389
+ OPTDEFINES = $(OPTDEFINES) /DMP_NO_STDINT=1
1390
+ !endif
1391
+ !if $(VCVERSION) >= 1800
1392
+ OPTDEFINES = $(OPTDEFINES) /DHAVE_INTTYPES_H=1 /DHAVE_STDBOOL_H=1
1393
+ !endif
1394
+
1395
+ !if $(TCL_MEM_DEBUG)
1396
+ OPTDEFINES = $(OPTDEFINES) /DTCL_MEM_DEBUG
1397
+ !endif
1398
+ !if $(TCL_COMPILE_DEBUG)
1399
+ OPTDEFINES = $(OPTDEFINES) /DTCL_COMPILE_DEBUG /DTCL_COMPILE_STATS
1400
+ !endif
1401
+ !if $(TCL_THREADS) && $(TCL_VERSION) < 87
1402
+ OPTDEFINES = $(OPTDEFINES) /DTCL_THREADS=1
1403
+ !if $(USE_THREAD_ALLOC) && $(TCL_VERSION) < 87
1404
+ OPTDEFINES = $(OPTDEFINES) /DUSE_THREAD_ALLOC=1
1405
+ !endif
1406
+ !endif
1407
+ !if $(STATIC_BUILD)
1408
+ OPTDEFINES = $(OPTDEFINES) /DSTATIC_BUILD
1409
+ !elseif $(TCL_VERSION) > 86
1410
+ OPTDEFINES = $(OPTDEFINES) /DTCL_WITH_EXTERNAL_TOMMATH
1411
+ !if "$(MACHINE)" == "AMD64" || "$(MACHINE)" == "ARM64"
1412
+ OPTDEFINES = $(OPTDEFINES) /DMP_64BIT
1413
+ !endif
1414
+ !endif
1415
+ !if $(TCL_NO_DEPRECATED)
1416
+ OPTDEFINES = $(OPTDEFINES) /DTCL_NO_DEPRECATED
1417
+ !endif
1418
+
1419
+ !if $(USE_STUBS)
1420
+ # Note we do not define USE_TCL_STUBS even when building tk since some
1421
+ # test targets in tk do not use stubs
1422
+ !if !$(DOING_TCL)
1423
+ USE_STUBS_DEFS = /DUSE_TCL_STUBS /DUSE_TCLOO_STUBS
1424
+ !if $(NEED_TK)
1425
+ USE_STUBS_DEFS = $(USE_STUBS_DEFS) /DUSE_TK_STUBS
1426
+ !endif
1427
+ !endif
1428
+ !endif # USE_STUBS
1429
+
1430
+ !if !$(DEBUG)
1431
+ OPTDEFINES = $(OPTDEFINES) /DNDEBUG
1432
+ !if $(OPTIMIZING)
1433
+ OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_OPTIMIZED
1434
+ !endif
1435
+ !endif
1436
+ !if $(PROFILE)
1437
+ OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_PROFILED
1438
+ !endif
1439
+ !if "$(MACHINE)" == "AMD64" || "$(MACHINE)" == "ARM64"
1440
+ OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_DO64BIT
1441
+ !endif
1442
+ !if $(VCVERSION) < 1300
1443
+ OPTDEFINES = $(OPTDEFINES) /DNO_STRTOI64=1
1444
+ !endif
1445
+
1446
+ !if $(TCL_MAJOR_VERSION) == 8
1447
+ !if "$(_USE_64BIT_TIME_T)" == "1"
1448
+ OPTDEFINES = $(OPTDEFINES) /D_USE_64BIT_TIME_T=1
1449
+ !endif
1450
+ !endif
1451
+ !if "$(TCL_BUILD_FOR)" == "8"
1452
+ OPTDEFINES = $(OPTDEFINES) /DTCL_MAJOR_VERSION=8
1453
+ !endif
1454
+
1455
+ # Like the TEA system only set this non empty for non-Tk extensions
1456
+ # Note: some extensions use PACKAGE_NAME and others use PACKAGE_TCLNAME
1457
+ # so we pass both
1458
+ !if !$(DOING_TCL) && !$(DOING_TK)
1459
+ PKGNAMEFLAGS = /DPACKAGE_NAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
1460
+ /DPACKAGE_TCLNAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
1461
+ /DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
1462
+ /DMODULE_SCOPE=extern
1463
+ !endif
1464
+
1465
+ # crt picks the C run time based on selected OPTS
1466
+ !if $(MSVCRT)
1467
+ !if $(DEBUG) && !$(UNCHECKED)
1468
+ crt = -MDd
1469
+ !else
1470
+ crt = -MD
1471
+ !endif
1472
+ !else
1473
+ !if $(DEBUG) && !$(UNCHECKED)
1474
+ crt = -MTd
1475
+ !else
1476
+ crt = -MT
1477
+ !endif
1478
+ !endif
1479
+
1480
+ # cdebug includes compiler options for debugging as well as optimization.
1481
+ !if $(DEBUG)
1482
+
1483
+ # In debugging mode, optimizations need to be disabled
1484
+ cdebug = -Zi -Od $(DEBUGFLAGS)
1485
+
1486
+ !else
1487
+
1488
+ cdebug = $(OPTIMIZATIONS)
1489
+ !if $(SYMBOLS)
1490
+ cdebug = $(cdebug) -Zi
1491
+ !endif
1492
+
1493
+ !endif # $(DEBUG)
1494
+
1495
+ # cwarn includes default warning levels, also C4090 (buggy) and C4146 is useless.
1496
+ cwarn = $(WARNINGS) -wd4090 -wd4146
1497
+
1498
+ !if "$(MACHINE)" == "AMD64" || "$(MACHINE)" == "ARM64"
1499
+ # Disable pointer<->int warnings related to cast between different sizes
1500
+ # There are a gadzillion of these due to use of ClientData and
1501
+ # clutter up compiler
1502
+ # output increasing chance of a real warning getting lost. So disable them.
1503
+ # Eventually some day, Tcl will be 64-bit clean.
1504
+ cwarn = $(cwarn) -wd4311 -wd4312
1505
+ !endif
1506
+
1507
+ ### Common compiler options that are architecture specific
1508
+ !if "$(MACHINE)" == "ARM"
1509
+ carch = /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
1510
+ !else
1511
+ carch =
1512
+ !endif
1513
+
1514
+ # cpuid is only available on intel machines
1515
+ !if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "AMD64"
1516
+ carch = $(carch) /DHAVE_CPUID=1
1517
+ !endif
1518
+
1519
+ !if $(DEBUG)
1520
+ # Turn warnings into errors
1521
+ cwarn = $(cwarn) -WX
1522
+ !endif
1523
+
1524
+ INCLUDES = $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES)
1525
+ !if !$(DOING_TCL) && !$(DOING_TK)
1526
+ INCLUDES = $(INCLUDES) -I"$(GENERICDIR)" -I"$(WIN_DIR)" -I"$(COMPATDIR)"
1527
+ !endif
1528
+
1529
+ # These flags are defined roughly in the order of the pre-reform
1530
+ # rules.vc/makefile.vc to help visually compare that the pre- and
1531
+ # post-reform build logs
1532
+
1533
+ # cflags contains generic flags used for building practically all object files
1534
+ cflags = -nologo -c $(COMPILERFLAGS) $(carch) $(cwarn) -Fp$(TMP_DIR)^\ $(cdebug)
1535
+
1536
+ !if $(TCL_MAJOR_VERSION) == 8 && $(TCL_MINOR_VERSION) < 7
1537
+ cflags = $(cflags) -DTcl_Size=int
1538
+ !endif
1539
+
1540
+ # appcflags contains $(cflags) and flags for building the application
1541
+ # object files (e.g. tclsh, or wish) pkgcflags contains $(cflags) plus
1542
+ # flags used for building shared object files The two differ in the
1543
+ # BUILD_$(PROJECT) macro which should be defined only for the shared
1544
+ # library *implementation* and not for its caller interface
1545
+
1546
+ appcflags_nostubs = $(cflags) $(crt) $(INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES)
1547
+ appcflags = $(appcflags_nostubs) $(USE_STUBS_DEFS)
1548
+ pkgcflags = $(appcflags) $(PKGNAMEFLAGS) /DBUILD_$(PROJECT)
1549
+ pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) /DBUILD_$(PROJECT)
1550
+
1551
+ # stubscflags contains $(cflags) plus flags used for building a stubs
1552
+ # library for the package. Note: /DSTATIC_BUILD is defined in
1553
+ # $(OPTDEFINES) only if the OPTS configuration indicates a static
1554
+ # library. However the stubs library is ALWAYS static hence included
1555
+ # here irrespective of the OPTS setting.
1556
+ #
1557
+ # TBD - tclvfs has a comment that stubs libs should not be compiled with -GL
1558
+ # without stating why. Tcl itself compiled stubs libs with this flag.
1559
+ # so we do not remove it from cflags. -GL may prevent extensions
1560
+ # compiled with one VC version to fail to link against stubs library
1561
+ # compiled with another VC version. Check for this and fix accordingly.
1562
+ stubscflags = $(cflags) $(PKGNAMEFLAGS) $(PRJ_DEFINES) $(OPTDEFINES) /Zl /GL- /DSTATIC_BUILD $(INCLUDES) $(USE_STUBS_DEFS)
1563
+
1564
+ # Link flags
1565
+
1566
+ !if $(DEBUG)
1567
+ ldebug = -debug -debugtype:cv
1568
+ !else
1569
+ ldebug = -release -opt:ref -opt:icf,3
1570
+ !if $(SYMBOLS)
1571
+ ldebug = $(ldebug) -debug -debugtype:cv
1572
+ !endif
1573
+ !endif
1574
+
1575
+ # Note: Profiling is currently only possible with the Visual Studio Enterprise
1576
+ !if $(PROFILE)
1577
+ ldebug= $(ldebug) -profile
1578
+ !endif
1579
+
1580
+ ### Declarations common to all linker versions
1581
+ lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug)
1582
+
1583
+ !if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900
1584
+ lflags = $(lflags) -nodefaultlib:libucrt.lib
1585
+ !endif
1586
+
1587
+ dlllflags = $(lflags) -dll
1588
+ conlflags = $(lflags) -subsystem:console
1589
+ guilflags = $(lflags) -subsystem:windows
1590
+
1591
+ # Libraries that are required for every image.
1592
+ # Extensions should define any additional libraries with $(PRJ_LIBS)
1593
+ winlibs = kernel32.lib advapi32.lib
1594
+
1595
+ !if $(NEED_TK)
1596
+ winlibs = $(winlibs) gdi32.lib user32.lib uxtheme.lib
1597
+ !endif
1598
+
1599
+ # Avoid 'unresolved external symbol __security_cookie' errors.
1600
+ # c.f. http://support.microsoft.com/?id=894573
1601
+ !if "$(MACHINE)" == "AMD64"
1602
+ !if $(VCVERSION) > 1399 && $(VCVERSION) < 1500
1603
+ winlibs = $(winlibs) bufferoverflowU.lib
1604
+ !endif
1605
+ !endif
1606
+
1607
+ baselibs = $(winlibs) $(PRJ_LIBS)
1608
+
1609
+ !if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900
1610
+ baselibs = $(baselibs) ucrt.lib
1611
+ !endif
1612
+
1613
+ ################################################################
1614
+ # 13. Define standard commands, common make targets and implicit rules
1615
+
1616
+ CCPKGCMD = $(cc32) $(pkgcflags) -Fo$(TMP_DIR)^\
1617
+ CCAPPCMD = $(cc32) $(appcflags) -Fo$(TMP_DIR)^\
1618
+ CCSTUBSCMD = $(cc32) $(stubscflags) -Fo$(TMP_DIR)^\
1619
+
1620
+ LIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:$@
1621
+ DLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs)
1622
+
1623
+ CONEXECMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs)
1624
+ GUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs)
1625
+ RESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \
1626
+ $(TCL_INCLUDES) /DSTATIC_BUILD=$(STATIC_BUILD) \
1627
+ /DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
1628
+ /DCOMMAVERSION=$(RCCOMMAVERSION) \
1629
+ /DDOTVERSION=\"$(DOTVERSION)\" \
1630
+ /DVERSION=\"$(VERSION)\" \
1631
+ /DSUFX=\"$(SUFX)\" \
1632
+ /DPROJECT=\"$(PROJECT)\" \
1633
+ /DPRJLIBNAME=\"$(PRJLIBNAME)\"
1634
+
1635
+ !ifndef DEFAULT_BUILD_TARGET
1636
+ DEFAULT_BUILD_TARGET = $(PROJECT)
1637
+ !endif
1638
+
1639
+ default-target: $(DEFAULT_BUILD_TARGET)
1640
+
1641
+ !if $(MULTIPLATFORM_INSTALL)
1642
+ default-pkgindex:
1643
+ @echo if {[package vsatisfies [package provide Tcl] 9.0-]} { > $(OUT_DIR)\pkgIndex.tcl
1644
+ @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
1645
+ [list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME9)]] >> $(OUT_DIR)\pkgIndex.tcl
1646
+ @echo } else { >> $(OUT_DIR)\pkgIndex.tcl
1647
+ @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
1648
+ [list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME8)]] >> $(OUT_DIR)\pkgIndex.tcl
1649
+ @echo } >> $(OUT_DIR)\pkgIndex.tcl
1650
+ !else
1651
+ default-pkgindex:
1652
+ @echo if {[package vsatisfies [package provide Tcl] 9.0-]} { > $(OUT_DIR)\pkgIndex.tcl
1653
+ @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
1654
+ [list load [file join $$dir $(PRJLIBNAME9)]] >> $(OUT_DIR)\pkgIndex.tcl
1655
+ @echo } else { >> $(OUT_DIR)\pkgIndex.tcl
1656
+ @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
1657
+ [list load [file join $$dir $(PRJLIBNAME8)]] >> $(OUT_DIR)\pkgIndex.tcl
1658
+ @echo } >> $(OUT_DIR)\pkgIndex.tcl
1659
+ !endif
1660
+
1661
+ default-pkgindex-tea:
1662
+ @if exist $(ROOT)\pkgIndex.tcl.in nmakehlp -s << $(ROOT)\pkgIndex.tcl.in > $(OUT_DIR)\pkgIndex.tcl
1663
+ @PACKAGE_VERSION@ $(DOTVERSION)
1664
+ @PACKAGE_NAME@ $(PRJ_PACKAGE_TCLNAME)
1665
+ @PACKAGE_TCLNAME@ $(PRJ_PACKAGE_TCLNAME)
1666
+ @PKG_LIB_FILE@ $(PRJLIBNAME)
1667
+ @PKG_LIB_FILE8@ $(PRJLIBNAME8)
1668
+ @PKG_LIB_FILE9@ $(PRJLIBNAME9)
1669
+ <<
1670
+
1671
+ default-install: default-install-binaries default-install-libraries
1672
+ !if $(SYMBOLS)
1673
+ default-install: default-install-pdbs
1674
+ !endif
1675
+
1676
+ # Again to deal with historical brokenness, there is some confusion
1677
+ # in terminlogy. For extensions, the "install-binaries" was used to
1678
+ # locate target directory for *binary shared libraries* and thus
1679
+ # the appropriate macro is LIB_INSTALL_DIR since BIN_INSTALL_DIR is
1680
+ # for executables (exes). On the other hand the "install-libraries"
1681
+ # target is for *scripts* and should have been called "install-scripts".
1682
+ default-install-binaries: $(PRJLIB)
1683
+ @echo Installing binaries to '$(LIB_INSTALL_DIR)'
1684
+ @if not exist "$(LIB_INSTALL_DIR)" mkdir "$(LIB_INSTALL_DIR)"
1685
+ @$(CPY) $(PRJLIB) "$(LIB_INSTALL_DIR)" >NUL
1686
+
1687
+ # Alias for default-install-scripts
1688
+ default-install-libraries: default-install-scripts
1689
+
1690
+ default-install-scripts: $(OUT_DIR)\pkgIndex.tcl
1691
+ @echo Installing libraries to '$(SCRIPT_INSTALL_DIR)'
1692
+ @if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)"
1693
+ @echo Installing package index in '$(SCRIPT_INSTALL_DIR)'
1694
+ @$(CPY) $(OUT_DIR)\pkgIndex.tcl $(SCRIPT_INSTALL_DIR)
1695
+
1696
+ default-install-stubs:
1697
+ @echo Installing stubs library to '$(SCRIPT_INSTALL_DIR)'
1698
+ @if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
1699
+ @$(CPY) $(PRJSTUBLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
1700
+
1701
+ default-install-pdbs:
1702
+ @echo Installing PDBs to '$(LIB_INSTALL_DIR)'
1703
+ @if not exist "$(LIB_INSTALL_DIR)" mkdir "$(LIB_INSTALL_DIR)"
1704
+ @$(CPY) "$(OUT_DIR)\*.pdb" "$(LIB_INSTALL_DIR)\"
1705
+
1706
+ # "emacs font-lock highlighting fix
1707
+
1708
+ default-install-docs-html:
1709
+ @echo Installing documentation files to '$(DOC_INSTALL_DIR)'
1710
+ @if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)"
1711
+ @if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.html" "$(DOCDIR)\*.css" "$(DOCDIR)\*.png") do @$(COPY) %f "$(DOC_INSTALL_DIR)"
1712
+
1713
+ default-install-docs-n:
1714
+ @echo Installing documentation files to '$(DOC_INSTALL_DIR)'
1715
+ @if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)"
1716
+ @if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.n") do @$(COPY) %f "$(DOC_INSTALL_DIR)"
1717
+
1718
+ default-install-demos:
1719
+ @echo Installing demos to '$(DEMO_INSTALL_DIR)'
1720
+ @if not exist "$(DEMO_INSTALL_DIR)" mkdir "$(DEMO_INSTALL_DIR)"
1721
+ @if exist $(DEMODIR) $(CPYDIR) "$(DEMODIR)" "$(DEMO_INSTALL_DIR)"
1722
+
1723
+ default-clean:
1724
+ @echo Cleaning $(TMP_DIR)\* ...
1725
+ @if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
1726
+ @echo Cleaning $(WIN_DIR)\nmakehlp.obj, nmakehlp.exe ...
1727
+ @if exist $(WIN_DIR)\nmakehlp.obj del $(WIN_DIR)\nmakehlp.obj
1728
+ @if exist $(WIN_DIR)\nmakehlp.exe del $(WIN_DIR)\nmakehlp.exe
1729
+ @if exist $(WIN_DIR)\nmakehlp.out del $(WIN_DIR)\nmakehlp.out
1730
+ @echo Cleaning $(WIN_DIR)\nmhlp-out.txt ...
1731
+ @if exist $(WIN_DIR)\nmhlp-out.txt del $(WIN_DIR)\nmhlp-out.txt
1732
+ @echo Cleaning $(WIN_DIR)\_junk.pch ...
1733
+ @if exist $(WIN_DIR)\_junk.pch del $(WIN_DIR)\_junk.pch
1734
+ @echo Cleaning $(WIN_DIR)\vercl.x, vercl.i ...
1735
+ @if exist $(WIN_DIR)\vercl.x del $(WIN_DIR)\vercl.x
1736
+ @if exist $(WIN_DIR)\vercl.i del $(WIN_DIR)\vercl.i
1737
+ @echo Cleaning $(WIN_DIR)\versions.vc, version.vc ...
1738
+ @if exist $(WIN_DIR)\versions.vc del $(WIN_DIR)\versions.vc
1739
+ @if exist $(WIN_DIR)\version.vc del $(WIN_DIR)\version.vc
1740
+
1741
+ default-hose: default-clean
1742
+ @echo Hosing $(OUT_DIR)\* ...
1743
+ @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)
1744
+
1745
+ # Only for backward compatibility
1746
+ default-distclean: default-hose
1747
+
1748
+ default-setup:
1749
+ @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
1750
+ @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
1751
+
1752
+ !if "$(TESTPAT)" != ""
1753
+ TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT)
1754
+ !endif
1755
+
1756
+ default-test: default-setup $(PROJECT)
1757
+ @set TCLLIBPATH=$(OUT_DIR:\=/)
1758
+ @if exist $(LIBDIR) for %f in ("$(LIBDIR)\*.tcl") do @$(COPY) %f "$(OUT_DIR)"
1759
+ cd "$(TESTDIR)" && $(DEBUGGER) $(TCLSH) all.tcl $(TESTFLAGS)
1760
+
1761
+ default-shell: default-setup $(PROJECT)
1762
+ @set TCLLIBPATH=$(OUT_DIR:\=/)
1763
+ @if exist $(LIBDIR) for %f in ("$(LIBDIR)\*.tcl") do @$(COPY) %f "$(OUT_DIR)"
1764
+ $(DEBUGGER) $(TCLSH)
1765
+
1766
+ # Generation of Windows version resource
1767
+ !ifdef RCFILE
1768
+
1769
+ # Note: don't use $** in below rule because there may be other dependencies
1770
+ # and only the "main" rc must be passed to the resource compiler
1771
+ $(TMP_DIR)\$(PROJECT).res: $(RCDIR)\$(PROJECT).rc
1772
+ $(RESCMD) $(RCDIR)\$(PROJECT).rc
1773
+
1774
+ !else
1775
+
1776
+ # If parent makefile has not defined a resource definition file,
1777
+ # we will generate one from standard template.
1778
+ $(TMP_DIR)\$(PROJECT).res: $(TMP_DIR)\$(PROJECT).rc
1779
+
1780
+ $(TMP_DIR)\$(PROJECT).rc:
1781
+ @$(COPY) << $(TMP_DIR)\$(PROJECT).rc
1782
+ #include <winver.h>
1783
+
1784
+ VS_VERSION_INFO VERSIONINFO
1785
+ FILEVERSION COMMAVERSION
1786
+ PRODUCTVERSION COMMAVERSION
1787
+ FILEFLAGSMASK 0x3fL
1788
+ #ifdef DEBUG
1789
+ FILEFLAGS VS_FF_DEBUG
1790
+ #else
1791
+ FILEFLAGS 0x0L
1792
+ #endif
1793
+ FILEOS VOS_NT_WINDOWS32
1794
+ FILETYPE VFT_DLL
1795
+ FILESUBTYPE 0x0L
1796
+ BEGIN
1797
+ BLOCK "StringFileInfo"
1798
+ BEGIN
1799
+ BLOCK "040904b0"
1800
+ BEGIN
1801
+ VALUE "FileDescription", "Tcl extension " PROJECT
1802
+ VALUE "OriginalFilename", PRJLIBNAME
1803
+ VALUE "FileVersion", DOTVERSION
1804
+ VALUE "ProductName", "Package " PROJECT " for Tcl"
1805
+ VALUE "ProductVersion", DOTVERSION
1806
+ END
1807
+ END
1808
+ BLOCK "VarFileInfo"
1809
+ BEGIN
1810
+ VALUE "Translation", 0x409, 1200
1811
+ END
1812
+ END
1813
+
1814
+ <<
1815
+
1816
+ !endif # ifdef RCFILE
1817
+
1818
+ !ifndef DISABLE_IMPLICIT_RULES
1819
+ DISABLE_IMPLICIT_RULES = 0
1820
+ !endif
1821
+
1822
+ !if !$(DISABLE_IMPLICIT_RULES)
1823
+ # Implicit rule definitions - only for building library objects. For stubs and
1824
+ # main application, the makefile should define explicit rules.
1825
+
1826
+ {$(ROOT)}.c{$(TMP_DIR)}.obj::
1827
+ $(CCPKGCMD) @<<
1828
+ $<
1829
+ <<
1830
+
1831
+ {$(WIN_DIR)}.c{$(TMP_DIR)}.obj::
1832
+ $(CCPKGCMD) @<<
1833
+ $<
1834
+ <<
1835
+
1836
+ {$(GENERICDIR)}.c{$(TMP_DIR)}.obj::
1837
+ $(CCPKGCMD) @<<
1838
+ $<
1839
+ <<
1840
+
1841
+ {$(COMPATDIR)}.c{$(TMP_DIR)}.obj::
1842
+ $(CCPKGCMD) @<<
1843
+ $<
1844
+ <<
1845
+
1846
+ {$(RCDIR)}.rc{$(TMP_DIR)}.res:
1847
+ $(RESCMD) $<
1848
+
1849
+ {$(WIN_DIR)}.rc{$(TMP_DIR)}.res:
1850
+ $(RESCMD) $<
1851
+
1852
+ {$(TMP_DIR)}.rc{$(TMP_DIR)}.res:
1853
+ $(RESCMD) $<
1854
+
1855
+ .SUFFIXES:
1856
+ .SUFFIXES:.c .rc
1857
+
1858
+ !endif
1859
+
1860
+ ################################################################
1861
+ # 14. Sanity check selected options against Tcl build options
1862
+ # When building an extension, certain configuration options should
1863
+ # match the ones used when Tcl was built. Here we check and
1864
+ # warn on a mismatch.
1865
+ !if !$(DOING_TCL)
1866
+
1867
+ !if $(TCLINSTALL) # Building against an installed Tcl
1868
+ !if exist("$(_TCLDIR)\lib\nmake\tcl.nmake")
1869
+ TCLNMAKECONFIG = "$(_TCLDIR)\lib\nmake\tcl.nmake"
1870
+ !endif
1871
+ !else # !$(TCLINSTALL) - building against Tcl source
1872
+ !if exist("$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl.nmake")
1873
+ TCLNMAKECONFIG = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl.nmake"
1874
+ !endif
1875
+ !endif # TCLINSTALL
1876
+
1877
+ !if $(CONFIG_CHECK)
1878
+ !ifdef TCLNMAKECONFIG
1879
+ !include $(TCLNMAKECONFIG)
1880
+
1881
+ !if defined(CORE_MACHINE) && "$(CORE_MACHINE)" != "$(MACHINE)"
1882
+ !error ERROR: Build target ($(MACHINE)) does not match the Tcl library architecture ($(CORE_MACHINE)).
1883
+ !endif
1884
+ !if $(TCL_VERSION) < 87 && defined(CORE_USE_THREAD_ALLOC) && $(CORE_USE_THREAD_ALLOC) != $(USE_THREAD_ALLOC)
1885
+ !message WARNING: Value of USE_THREAD_ALLOC ($(USE_THREAD_ALLOC)) does not match its Tcl core value ($(CORE_USE_THREAD_ALLOC)).
1886
+ !endif
1887
+ !if defined(CORE_DEBUG) && $(CORE_DEBUG) != $(DEBUG)
1888
+ !message WARNING: Value of DEBUG ($(DEBUG)) does not match its Tcl library configuration ($(DEBUG)).
1889
+ !endif
1890
+ !endif
1891
+
1892
+ !endif # TCLNMAKECONFIG
1893
+
1894
+ !endif # !$(DOING_TCL)
1895
+
1896
+
1897
+ #----------------------------------------------------------
1898
+ # Display stats being used.
1899
+ #----------------------------------------------------------
1900
+
1901
+ !if !$(DOING_TCL)
1902
+ !message *** Building against Tcl at '$(_TCLDIR)'
1903
+ !endif
1904
+ !if !$(DOING_TK) && $(NEED_TK)
1905
+ !message *** Building against Tk at '$(_TKDIR)'
1906
+ !endif
1907
+ !message *** Intermediate directory will be '$(TMP_DIR)'
1908
+ !message *** Output directory will be '$(OUT_DIR)'
1909
+ !message *** Installation, if selected, will be in '$(_INSTALLDIR)'
1910
+ !message *** Suffix for binaries will be '$(SUFX)'
1911
+ !message *** Compiler version $(VCVER). Target $(MACHINE), host $(NATIVE_ARCH).
1912
+
1913
+ !endif # ifdef _RULES_VC
local-test-sqlite3-delta-02/afc-sqlite3/autoconf/tea/win/targets.vc ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #------------------------------------------------------------- -*- makefile -*-
2
+ # targets.vc --
3
+ #
4
+ # Part of the nmake based build system for Tcl and its extensions.
5
+ # This file defines some standard targets for the convenience of extensions
6
+ # and can be optionally included by the extension makefile.
7
+ # See TIP 477 (https://core.tcl-lang.org/tips/doc/main/tip/477.md) for docs.
8
+
9
+ $(PROJECT): setup pkgindex $(PRJLIB)
10
+
11
+ !ifdef PRJ_STUBOBJS
12
+ $(PROJECT): $(PRJSTUBLIB)
13
+ $(PRJSTUBLIB): $(PRJ_STUBOBJS)
14
+ $(LIBCMD) $**
15
+
16
+ $(PRJ_STUBOBJS):
17
+ $(CCSTUBSCMD) %s
18
+ !endif # PRJ_STUBOBJS
19
+
20
+ !ifdef PRJ_MANIFEST
21
+ $(PROJECT): $(PRJLIB).manifest
22
+ $(PRJLIB).manifest: $(PRJ_MANIFEST)
23
+ @nmakehlp -s << $** >$@
24
+ @MACHINE@ $(MACHINE:IX86=X86)
25
+ <<
26
+ !endif
27
+
28
+ !if "$(PROJECT)" != "tcl" && "$(PROJECT)" != "tk"
29
+ $(PRJLIB): $(PRJ_OBJS) $(RESFILE)
30
+ !if $(STATIC_BUILD)
31
+ $(LIBCMD) $**
32
+ !else
33
+ $(DLLCMD) $**
34
+ $(_VC_MANIFEST_EMBED_DLL)
35
+ !endif
36
+ -@del $*.exp
37
+ !endif
38
+
39
+ !if "$(PRJ_HEADERS)" != "" && "$(PRJ_OBJS)" != ""
40
+ $(PRJ_OBJS): $(PRJ_HEADERS)
41
+ !endif
42
+
43
+ # If parent makefile has defined stub objects, add their installation
44
+ # to the default install
45
+ !if "$(PRJ_STUBOBJS)" != ""
46
+ default-install: default-install-stubs
47
+ !endif
48
+
49
+ # Unlike the other default targets, these cannot be in rules.vc because
50
+ # the executed command depends on existence of macro PRJ_HEADERS_PUBLIC
51
+ # that the parent makefile will not define until after including rules-ext.vc
52
+ !if "$(PRJ_HEADERS_PUBLIC)" != ""
53
+ default-install: default-install-headers
54
+ default-install-headers:
55
+ @echo Installing headers to '$(INCLUDE_INSTALL_DIR)'
56
+ @for %f in ($(PRJ_HEADERS_PUBLIC)) do @$(COPY) %f "$(INCLUDE_INSTALL_DIR)"
57
+ !endif
58
+
59
+ !if "$(DISABLE_STANDARD_TARGETS)" == ""
60
+ DISABLE_STANDARD_TARGETS = 0
61
+ !endif
62
+
63
+ !if "$(DISABLE_TARGET_setup)" == ""
64
+ DISABLE_TARGET_setup = 0
65
+ !endif
66
+ !if "$(DISABLE_TARGET_install)" == ""
67
+ DISABLE_TARGET_install = 0
68
+ !endif
69
+ !if "$(DISABLE_TARGET_clean)" == ""
70
+ DISABLE_TARGET_clean = 0
71
+ !endif
72
+ !if "$(DISABLE_TARGET_test)" == ""
73
+ DISABLE_TARGET_test = 0
74
+ !endif
75
+ !if "$(DISABLE_TARGET_shell)" == ""
76
+ DISABLE_TARGET_shell = 0
77
+ !endif
78
+
79
+ !if !$(DISABLE_STANDARD_TARGETS)
80
+ !if !$(DISABLE_TARGET_setup)
81
+ setup: default-setup
82
+ !endif
83
+ !if !$(DISABLE_TARGET_install)
84
+ install: default-install
85
+ !endif
86
+ !if !$(DISABLE_TARGET_clean)
87
+ clean: default-clean
88
+ realclean: hose
89
+ hose: default-hose
90
+ distclean: realclean default-distclean
91
+ !endif
92
+ !if !$(DISABLE_TARGET_test)
93
+ test: default-test
94
+ !endif
95
+ !if !$(DISABLE_TARGET_shell)
96
+ shell: default-shell
97
+ !endif
98
+ !endif # DISABLE_STANDARD_TARGETS
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/LICENSE ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Unless explicitly stated, all files which form part of autosetup
2
+ are released under the following license:
3
+
4
+ ---------------------------------------------------------------------
5
+ autosetup - A build environment "autoconfigurator"
6
+
7
+ Copyright (c) 2010-2011, WorkWare Systems <http://workware.net.au/>
8
+
9
+ Redistribution and use in source and binary forms, with or without
10
+ modification, are permitted provided that the following conditions
11
+ are met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+ 2. Redistributions in binary form must reproduce the above
16
+ copyright notice, this list of conditions and the following
17
+ disclaimer in the documentation and/or other materials
18
+ provided with the distribution.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE WORKWARE SYSTEMS ``AS IS'' AND ANY
21
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WORKWARE
24
+ SYSTEMS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+
33
+ The views and conclusions contained in the software and documentation
34
+ are those of the authors and should not be interpreted as representing
35
+ official policies, either expressed or implied, of WorkWare Systems.
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/README.autosetup ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ README.autosetup created by autosetup v0.7.2
2
+
3
+ This is the autosetup directory for a local install of autosetup.
4
+ It contains autosetup, support files and loadable modules.
5
+
6
+ *.tcl files in this directory are optional modules which
7
+ can be loaded with the 'use' directive.
8
+
9
+ *.auto files in this directory are auto-loaded.
10
+
11
+ For more information, see https://msteveb.github.io/autosetup/
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/README.md ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Maintaining Autosetup in the SQLite Tree
2
+ ========================================================================
3
+
4
+ This document provides some tips and reminders for the SQLite
5
+ developers regarding using and maintaining the [Autosetup][]-based
6
+ build infrastructure. It is not an [Autosetup][] reference.
7
+
8
+ **Table of Contents**:
9
+
10
+ - [Autosetup API Reference](#apiref)
11
+ - [API Tips](#apitips)
12
+ - [Ensuring TCL Compatibility](#tclcompat)
13
+ - [Design Conventions](#conventions)
14
+ - Symbolic Names of Feature Flags
15
+ - Do Not Update Global Shared State
16
+ - [Updating Autosetup](#updating)
17
+
18
+ ------------------------------------------------------------------------
19
+
20
+ <a name="apiref"></a>
21
+ Autosetup API Reference
22
+ ========================================================================
23
+
24
+ The Autosetup API is quite extensive and can be read either in
25
+ the [files in the `autosetup` dir](/dir/autosetup) or using:
26
+
27
+ >
28
+ ```
29
+ $ ./configure --reference | less
30
+ ```
31
+
32
+ That will include any docs from any TCL files in the `./autosetup` dir
33
+ which contain certain (simple) markup defined by autosetup.
34
+
35
+ This project's own autosetup-related APIs are in [proj.tcl][] or
36
+ [auto.def][]. The former contains helper APIs which are, more or
37
+ less, portable across projects (that file is re-used as-is in other
38
+ projects) and all have a `proj-` name prefix. The latter is the main
39
+ configure script driver and contains related functions which are
40
+ specific to this tree.
41
+
42
+
43
+ <a name="apitips"></a>
44
+ Autosetup API Tips
45
+ ========================================================================
46
+
47
+ This section briefly covers only APIs which are frequently useful in
48
+ day-to-day maintenance and might not be immediately recognized as such
49
+ obvious from a casual perusal of [auto.def][]. The complete docs of
50
+ those with `proj-` prefix can be found in [proj.tcl][]. The others are
51
+ scattered around [the TCL files in ./autosetup](/dir/autosetup).
52
+
53
+ In (mostly) alphabetical order:
54
+
55
+ - **`file-isexec filename`**\
56
+ Should be used in place of `[file executable]`, as it will also
57
+ check for `${filename}.exe` on Windows platforms. However, on such
58
+ platforms is also assumes that _any_ existing file is executable.
59
+
60
+ - **`get-env VAR ?default?`**\
61
+ Will fetch an "environment variable"
62
+ from the first of either: (1) a KEY=VALUE passed to the configure
63
+ script or (2) the system's environment variables. Not to be confused
64
+ with `getenv`, which only does the latter and is rarely, if ever,
65
+ useful in this tree.
66
+ - **`proj-get-env VAR ?default?`**\
67
+ Works like `get-env` but will, if that function finds no match,
68
+ look for a file named `./.env-$VAR` and, if found, return its
69
+ trimmed contents. This can be used, e.g., to set a developer's
70
+ local preferences for the default `CFLAGS`.
71
+
72
+ - **`define-for-opt flag defineName ?checkingMsg? ?yesVal=1? ?noVal=0?`**\
73
+ `[define $defineName]` to either `$yesVal` or `$noVal`, depending on
74
+ whether `--$flag` is truthy or not. `$checkingMsg` is a
75
+ human-readable description of the check being made, e.g. "enable foo
76
+ bar baz?" If no `checkingMsg` is provided, the operation is silent.\
77
+ Potential TODO: change the final two args to `-yes` and `-no`
78
+ flags. They're rarely needed, though: search [auto.def][] for
79
+ `TSTRNNR_OPTS` for an example of where they are used.
80
+
81
+ - **`proj-fatal msg`**\
82
+ Emits `$msg` to stderr and exits with non-zero.
83
+
84
+ - **`proj-if-opt-truthy flag thenScript ?elseScript?`**\
85
+ Evals `thenScript` if the given `--flag` is truthy, else it
86
+ evals the optional `elseScript`.
87
+
88
+ - **`proj-indented-notice ?-error? ?-notice? msg`**\
89
+ Breaks its `msg` argument into lines, trims them, and emits them
90
+ with consistent indentation. Exactly how it emits depends on the
91
+ flags passed to it (or not), as covered in its docs. This will stick
92
+ out starkly from normal output and is intended to be used only for
93
+ important notices.
94
+
95
+ - **`proj-opt-truthy flag`**\
96
+ Returns 1 if `--flag`'s value is "truthy," i.e. one of (1, on,
97
+ enabled, yes, true).
98
+
99
+ - **`proj-opt-was-provided FLAG`**\
100
+ Returns 1 if `--FLAG` was explicitly provided to configure,
101
+ else 0. This distinction can be used to determine, e.g., whether
102
+ `--with-readline` was provided or whether we're searching for
103
+ readline by default. In the former case, failure to find it should
104
+ be treated as fatal, where in the latter case it's not.
105
+
106
+ - **`proj-val-truthy value`**\
107
+ Returns 1 if `$value` is "truthy," See `proj-opt-truthy` for the definition
108
+ of "truthy."
109
+
110
+ - **`proj-warn msg`**\
111
+ Emits `$msg` to stderr. Closely-related is autosetup's `user-notice`
112
+ (described below).
113
+
114
+ - **`sqlite-add-feature-flag ?-shell? FLAG...`**\
115
+ Adds the given feature flag to the CFLAGS which are specific to building
116
+ the library. It's intended to be passed one or more `-DSQLITE_ENABLE_...`,
117
+ or similar, flags. If the `-shell` flag is used then it also passes
118
+ its arguments to `sqlite-add-shell-opt`. This is a no-op if `FLAG`
119
+ is not provided or is empty.
120
+
121
+ - **`sqlite-add-shell-opt FLAG...`**\
122
+ The shell-specific counterpart of `sqlite-add-feature-flag`.
123
+
124
+ - **`user-notice msg`**\
125
+ Queues `$msg` to be sent to stderr, but does not emit it until
126
+ either `show-notices` is called or the next time autosetup would
127
+ output something (it internally calls `show-notices`). This can be
128
+ used to generate warnings between a "checking for..." message and
129
+ its resulting "yes/no/whatever" message in such a way as to not
130
+ spoil the layout of such messages.
131
+
132
+ <a name="tclcompat"></a>
133
+ Ensuring TCL Compatibility
134
+ ========================================================================
135
+
136
+ It is important that any TCL files used by the configure process
137
+ remain compatible with both [JimTCL][] and the canonical TCL. Though
138
+ JimTCL has outstanding compatibility with canonical TCL, it does have
139
+ a few corners with incompatibilities, e.g. regular expressions. If a
140
+ script runs in JimTCL without using any JimTCL-specific features, then
141
+ it's a certainty that it will run in canonical TCL as well. The
142
+ opposite, however, is not _always_ the case.
143
+
144
+ When [`./configure`](/file/configure) is run, it goes through a
145
+ bootstrapping process to find a suitable TCL with which to run the
146
+ autosetup framework. The first step involves [finding or building a
147
+ TCL shell](/file/autosetup/autosetup-find-tclsh). That will first
148
+ search for an available `tclsh` (under several common names,
149
+ e.g. `tclsh8.6`) before falling back to compiling the copy of
150
+ `jimsh0.c` included in the source tree. i.e. it will prefer to use a
151
+ system-installed TCL for running the configure script. Once it finds
152
+ (or builds) a TCL shell, it then runs [a sanity test to ensure that
153
+ the shell is suitable](/file/autosetup/autosetup-test-tclsh) before
154
+ using it to run the main autosetup app.
155
+
156
+ There are two simple ways to ensure that running of the configure
157
+ process uses JimTCL instead of the canonical `tclsh`, and either
158
+ approach provides equally high assurances about configure script
159
+ compatibility across TCL implementations:
160
+
161
+ 1. Build on a system with no `tclsh` installed in the `$PATH`. In that
162
+ case, the configure process will fall back to building the in-tree
163
+ copy of JimTCL.
164
+
165
+ 2. Manually build `./jimsh0` in the top of the checkout with:\
166
+ `cc -o jimsh0 autosetup/jimsh0.c`\
167
+ With that in place, the configure script will prefer to use that
168
+ before looking for a system-level `tclsh`. Be aware, though, that
169
+ `make distclean` will remove that file.
170
+
171
+ **Note that `jimsh0` is distinctly different** from the `jimsh` which
172
+ gets built for code-generation purposes. The latter requires
173
+ non-default build flags to enable features which are
174
+ platform-dependent, most notably to make its `[file normalize]` work.
175
+ This means, for example, that the configure script and its utility
176
+ APIs must not use `[file normalize]`, but autosetup provides a TCL
177
+ implementation of `[file-normalize]` (note the dash) for portable use
178
+ in the configure script.
179
+
180
+
181
+ <a name="conventions"></a>
182
+ Design Conventions
183
+ ========================================================================
184
+
185
+ This section describes the motivations for the most glaring of the
186
+ build's design decisions, in particular how they deviate from
187
+ historical, or even widely-conventional, practices.
188
+
189
+ Symbolic Names of Feature Flags
190
+ ------------------------------------------------------------------------
191
+
192
+ Historically, the project's makefile has exclusively used
193
+ `UPPER_UNDERSCORE` form for makefile variables. This build, however,
194
+ primarily uses `X.y` format, where `X` is often a category label,
195
+ e.g. `CFLAGS` and `y` is the specific instance of that category,
196
+ e.g. `CFLAGS.readline`.
197
+
198
+ When the configure script exports flags for consumption by filtered
199
+ files, e.g. [Makefile.in][] and the generated
200
+ `sqlite_cfg.h`, it does so in the more conventional `X_Y` form because
201
+ those flags get exported as as C `#define`s to `sqlite_cfg.h`, where
202
+ dots are not permitted.
203
+
204
+ The `X.y` convention is used in the makefiles primarily because the
205
+ person who did the initial port finds that considerably easier on the
206
+ eyes and fingers. In practice, the `X_Y` form of such exports is used
207
+ exactly once in [Makefile.in][], where it's translated into into `X.y`
208
+ form for consumption by [Makefile.in][] and [main.mk][]. For example:
209
+
210
+ >
211
+ ```
212
+ LDFLAGS.shobj = @SHOBJ_LDFLAGS@
213
+ LDFLAGS.zlib = @LDFLAGS_ZLIB@
214
+ LDFLAGS.math = @LDFLAGS_MATH@
215
+ ```
216
+
217
+ (That first one is defined by autosetup, and thus applies "LDFLAGS" as
218
+ the suffix rather than the prefix. Which is more legible is a matter
219
+ of taste, for which there is no accounting.)
220
+
221
+
222
+ Do Not Update Global Shared State
223
+ ------------------------------------------------------------------------
224
+
225
+ In both the legacy Autotools-driven build and in common Autosetup
226
+ usage, feature tests performed by the configure script may amend
227
+ global flags such as `LIBS`, `LDFLAGS`, and `CFLAGS`[^as-cflags]. That's
228
+ appropriate for a makefile which builds a single deliverable, but less
229
+ so for makefiles which produce multiple deliverables. Drawbacks of
230
+ that approach include:
231
+
232
+ - It's unlikely that every single deliverable will require the same
233
+ core set of those flags.
234
+ - It can be difficult to determine the origin of any given change to
235
+ that global state because those changes are hidden behind voodoo performed
236
+ outside the immediate visibility of the configure script's
237
+ maintainer.
238
+ - It can force the maintainers of the configure script to place tests
239
+ in a specific order so that the resulting flags get applied at
240
+ the correct time and/or in the correct order.\
241
+ (A real-life example: before the approach described below was taken
242
+ to collecting build-time flags, the test for `-rpath` had to come
243
+ _after_ the test for zlib because the results of the `-rpath` test
244
+ implicitly modified global state which broke the zlib feature
245
+ test. Because the feature tests no longer (intentionally) modify
246
+ global state, that is not an issue.)
247
+
248
+ In this build, cases where feature tests modify global state in such a
249
+ way that it may impact later feature tests are either (A) very
250
+ intentionally defined to do so (e.g. the `--with-wasi-sdk` flag has
251
+ invasive side-effects) or (B) are oversights (i.e. bugs).
252
+
253
+ This tree's [configure script][auto.def], [utility APIs][proj.tcl],
254
+ [Makefile.in][], and [main.mk][] therefore strive to separate the
255
+ results of any given feature test into its own well-defined
256
+ variables. For example:
257
+
258
+ - The linker flags for zlib are exported from the configure script as
259
+ `LDFLAGS_ZLIB`, which [Makefile.in][] and [main.mk][] then expose as
260
+ `LDFLAGS.zlib`.
261
+ - `CFLAGS_READLINE` (a.k.a. `CFLAGS.readline`) contains the `CFLAGS`
262
+ needed for including `libreadline`, `libedit`, or `linenoise`, and
263
+ `LDFLAGS_READLINE` (a.k.a. `LDFLAGS.readline`) is its link-time
264
+ counterpart.
265
+
266
+ It is then up to the Makefile to apply and order the flags however is
267
+ appropriate.
268
+
269
+ At the end of the configure script, the global `CFLAGS` _ideally_
270
+ holds only flags which are either relevant to all targets or, failing
271
+ that, will have no unintended side-effects on any targets. That said:
272
+ clients frequently pass custom `CFLAGS` to `./configure` or `make` to
273
+ set library-level feature toggles, e.g. `-DSQLITE_OMIT_FOO`, in which
274
+ case there is no practical way to avoid "polluting" the builds of
275
+ arbitrary makefile targets with those. _C'est la vie._
276
+
277
+
278
+ [^as-cflags]: But see this article for a detailed discussion of how
279
+ autosetup currently deals specifically with CFLAGS:
280
+ <https://msteveb.github.io/autosetup/articles/handling-cflags/>
281
+
282
+
283
+ <a name="updating"></a>
284
+ Updating Autosetup
285
+ ========================================================================
286
+
287
+ Updating autosetup is, more often than not, painless. It requires having
288
+ a checked-out copy of [the autosetup git repository][autosetup-git]:
289
+
290
+ >
291
+ ```
292
+ $ git clone https://github.com/msteveb/autosetup
293
+ $ cd autosetup
294
+ # Or, if it's already checked out:
295
+ $ git pull
296
+ ```
297
+
298
+ Then, from the top-most directory of an SQLite checkout:
299
+
300
+ >
301
+ ```
302
+ $ /path/to/autosetup-checkout/autosetup --install .
303
+ $ fossil status # show the modified files
304
+ ```
305
+
306
+ Unless the upgrade made any incompatible changes (which is exceedingly
307
+ rare), that's all there is to it. Check over the diff, test the
308
+ configure process, and check it in.
309
+
310
+
311
+
312
+ [Autosetup]: https://msteveb.github.io/autosetup/
313
+ [auto.def]: /file/auto.def
314
+ [autosetup-git]: https://github.com/msteveb/autosetup
315
+ [proj.tcl]: /file/autosetup/proj.tcl
316
+ [Makefile.in]: /file/Makefile.in
317
+ [main.mk]: /file/main.mk
318
+ [JimTCL]: https://jim.tcl.tk
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/autosetup ADDED
@@ -0,0 +1,2536 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # Copyright (c) 2006-2011 WorkWare Systems http://www.workware.net.au/
3
+ # All rights reserved
4
+ # vim:se syntax=tcl:
5
+ # \
6
+ dir=`dirname "$0"`; exec "`$dir/autosetup-find-tclsh`" "$0" "$@"
7
+
8
+ # Note that the version has a trailing + on unreleased versions
9
+ set autosetup(version) 0.7.2
10
+
11
+ # Can be set to 1 to debug early-init problems
12
+ set autosetup(debug) [expr {"--debug" in $argv}]
13
+
14
+ ##################################################################
15
+ #
16
+ # Main flow of control, option handling
17
+ #
18
+ proc main {argv} {
19
+ global autosetup define
20
+
21
+ # There are 3 potential directories involved:
22
+ # 1. The directory containing autosetup (this script)
23
+ # 2. The directory containing auto.def
24
+ # 3. The current directory
25
+
26
+ # From this we need to determine:
27
+ # a. The path to this script (and related support files)
28
+ # b. The path to auto.def
29
+ # c. The build directory, where output files are created
30
+
31
+ # This is also complicated by the fact that autosetup may
32
+ # have been run via the configure wrapper ([getenv WRAPPER] is set)
33
+
34
+ # Here are the rules.
35
+ # a. This script is $::argv0
36
+ # => dir, prog, exe, libdir
37
+ # b. auto.def is in the directory containing the configure wrapper,
38
+ # otherwise it is in the current directory.
39
+ # => srcdir, autodef
40
+ # c. The build directory is the current directory
41
+ # => builddir, [pwd]
42
+
43
+ # 'misc' is needed before we can do anything, so set a temporary libdir
44
+ # in case this is the development version
45
+ set autosetup(libdir) [file dirname $::argv0]/lib
46
+ use misc
47
+
48
+ # (a)
49
+ set autosetup(dir) [realdir [file dirname [realpath $::argv0]]]
50
+ set autosetup(prog) [file join $autosetup(dir) [file tail $::argv0]]
51
+ set autosetup(exe) [getenv WRAPPER $autosetup(prog)]
52
+ if {$autosetup(installed)} {
53
+ set autosetup(libdir) $autosetup(dir)
54
+ } else {
55
+ set autosetup(libdir) [file join $autosetup(dir) lib]
56
+ }
57
+ autosetup_add_dep $autosetup(prog)
58
+
59
+ # (b)
60
+ if {[getenv WRAPPER ""] eq ""} {
61
+ # Invoked directly
62
+ set autosetup(srcdir) [pwd]
63
+ } else {
64
+ # Invoked via the configure wrapper
65
+ set autosetup(srcdir) [file-normalize [file dirname $autosetup(exe)]]
66
+ }
67
+ set autosetup(autodef) [relative-path $autosetup(srcdir)/auto.def]
68
+
69
+ # (c)
70
+ set autosetup(builddir) [pwd]
71
+
72
+ set autosetup(argv) $argv
73
+ set autosetup(cmdline) {}
74
+ # options is a list of known options
75
+ set autosetup(options) {}
76
+ # optset is a dictionary of option values set by the user based on getopt
77
+ set autosetup(optset) {}
78
+ # optdefault is a dictionary of default values
79
+ set autosetup(optdefault) {}
80
+ # options-defaults is a dictionary of overrides for default values for options
81
+ set autosetup(options-defaults) {}
82
+ set autosetup(optionhelp) {}
83
+ set autosetup(showhelp) 0
84
+
85
+ use util
86
+
87
+ # Parse options
88
+ use getopt
89
+
90
+ # At the is point we don't know what is a valid option
91
+ # We simply parse anything that looks like an option
92
+ set autosetup(getopt) [getopt argv]
93
+
94
+ #"=Core Options:"
95
+ options-add {
96
+ help:=all => "display help and options. Optional: module name, such as --help=system"
97
+ licence license => "display the autosetup license"
98
+ version => "display the version of autosetup"
99
+ ref:=text manual:=text
100
+ reference:=text => "display the autosetup command reference. 'text', 'wiki', 'asciidoc' or 'markdown'"
101
+ debug => "display debugging output as autosetup runs"
102
+ install:=. => "install autosetup to the current or given directory"
103
+ }
104
+ if {$autosetup(installed)} {
105
+ # hidden options so we can produce a nice error
106
+ options-add {
107
+ sysinstall:path
108
+ }
109
+ } else {
110
+ options-add {
111
+ sysinstall:path => "install standalone autosetup to the given directory (e.g.: /usr/local)"
112
+ }
113
+ }
114
+ options-add {
115
+ force init:=help => "create initial auto.def, etc. Use --init=help for known types"
116
+ # Undocumented options
117
+ option-checking=1
118
+ nopager
119
+ quiet
120
+ timing
121
+ conf:
122
+ }
123
+
124
+ if {[opt-bool version]} {
125
+ puts $autosetup(version)
126
+ exit 0
127
+ }
128
+
129
+ # autosetup --conf=alternate-auto.def
130
+ if {[opt-str conf o]} {
131
+ set autosetup(autodef) $o
132
+ }
133
+
134
+ # Debugging output (set this early)
135
+ incr autosetup(debug) [opt-bool debug]
136
+ incr autosetup(force) [opt-bool force]
137
+ incr autosetup(msg-quiet) [opt-bool quiet]
138
+ incr autosetup(msg-timing) [opt-bool timing]
139
+
140
+ # If the local module exists, source it now to allow for
141
+ # project-local customisations
142
+ if {[file exists $autosetup(libdir)/local.tcl]} {
143
+ use local
144
+ }
145
+
146
+ # Now any auto-load modules
147
+ autosetup_load_auto_modules
148
+
149
+ if {[opt-str help o]} {
150
+ incr autosetup(showhelp)
151
+ use help
152
+ autosetup_help $o
153
+ }
154
+
155
+ if {[opt-bool licence license]} {
156
+ use help
157
+ autosetup_show_license
158
+ exit 0
159
+ }
160
+
161
+ if {[opt-str {manual ref reference} o]} {
162
+ use help
163
+ autosetup_reference $o
164
+ }
165
+
166
+ # Allow combining --install and --init
167
+ set earlyexit 0
168
+ if {[opt-str install o]} {
169
+ use install
170
+ autosetup_install $o
171
+ incr earlyexit
172
+ }
173
+
174
+ if {[opt-str init o]} {
175
+ use init
176
+ autosetup_init $o
177
+ incr earlyexit
178
+ }
179
+
180
+ if {$earlyexit} {
181
+ exit 0
182
+ }
183
+ if {[opt-str sysinstall o]} {
184
+ use install
185
+ autosetup_install $o 1
186
+ exit 0
187
+ }
188
+
189
+ if {![file exists $autosetup(autodef)]} {
190
+ # Check for invalid option first
191
+ options {}
192
+ user-error "No auto.def found in \"$autosetup(srcdir)\" (use [file tail $::autosetup(exe)] --init to create one)"
193
+ }
194
+
195
+ # Parse extra arguments into autosetup(cmdline)
196
+ foreach arg $argv {
197
+ if {[regexp {([^=]*)=(.*)} $arg -> n v]} {
198
+ dict set autosetup(cmdline) $n $v
199
+ define $n $v
200
+ } else {
201
+ user-error "Unexpected parameter: $arg"
202
+ }
203
+ }
204
+
205
+ autosetup_add_dep $autosetup(autodef)
206
+
207
+ # Add $argv to CONFIGURE_OPTS
208
+ define-append-argv CONFIGURE_OPTS {*}$autosetup(argv)
209
+ # Set up AUTOREMAKE to reconfigure with the same args
210
+ define-append-argv AUTOREMAKE {*}$autosetup(exe) {*}$autosetup(argv)
211
+
212
+ # Log how we were invoked
213
+ configlog "Invoked as: [getenv WRAPPER $::argv0] [quote-argv $autosetup(argv)]"
214
+ configlog "Tclsh: [info nameofexecutable]"
215
+
216
+ # Load auto.def as module "auto.def"
217
+ autosetup_load_module auto.def source $autosetup(autodef)
218
+
219
+ # Could warn here if options {} was not specified
220
+
221
+ show-notices
222
+
223
+ if {$autosetup(debug)} {
224
+ msg-result "Writing all defines to config.log"
225
+ configlog "================ defines ======================"
226
+ foreach n [lsort [array names define]] {
227
+ configlog "define $n $define($n)"
228
+ }
229
+ }
230
+
231
+ exit 0
232
+ }
233
+
234
+ # @section Option Handling
235
+
236
+ # @opt-bool ?-nodefault? option ...
237
+ #
238
+ # Check each of the named, boolean options and if any have been explicitly enabled
239
+ # or disabled by the user, return 1 or 0 accordingly.
240
+ #
241
+ # If the option was specified more than once, the last value wins.
242
+ # e.g. With '--enable-foo --disable-foo', '[opt-bool foo]' will return 0
243
+ #
244
+ # If no value was specified by the user, returns the default value for the
245
+ # first option. If '-nodefault' is given, this behaviour changes and
246
+ # -1 is returned instead.
247
+ #
248
+ proc opt-bool {args} {
249
+ set nodefault 0
250
+ if {[lindex $args 0] eq "-nodefault"} {
251
+ set nodefault 1
252
+ set args [lrange $args 1 end]
253
+ }
254
+ option-check-names {*}$args
255
+
256
+ foreach opt $args {
257
+ if {[dict exists $::autosetup(optset) $opt]} {
258
+ return [dict get $::autosetup(optset) $opt]
259
+ }
260
+ }
261
+
262
+ if {$nodefault} {
263
+ return -1
264
+ }
265
+ # Default value is the default for the first option
266
+ return [dict get $::autosetup(optdefault) [lindex $args 0]]
267
+ }
268
+
269
+ # @opt-val optionlist ?default=""?
270
+ #
271
+ # Returns a list containing all the values given for the non-boolean options in '$optionlist'.
272
+ # There will be one entry in the list for each option given by the user, including if the
273
+ # same option was used multiple times.
274
+ #
275
+ # If no options were set, '$default' is returned (exactly, not as a list).
276
+ #
277
+ # Note: For most use cases, 'opt-str' should be preferred.
278
+ #
279
+ proc opt-val {names {default ""}} {
280
+ option-check-names {*}$names
281
+
282
+ foreach opt $names {
283
+ if {[dict exists $::autosetup(optset) $opt]} {
284
+ lappend result {*}[dict get $::autosetup(optset) $opt]
285
+ }
286
+ }
287
+ if {[info exists result]} {
288
+ return $result
289
+ }
290
+ return $default
291
+ }
292
+
293
+ # @opt-str optionlist varname ?default?
294
+ #
295
+ # Sets '$varname' in the callers scope to the value for one of the given options.
296
+ #
297
+ # For the list of options given in '$optionlist', if any value is set for any option,
298
+ # the option value is taken to be the *last* value of the last option (in the order given).
299
+ #
300
+ # If no option was given, and a default was specified with 'options-defaults',
301
+ # that value is used.
302
+ #
303
+ # If no 'options-defaults' value was given and '$default' was given, it is used.
304
+ #
305
+ # If none of the above provided a value, no value is set.
306
+ #
307
+ # The return value depends on whether '$default' was specified.
308
+ # If it was, the option value is returned.
309
+ # If it was not, 1 is returns if a value was set, or 0 if not.
310
+ #
311
+ # Typical usage is as follows:
312
+ #
313
+ ## if {[opt-str {myopt altname} o]} {
314
+ ## do something with $o
315
+ ## }
316
+ #
317
+ # Or:
318
+ ## define myname [opt-str {myopt altname} o "/usr/local"]
319
+ #
320
+ proc opt-str {names varname args} {
321
+ global autosetup
322
+
323
+ option-check-names {*}$names
324
+ upvar $varname value
325
+
326
+ if {[llength $args]} {
327
+ # A default was given, so always return the string value of the option
328
+ set default [lindex $args 0]
329
+ set retopt 1
330
+ } else {
331
+ # No default, so return 0 or 1 to indicate if a value was found
332
+ set retopt 0
333
+ }
334
+
335
+ foreach opt $names {
336
+ if {[dict exists $::autosetup(optset) $opt]} {
337
+ set result [lindex [dict get $::autosetup(optset) $opt] end]
338
+ }
339
+ }
340
+
341
+ if {![info exists result]} {
342
+ # No user-specified value. Has options-defaults been set?
343
+ foreach opt $names {
344
+ if {[dict exists $::autosetup(optdefault) $opt]} {
345
+ set result [dict get $autosetup(optdefault) $opt]
346
+ }
347
+ }
348
+ }
349
+
350
+ if {[info exists result]} {
351
+ set value $result
352
+ if {$retopt} {
353
+ return $value
354
+ }
355
+ return 1
356
+ }
357
+
358
+ if {$retopt} {
359
+ set value $default
360
+ return $value
361
+ }
362
+
363
+ return 0
364
+ }
365
+
366
+ proc option-check-names {args} {
367
+ foreach o $args {
368
+ if {$o ni $::autosetup(options)} {
369
+ autosetup-error "Request for undeclared option --$o"
370
+ }
371
+ }
372
+ }
373
+
374
+ # Parse the option definition in $opts and update
375
+ # ::autosetup(setoptions) and ::autosetup(optionhelp) appropriately
376
+ #
377
+ proc options-add {opts} {
378
+ global autosetup
379
+
380
+ # First weed out comment lines
381
+ set realopts {}
382
+ foreach line [split $opts \n] {
383
+ if {![string match "#*" [string trimleft $line]]} {
384
+ append realopts $line \n
385
+ }
386
+ }
387
+ set opts $realopts
388
+
389
+ for {set i 0} {$i < [llength $opts]} {incr i} {
390
+ set opt [lindex $opts $i]
391
+ if {[string match =* $opt]} {
392
+ # This is a special heading
393
+ lappend autosetup(optionhelp) [list $opt $autosetup(module)]
394
+ continue
395
+ }
396
+ unset -nocomplain defaultvalue equal value
397
+
398
+ #puts "i=$i, opt=$opt"
399
+ regexp {^([^:=]*)(:)?(=)?(.*)$} $opt -> name colon equal value
400
+ if {$name in $autosetup(options)} {
401
+ autosetup-error "Option $name already specified"
402
+ }
403
+
404
+ #puts "$opt => $name $colon $equal $value"
405
+
406
+ # Find the corresponding value in the user options
407
+ # and set the default if necessary
408
+ if {[string match "-*" $opt]} {
409
+ # This is a documentation-only option, like "-C <dir>"
410
+ set opthelp $opt
411
+ } elseif {$colon eq ""} {
412
+ # Boolean option
413
+ lappend autosetup(options) $name
414
+
415
+ # Check for override
416
+ if {[dict exists $autosetup(options-defaults) $name]} {
417
+ # A default was specified with options-defaults, so use it
418
+ set value [dict get $autosetup(options-defaults) $name]
419
+ }
420
+
421
+ if {$value eq "1"} {
422
+ set opthelp "--disable-$name"
423
+ } else {
424
+ set opthelp "--$name"
425
+ }
426
+
427
+ # Set the default
428
+ if {$value eq ""} {
429
+ set value 0
430
+ }
431
+ set defaultvalue $value
432
+ dict set autosetup(optdefault) $name $defaultvalue
433
+
434
+ if {[dict exists $autosetup(getopt) $name]} {
435
+ # The option was specified by the user. Look at the last value.
436
+ lassign [lindex [dict get $autosetup(getopt) $name] end] type setvalue
437
+ if {$type eq "str"} {
438
+ # Can we convert the value to a boolean?
439
+ if {$setvalue in {1 enabled yes}} {
440
+ set setvalue 1
441
+ } elseif {$setvalue in {0 disabled no}} {
442
+ set setvalue 0
443
+ } else {
444
+ user-error "Boolean option $name given as --$name=$setvalue"
445
+ }
446
+ }
447
+ dict set autosetup(optset) $name $setvalue
448
+ #puts "Found boolean option --$name=$setvalue"
449
+ }
450
+ } else {
451
+ # String option.
452
+ lappend autosetup(options) $name
453
+
454
+ if {$equal ne "="} {
455
+ # Was the option given as "name:value=default"?
456
+ # If so, set $value to the display name and $defaultvalue to the default
457
+ # (This is the preferred way to set a default value for a string option)
458
+ if {[regexp {^([^=]+)=(.*)$} $value -> value defaultvalue]} {
459
+ dict set autosetup(optdefault) $name $defaultvalue
460
+ }
461
+ }
462
+
463
+ # Maybe override the default value
464
+ if {[dict exists $autosetup(options-defaults) $name]} {
465
+ # A default was specified with options-defaults, so use it
466
+ set defaultvalue [dict get $autosetup(options-defaults) $name]
467
+ dict set autosetup(optdefault) $name $defaultvalue
468
+ } elseif {![info exists defaultvalue]} {
469
+ # No default value was given by value=default or options-defaults
470
+ # so use the value as the default when the plain option with no
471
+ # value is given (.e.g. just --opt instead of --opt=value)
472
+ set defaultvalue $value
473
+ }
474
+
475
+ if {$equal eq "="} {
476
+ # String option with optional value
477
+ set opthelp "--$name?=$value?"
478
+ } else {
479
+ # String option with required value
480
+ set opthelp "--$name=$value"
481
+ }
482
+
483
+ # Get the values specified by the user
484
+ if {[dict exists $autosetup(getopt) $name]} {
485
+ set listvalue {}
486
+
487
+ foreach pair [dict get $autosetup(getopt) $name] {
488
+ lassign $pair type setvalue
489
+ if {$type eq "bool" && $setvalue} {
490
+ if {$equal ne "="} {
491
+ user-error "Option --$name requires a value"
492
+ }
493
+ # If given as a boolean, use the default value
494
+ set setvalue $defaultvalue
495
+ }
496
+ lappend listvalue $setvalue
497
+ }
498
+
499
+ #puts "Found string option --$name=$listvalue"
500
+ dict set autosetup(optset) $name $listvalue
501
+ }
502
+ }
503
+
504
+ # Now create the help for this option if appropriate
505
+ if {[lindex $opts $i+1] eq "=>"} {
506
+ set desc [lindex $opts $i+2]
507
+ if {[info exists defaultvalue]} {
508
+ set desc [string map [list @default@ $defaultvalue] $desc]
509
+ }
510
+ # A multi-line description
511
+ lappend autosetup(optionhelp) [list $opthelp $autosetup(module) $desc]
512
+ incr i 2
513
+ }
514
+ }
515
+ }
516
+
517
+ # @module-options optionlist
518
+ #
519
+ # Deprecated. Simply use 'options' from within a module.
520
+ proc module-options {opts} {
521
+ options $opts
522
+ }
523
+
524
+ proc max {a b} {
525
+ expr {$a > $b ? $a : $b}
526
+ }
527
+
528
+ proc options-wrap-desc {text length firstprefix nextprefix initial} {
529
+ set len $initial
530
+ set space $firstprefix
531
+ foreach word [split $text] {
532
+ set word [string trim $word]
533
+ if {$word == ""} {
534
+ continue
535
+ }
536
+ if {$len && [string length $space$word] + $len >= $length} {
537
+ puts ""
538
+ set len 0
539
+ set space $nextprefix
540
+ }
541
+ incr len [string length $space$word]
542
+ puts -nonewline $space$word
543
+ set space " "
544
+ }
545
+ if {$len} {
546
+ puts ""
547
+ }
548
+ }
549
+
550
+ # Display options (from $autosetup(optionhelp)) for modules that match
551
+ # glob pattern $what
552
+ proc options-show {what} {
553
+ set local 0
554
+ # Determine the max option width
555
+ set max 0
556
+ foreach help $::autosetup(optionhelp) {
557
+ lassign $help opt module desc
558
+ if {![string match $what $module]} {
559
+ continue
560
+ }
561
+ if {[string match =* $opt] || [string match \n* $desc]} {
562
+ continue
563
+ }
564
+ set max [max $max [string length $opt]]
565
+ }
566
+ set indent [string repeat " " [expr {$max+4}]]
567
+ set cols [getenv COLUMNS 80]
568
+ catch {
569
+ lassign [exec stty size] _ sttycols
570
+ if {[string is integer -strict $sttycols]} {
571
+ set cols $sttycols
572
+ }
573
+ }
574
+ incr cols -1
575
+ # Now output
576
+ foreach help $::autosetup(optionhelp) {
577
+ lassign $help opt module desc
578
+ if {![string match $what $module]} {
579
+ continue
580
+ }
581
+ if {$local == 0 && $module eq "auto.def"} {
582
+ puts "Local Options:"
583
+ incr local
584
+ }
585
+ if {[string match =* $opt]} {
586
+ # Output a special heading line"
587
+ puts [string range $opt 1 end]
588
+ continue
589
+ }
590
+ puts -nonewline " [format %-${max}s $opt]"
591
+ if {[string match \n* $desc]} {
592
+ # Output a pre-formatted help description as-is
593
+ puts $desc
594
+ } else {
595
+ options-wrap-desc [string trim $desc] $cols " " $indent [expr {$max+2}]
596
+ }
597
+ }
598
+ }
599
+
600
+ # @options optionspec
601
+ #
602
+ # Specifies configuration-time options which may be selected by the user
603
+ # and checked with 'opt-str' and 'opt-bool'. '$optionspec' contains a series
604
+ # of options specifications separated by newlines, as follows:
605
+ #
606
+ # A boolean option is of the form:
607
+ #
608
+ ## name[=0|1] => "Description of this boolean option"
609
+ #
610
+ # The default is 'name=0', meaning that the option is disabled by default.
611
+ # If 'name=1' is used to make the option enabled by default, the description should reflect
612
+ # that with text like "Disable support for ...".
613
+ #
614
+ # An argument option (one which takes a parameter) is of one of the following forms:
615
+ #
616
+ ## name:value => "Description of this option"
617
+ ## name:value=default => "Description of this option with a default value"
618
+ ## name:=value => "Description of this option with an optional value"
619
+ #
620
+ # If the 'name:value' form is used, the value must be provided with the option (as '--name=myvalue').
621
+ # If the 'name:value=default' form is used, the option has the given default value even if not
622
+ # specified by the user.
623
+ # If the 'name:=value' form is used, the value is optional and the given value is used
624
+ # if it is not provided.
625
+ #
626
+ # The description may contain '@default@', in which case it will be replaced with the default
627
+ # value for the option (taking into account defaults specified with 'options-defaults'.
628
+ #
629
+ # Undocumented options are also supported by omitting the '=> description'.
630
+ # These options are not displayed with '--help' and can be useful for internal options or as aliases.
631
+ #
632
+ # For example, '--disable-lfs' is an alias for '--disable=largefile':
633
+ #
634
+ ## lfs=1 largefile=1 => "Disable large file support"
635
+ #
636
+ proc options {optlist} {
637
+ global autosetup
638
+
639
+ options-add $optlist
640
+
641
+ if {$autosetup(showhelp)} {
642
+ # If --help, stop now to show help
643
+ return -code break
644
+ }
645
+
646
+ if {$autosetup(module) eq "auto.def"} {
647
+ # Check for invalid options
648
+ if {[opt-bool option-checking]} {
649
+ foreach o [dict keys $::autosetup(getopt)] {
650
+ if {$o ni $::autosetup(options)} {
651
+ user-error "Unknown option --$o"
652
+ }
653
+ }
654
+ }
655
+ }
656
+ }
657
+
658
+ # @options-defaults dictionary
659
+ #
660
+ # Specifies a dictionary of options and a new default value for each of those options.
661
+ # Use before any 'use' statements in 'auto.def' to change the defaults for
662
+ # subsequently included modules.
663
+ proc options-defaults {dict} {
664
+ foreach {n v} $dict {
665
+ dict set ::autosetup(options-defaults) $n $v
666
+ }
667
+ }
668
+
669
+ proc config_guess {} {
670
+ if {[file-isexec $::autosetup(dir)/autosetup-config.guess]} {
671
+ if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.guess} alias]} {
672
+ user-error $alias
673
+ }
674
+ return $alias
675
+ } else {
676
+ configlog "No autosetup-config.guess, so using uname"
677
+ string tolower [exec uname -p]-unknown-[exec uname -s][exec uname -r]
678
+ }
679
+ }
680
+
681
+ proc config_sub {alias} {
682
+ if {[file-isexec $::autosetup(dir)/autosetup-config.sub]} {
683
+ if {[catch {exec-with-stderr sh $::autosetup(dir)/autosetup-config.sub $alias} alias]} {
684
+ user-error $alias
685
+ }
686
+ }
687
+ return $alias
688
+ }
689
+
690
+ # @section Variable Definitions (defines)
691
+
692
+ # @define name ?value=1?
693
+ #
694
+ # Defines the named variable to the given value.
695
+ # These (name, value) pairs represent the results of the configuration check
696
+ # and are available to be subsequently checked, modified and substituted.
697
+ #
698
+ proc define {name {value 1}} {
699
+ set ::define($name) $value
700
+ #dputs "$name <= $value"
701
+ }
702
+
703
+ # @define-push {name ...} script
704
+ #
705
+ # Save the values of the given defines, evaluation the script, then restore.
706
+ # For example, to avoid updating AS_FLAGS and AS_CXXFLAGS:
707
+ ## define-push {AS_CFLAGS AS_CXXFLAGS} {
708
+ ## cc-check-flags -Wno-error
709
+ ## }
710
+ proc define-push {names script} {
711
+ array set unset {}
712
+ foreach name $names {
713
+ if {[is-defined $name]} {
714
+ set save($name) [get-define $name]
715
+ } else {
716
+ set unset($name) 1
717
+ }
718
+ }
719
+ uplevel 1 $script
720
+ array set ::define [array get save]
721
+ foreach name [array names unset] {
722
+ unset -nocomplain ::define($name)
723
+ }
724
+ }
725
+
726
+ # @undefine name
727
+ #
728
+ # Undefine the named variable.
729
+ #
730
+ proc undefine {name} {
731
+ unset -nocomplain ::define($name)
732
+ #dputs "$name <= <undef>"
733
+ }
734
+
735
+ # @define-append name value ...
736
+ #
737
+ # Appends the given value(s) to the given "defined" variable.
738
+ # If the variable is not defined or empty, it is set to '$value'.
739
+ # Otherwise the value is appended, separated by a space.
740
+ # Any extra values are similarly appended.
741
+ #
742
+ # Note that define-append is not designed to add values containing spaces.
743
+ # If values may contain spaces, consider define-append-argv instead.
744
+ #
745
+ proc define-append {name args} {
746
+ if {[get-define $name ""] ne ""} {
747
+ foreach arg $args {
748
+ if {$arg eq ""} {
749
+ continue
750
+ }
751
+ append ::define($name) " " $arg
752
+ }
753
+ } else {
754
+ set ::define($name) [join $args]
755
+ }
756
+ #dputs "$name += [join $args] => $::define($name)"
757
+ }
758
+
759
+ # @define-append-argv name value ...
760
+ #
761
+ # Similar to define-append except designed to construct shell command
762
+ # lines, including correct handling of parameters with spaces.
763
+ #
764
+ # Each non-empty value is quoted if necessary and then appended to the given variable
765
+ # if it does not already exist.
766
+ #
767
+ proc define-append-argv {name args} {
768
+ set seen {}
769
+ set new {}
770
+ foreach val [list {*}[get-define $name ""] {*}$args] {
771
+ if {$val ne {} && ![dict exists $seen $val]} {
772
+ lappend new [quote-if-needed $val]
773
+ dict set seen $val 1
774
+ }
775
+ }
776
+ set ::define($name) [join $new " "]
777
+ #dputs "$name += [join $args] => $::define($name)"
778
+ }
779
+
780
+ # @get-define name ?default=0?
781
+ #
782
+ # Returns the current value of the "defined" variable, or '$default'
783
+ # if not set.
784
+ #
785
+ proc get-define {name {default 0}} {
786
+ if {[info exists ::define($name)]} {
787
+ #dputs "$name => $::define($name)"
788
+ return $::define($name)
789
+ }
790
+ #dputs "$name => $default"
791
+ return $default
792
+ }
793
+
794
+ # @is-defined name
795
+ #
796
+ # Returns 1 if the given variable is defined.
797
+ #
798
+ proc is-defined {name} {
799
+ info exists ::define($name)
800
+ }
801
+
802
+ # @is-define-set name
803
+ #
804
+ # Returns 1 if the given variable is defined and is set
805
+ # to a value other than "" or 0
806
+ #
807
+ proc is-define-set {name} {
808
+ if {[get-define $name] in {0 ""}} {
809
+ return 0
810
+ }
811
+ return 1
812
+ }
813
+
814
+ # @all-defines
815
+ #
816
+ # Returns a dictionary (name, value list) of all defined variables.
817
+ #
818
+ # This is suitable for use with 'dict', 'array set' or 'foreach'
819
+ # and allows for arbitrary processing of the defined variables.
820
+ #
821
+ proc all-defines {} {
822
+ array get ::define
823
+ }
824
+
825
+ # @section Environment/Helpers
826
+
827
+ # @get-env name default
828
+ #
829
+ # If '$name' was specified on the command line, return it.
830
+ # Otherwise if '$name' was set in the environment, return it.
831
+ # Otherwise return '$default'.
832
+ #
833
+ proc get-env {name default} {
834
+ if {[dict exists $::autosetup(cmdline) $name]} {
835
+ return [dict get $::autosetup(cmdline) $name]
836
+ }
837
+ getenv $name $default
838
+ }
839
+
840
+ # @env-is-set name
841
+ #
842
+ # Returns 1 if '$name' was specified on the command line or in the environment.
843
+ # Note that an empty environment variable is not considered to be set.
844
+ #
845
+ proc env-is-set {name} {
846
+ if {[dict exists $::autosetup(cmdline) $name]} {
847
+ return 1
848
+ }
849
+ if {[getenv $name ""] ne ""} {
850
+ return 1
851
+ }
852
+ return 0
853
+ }
854
+
855
+ # @readfile filename ?default=""?
856
+ #
857
+ # Return the contents of the file, without the trailing newline.
858
+ # If the file doesn't exist or can't be read, returns '$default'.
859
+ #
860
+ proc readfile {filename {default_value ""}} {
861
+ set result $default_value
862
+ catch {
863
+ set f [open $filename]
864
+ set result [read -nonewline $f]
865
+ close $f
866
+ }
867
+ return $result
868
+ }
869
+
870
+ # @writefile filename value
871
+ #
872
+ # Creates the given file containing '$value'.
873
+ # Does not add an extra newline.
874
+ #
875
+ proc writefile {filename value} {
876
+ set f [open $filename w]
877
+ puts -nonewline $f $value
878
+ close $f
879
+ }
880
+
881
+ proc quote-if-needed {str} {
882
+ if {[string match {*[\" ]*} $str]} {
883
+ return \"[string map [list \" \\" \\ \\\\] $str]\"
884
+ }
885
+ return $str
886
+ }
887
+
888
+ proc quote-argv {argv} {
889
+ set args {}
890
+ foreach arg $argv {
891
+ lappend args [quote-if-needed $arg]
892
+ }
893
+ join $args
894
+ }
895
+
896
+ # @list-non-empty list
897
+ #
898
+ # Returns a copy of the given list with empty elements removed
899
+ proc list-non-empty {list} {
900
+ set result {}
901
+ foreach p $list {
902
+ if {$p ne ""} {
903
+ lappend result $p
904
+ }
905
+ }
906
+ return $result
907
+ }
908
+
909
+ # @section Paths, Searching
910
+
911
+ # @find-executable-path name
912
+ #
913
+ # Searches the path for an executable with the given name.
914
+ # Note that the name may include some parameters, e.g. 'cc -mbig-endian',
915
+ # in which case the parameters are ignored.
916
+ # Returns the full path to the executable if found, or "" if not found.
917
+ #
918
+ proc find-executable-path {name} {
919
+ # Ignore any parameters
920
+ set name [lindex $name 0]
921
+ # The empty string is never a valid executable
922
+ if {$name ne ""} {
923
+ foreach p [split-path] {
924
+ dputs "Looking for $name in $p"
925
+ set exec [file join $p $name]
926
+ if {[file-isexec $exec]} {
927
+ dputs "Found $name -> $exec"
928
+ return $exec
929
+ }
930
+ }
931
+ }
932
+ return {}
933
+ }
934
+
935
+ # @find-executable name
936
+ #
937
+ # Searches the path for an executable with the given name.
938
+ # Note that the name may include some parameters, e.g. 'cc -mbig-endian',
939
+ # in which case the parameters are ignored.
940
+ # Returns 1 if found, or 0 if not.
941
+ #
942
+ proc find-executable {name} {
943
+ if {[find-executable-path $name] eq {}} {
944
+ return 0
945
+ }
946
+ return 1
947
+ }
948
+
949
+ # @find-an-executable ?-required? name ...
950
+ #
951
+ # Given a list of possible executable names,
952
+ # searches for one of these on the path.
953
+ #
954
+ # Returns the name found, or "" if none found.
955
+ # If the first parameter is '-required', an error is generated
956
+ # if no executable is found.
957
+ #
958
+ proc find-an-executable {args} {
959
+ set required 0
960
+ if {[lindex $args 0] eq "-required"} {
961
+ set args [lrange $args 1 end]
962
+ incr required
963
+ }
964
+ foreach name $args {
965
+ if {[find-executable $name]} {
966
+ return $name
967
+ }
968
+ }
969
+ if {$required} {
970
+ if {[llength $args] == 1} {
971
+ user-error "failed to find: [join $args]"
972
+ } else {
973
+ user-error "failed to find one of: [join $args]"
974
+ }
975
+ }
976
+ return ""
977
+ }
978
+
979
+ # @section Logging, Messages and Errors
980
+
981
+ # @configlog msg
982
+ #
983
+ # Writes the given message to the configuration log, 'config.log'.
984
+ #
985
+ proc configlog {msg} {
986
+ if {![info exists ::autosetup(logfh)]} {
987
+ set ::autosetup(logfh) [open config.log w]
988
+ }
989
+ puts $::autosetup(logfh) $msg
990
+ }
991
+
992
+ # @msg-checking msg
993
+ #
994
+ # Writes the message with no newline to stdout.
995
+ #
996
+ proc msg-checking {msg} {
997
+ if {$::autosetup(msg-quiet) == 0} {
998
+ maybe-show-timestamp
999
+ puts -nonewline $msg
1000
+ set ::autosetup(msg-checking) 1
1001
+ }
1002
+ }
1003
+
1004
+ # @msg-result msg
1005
+ #
1006
+ # Writes the message to stdout.
1007
+ #
1008
+ proc msg-result {msg} {
1009
+ if {$::autosetup(msg-quiet) == 0} {
1010
+ maybe-show-timestamp
1011
+ puts $msg
1012
+ set ::autosetup(msg-checking) 0
1013
+ show-notices
1014
+ }
1015
+ }
1016
+
1017
+ # @msg-quiet command ...
1018
+ #
1019
+ # 'msg-quiet' evaluates it's arguments as a command with output
1020
+ # from 'msg-checking' and 'msg-result' suppressed.
1021
+ #
1022
+ # This is useful if a check needs to run a subcheck which isn't
1023
+ # of interest to the user.
1024
+ proc msg-quiet {args} {
1025
+ incr ::autosetup(msg-quiet)
1026
+ set rc [uplevel 1 $args]
1027
+ incr ::autosetup(msg-quiet) -1
1028
+ return $rc
1029
+ }
1030
+
1031
+ # Will be overridden by 'use misc'
1032
+ proc error-stacktrace {msg} {
1033
+ return $msg
1034
+ }
1035
+
1036
+ proc error-location {msg} {
1037
+ return $msg
1038
+ }
1039
+
1040
+ ##################################################################
1041
+ #
1042
+ # Debugging output
1043
+ #
1044
+ proc dputs {msg} {
1045
+ if {$::autosetup(debug)} {
1046
+ puts $msg
1047
+ }
1048
+ }
1049
+
1050
+ ##################################################################
1051
+ #
1052
+ # User and system warnings and errors
1053
+ #
1054
+ # Usage errors such as wrong command line options
1055
+
1056
+ # @user-error msg
1057
+ #
1058
+ # Indicate incorrect usage to the user, including if required components
1059
+ # or features are not found.
1060
+ # 'autosetup' exits with a non-zero return code.
1061
+ #
1062
+ proc user-error {msg} {
1063
+ show-notices
1064
+ puts stderr "Error: $msg"
1065
+ puts stderr "Try: '[file tail $::autosetup(exe)] --help' for options"
1066
+ exit 1
1067
+ }
1068
+
1069
+ # @user-notice msg
1070
+ #
1071
+ # Output the given message to stderr.
1072
+ #
1073
+ proc user-notice {msg} {
1074
+ lappend ::autosetup(notices) $msg
1075
+ }
1076
+
1077
+ # Incorrect usage in the auto.def file. Identify the location.
1078
+ proc autosetup-error {msg} {
1079
+ autosetup-full-error [error-location $msg]
1080
+ }
1081
+
1082
+ # Like autosetup-error, except $msg is the full error message.
1083
+ proc autosetup-full-error {msg} {
1084
+ show-notices
1085
+ puts stderr $msg
1086
+ exit 1
1087
+ }
1088
+
1089
+ proc show-notices {} {
1090
+ if {$::autosetup(msg-checking)} {
1091
+ puts ""
1092
+ set ::autosetup(msg-checking) 0
1093
+ }
1094
+ flush stdout
1095
+ if {[info exists ::autosetup(notices)]} {
1096
+ puts stderr [join $::autosetup(notices) \n]
1097
+ unset ::autosetup(notices)
1098
+ }
1099
+ }
1100
+
1101
+ proc maybe-show-timestamp {} {
1102
+ if {$::autosetup(msg-timing) && $::autosetup(msg-checking) == 0} {
1103
+ puts -nonewline [format {[%6.2f] } [expr {([clock millis] - $::autosetup(start)) % 10000 / 1000.0}]]
1104
+ }
1105
+ }
1106
+
1107
+ # @autosetup-require-version required
1108
+ #
1109
+ # Checks the current version of 'autosetup' against '$required'.
1110
+ # A fatal error is generated if the current version is less than that required.
1111
+ #
1112
+ proc autosetup-require-version {required} {
1113
+ if {[compare-versions $::autosetup(version) $required] < 0} {
1114
+ user-error "autosetup version $required is required, but this is $::autosetup(version)"
1115
+ }
1116
+ }
1117
+
1118
+ proc autosetup_version {} {
1119
+ return "autosetup v$::autosetup(version)"
1120
+ }
1121
+
1122
+ ##################################################################
1123
+ #
1124
+ # Directory/path handling
1125
+ #
1126
+
1127
+ proc realdir {dir} {
1128
+ set oldpwd [pwd]
1129
+ cd $dir
1130
+ set pwd [pwd]
1131
+ cd $oldpwd
1132
+ return $pwd
1133
+ }
1134
+
1135
+ # Follow symlinks until we get to something which is not a symlink
1136
+ proc realpath {path} {
1137
+ while {1} {
1138
+ if {[catch {
1139
+ set path [file readlink $path]
1140
+ }]} {
1141
+ # Not a link
1142
+ break
1143
+ }
1144
+ }
1145
+ return $path
1146
+ }
1147
+
1148
+ # Convert absolute path, $path into a path relative
1149
+ # to the given directory (or the current dir, if not given).
1150
+ #
1151
+ proc relative-path {path {pwd {}}} {
1152
+ set diff 0
1153
+ set same 0
1154
+ set newf {}
1155
+ set prefix {}
1156
+ set path [file-normalize $path]
1157
+ if {$pwd eq ""} {
1158
+ set pwd [pwd]
1159
+ } else {
1160
+ set pwd [file-normalize $pwd]
1161
+ }
1162
+
1163
+ if {$path eq $pwd} {
1164
+ return .
1165
+ }
1166
+
1167
+ # Try to make the filename relative to the current dir
1168
+ foreach p [split $pwd /] f [split $path /] {
1169
+ if {$p ne $f} {
1170
+ incr diff
1171
+ } elseif {!$diff} {
1172
+ incr same
1173
+ }
1174
+ if {$diff} {
1175
+ if {$p ne ""} {
1176
+ # Add .. for sibling or parent dir
1177
+ lappend prefix ..
1178
+ }
1179
+ if {$f ne ""} {
1180
+ lappend newf $f
1181
+ }
1182
+ }
1183
+ }
1184
+ if {$same == 1 || [llength $prefix] > 3} {
1185
+ return $path
1186
+ }
1187
+
1188
+ file join [join $prefix /] [join $newf /]
1189
+ }
1190
+
1191
+ # Add filename as a dependency to rerun autosetup
1192
+ # The name will be normalised (converted to a full path)
1193
+ #
1194
+ proc autosetup_add_dep {filename} {
1195
+ lappend ::autosetup(deps) [file-normalize $filename]
1196
+ }
1197
+
1198
+ # @section Modules Support
1199
+
1200
+ ##################################################################
1201
+ #
1202
+ # Library module support
1203
+ #
1204
+
1205
+ # @use module ...
1206
+ #
1207
+ # Load the given library modules.
1208
+ # e.g. 'use cc cc-shared'
1209
+ #
1210
+ # Note that module 'X' is implemented in either 'autosetup/X.tcl'
1211
+ # or 'autosetup/X/init.tcl'
1212
+ #
1213
+ # The latter form is useful for a complex module which requires additional
1214
+ # support file. In this form, '$::usedir' is set to the module directory
1215
+ # when it is loaded.
1216
+ #
1217
+ proc use {args} {
1218
+ global autosetup libmodule modsource
1219
+
1220
+ set dirs [list $autosetup(libdir)]
1221
+ if {[info exists autosetup(srcdir)]} {
1222
+ lappend dirs $autosetup(srcdir)/autosetup
1223
+ }
1224
+ foreach m $args {
1225
+ if {[info exists libmodule($m)]} {
1226
+ continue
1227
+ }
1228
+ set libmodule($m) 1
1229
+
1230
+ if {[info exists modsource(${m}.tcl)]} {
1231
+ autosetup_load_module $m eval $modsource(${m}.tcl)
1232
+ } else {
1233
+ set locs [list ${m}.tcl ${m}/init.tcl]
1234
+ set found 0
1235
+ foreach dir $dirs {
1236
+ foreach loc $locs {
1237
+ set source $dir/$loc
1238
+ if {[file exists $source]} {
1239
+ incr found
1240
+ break
1241
+ }
1242
+ }
1243
+ if {$found} {
1244
+ break
1245
+ }
1246
+ }
1247
+ if {$found} {
1248
+ # For the convenience of the "use" source, point to the directory
1249
+ # it is being loaded from
1250
+ set ::usedir [file dirname $source]
1251
+ autosetup_load_module $m source $source
1252
+ autosetup_add_dep $source
1253
+ } else {
1254
+ autosetup-error "use: No such module: $m"
1255
+ }
1256
+ }
1257
+ }
1258
+ }
1259
+
1260
+ proc autosetup_load_auto_modules {} {
1261
+ global autosetup modsource
1262
+ # First load any embedded auto modules
1263
+ foreach mod [array names modsource *.auto] {
1264
+ autosetup_load_module $mod eval $modsource($mod)
1265
+ }
1266
+ # Now any external auto modules
1267
+ foreach file [glob -nocomplain $autosetup(libdir)/*.auto $autosetup(libdir)/*/*.auto] {
1268
+ autosetup_load_module [file tail $file] source $file
1269
+ }
1270
+ }
1271
+
1272
+ # Load module source in the global scope by executing the given command
1273
+ proc autosetup_load_module {module args} {
1274
+ global autosetup
1275
+ set prev $autosetup(module)
1276
+ set autosetup(module) $module
1277
+
1278
+ if {[catch [list uplevel #0 $args] msg opts] ni {0 2 3}} {
1279
+ autosetup-full-error [error-dump $msg $opts $::autosetup(debug)]
1280
+ }
1281
+ set autosetup(module) $prev
1282
+ }
1283
+
1284
+ # Initial settings
1285
+ set autosetup(exe) $::argv0
1286
+ set autosetup(istcl) 1
1287
+ set autosetup(start) [clock millis]
1288
+ set autosetup(installed) 0
1289
+ set autosetup(sysinstall) 0
1290
+ set autosetup(msg-checking) 0
1291
+ set autosetup(msg-quiet) 0
1292
+ set autosetup(inittypes) {}
1293
+ set autosetup(module) autosetup
1294
+
1295
+ # Embedded modules are inserted below here
1296
+ set autosetup(installed) 1
1297
+ set autosetup(sysinstall) 0
1298
+ # ----- @module asciidoc-formatting.tcl -----
1299
+
1300
+ set modsource(asciidoc-formatting.tcl) {
1301
+ # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1302
+ # All rights reserved
1303
+
1304
+ # Module which provides text formatting
1305
+ # asciidoc format
1306
+
1307
+ use formatting
1308
+
1309
+ proc para {text} {
1310
+ regsub -all "\[ \t\n\]+" [string trim $text] " "
1311
+ }
1312
+ proc title {text} {
1313
+ underline [para $text] =
1314
+ nl
1315
+ }
1316
+ proc p {text} {
1317
+ puts [para $text]
1318
+ nl
1319
+ }
1320
+ proc code {text} {
1321
+ foreach line [parse_code_block $text] {
1322
+ puts " $line"
1323
+ }
1324
+ nl
1325
+ }
1326
+ proc codelines {lines} {
1327
+ foreach line $lines {
1328
+ puts " $line"
1329
+ }
1330
+ nl
1331
+ }
1332
+ proc nl {} {
1333
+ puts ""
1334
+ }
1335
+ proc underline {text char} {
1336
+ regexp "^(\[ \t\]*)(.*)" $text -> indent words
1337
+ puts $text
1338
+ puts $indent[string repeat $char [string length $words]]
1339
+ }
1340
+ proc section {text} {
1341
+ underline "[para $text]" -
1342
+ nl
1343
+ }
1344
+ proc subsection {text} {
1345
+ underline "$text" ~
1346
+ nl
1347
+ }
1348
+ proc bullet {text} {
1349
+ puts "* [para $text]"
1350
+ }
1351
+ proc indent {text} {
1352
+ puts " :: "
1353
+ puts [para $text]
1354
+ }
1355
+ proc defn {first args} {
1356
+ set sep ""
1357
+ if {$first ne ""} {
1358
+ puts "${first}::"
1359
+ } else {
1360
+ puts " :: "
1361
+ }
1362
+ set defn [string trim [join $args \n]]
1363
+ regsub -all "\n\n" $defn "\n ::\n" defn
1364
+ puts $defn
1365
+ }
1366
+ }
1367
+
1368
+ # ----- @module formatting.tcl -----
1369
+
1370
+ set modsource(formatting.tcl) {
1371
+ # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1372
+ # All rights reserved
1373
+
1374
+ # Module which provides common text formatting
1375
+
1376
+ # This is designed for documentation which looks like:
1377
+ # code {...}
1378
+ # or
1379
+ # code {
1380
+ # ...
1381
+ # ...
1382
+ # }
1383
+ # In the second case, we need to work out the indenting
1384
+ # and strip it from all lines but preserve the remaining indenting.
1385
+ # Note that all lines need to be indented with the same initial
1386
+ # spaces/tabs.
1387
+ #
1388
+ # Returns a list of lines with the indenting removed.
1389
+ #
1390
+ proc parse_code_block {text} {
1391
+ # If the text begins with newline, take the following text,
1392
+ # otherwise just return the original
1393
+ if {![regexp "^\n(.*)" $text -> text]} {
1394
+ return [list [string trim $text]]
1395
+ }
1396
+
1397
+ # And trip spaces off the end
1398
+ set text [string trimright $text]
1399
+
1400
+ set min 100
1401
+ # Examine each line to determine the minimum indent
1402
+ foreach line [split $text \n] {
1403
+ if {$line eq ""} {
1404
+ # Ignore empty lines for the indent calculation
1405
+ continue
1406
+ }
1407
+ regexp "^(\[ \t\]*)" $line -> indent
1408
+ set len [string length $indent]
1409
+ if {$len < $min} {
1410
+ set min $len
1411
+ }
1412
+ }
1413
+
1414
+ # Now make a list of lines with this indent removed
1415
+ set lines {}
1416
+ foreach line [split $text \n] {
1417
+ lappend lines [string range $line $min end]
1418
+ }
1419
+
1420
+ # Return the result
1421
+ return $lines
1422
+ }
1423
+ }
1424
+
1425
+ # ----- @module getopt.tcl -----
1426
+
1427
+ set modsource(getopt.tcl) {
1428
+ # Copyright (c) 2006 WorkWare Systems http://www.workware.net.au/
1429
+ # All rights reserved
1430
+
1431
+ # Simple getopt module
1432
+
1433
+ # Parse everything out of the argv list which looks like an option
1434
+ # Everything which doesn't look like an option, or is after --, is left unchanged
1435
+ # Understands --enable-xxx as a synonym for --xxx to enable the boolean option xxx.
1436
+ # Understands --disable-xxx to disable the boolean option xxx.
1437
+ #
1438
+ # The returned value is a dictionary keyed by option name
1439
+ # Each value is a list of {type value} ... where type is "bool" or "str".
1440
+ # The value for a boolean option is 0 or 1. The value of a string option is the value given.
1441
+ proc getopt {argvname} {
1442
+ upvar $argvname argv
1443
+ set nargv {}
1444
+
1445
+ set opts {}
1446
+
1447
+ for {set i 0} {$i < [llength $argv]} {incr i} {
1448
+ set arg [lindex $argv $i]
1449
+
1450
+ #dputs arg=$arg
1451
+
1452
+ if {$arg eq "--"} {
1453
+ # End of options
1454
+ incr i
1455
+ lappend nargv {*}[lrange $argv $i end]
1456
+ break
1457
+ }
1458
+
1459
+ if {[regexp {^--([^=][^=]+)=(.*)$} $arg -> name value]} {
1460
+ # --name=value
1461
+ dict lappend opts $name [list str $value]
1462
+ } elseif {[regexp {^--(enable-|disable-)?([^=]*)$} $arg -> prefix name]} {
1463
+ if {$prefix in {enable- ""}} {
1464
+ set value 1
1465
+ } else {
1466
+ set value 0
1467
+ }
1468
+ dict lappend opts $name [list bool $value]
1469
+ } else {
1470
+ lappend nargv $arg
1471
+ }
1472
+ }
1473
+
1474
+ #puts "getopt: argv=[join $argv] => [join $nargv]"
1475
+ #array set getopt $opts
1476
+ #parray getopt
1477
+
1478
+ set argv $nargv
1479
+
1480
+ return $opts
1481
+ }
1482
+ }
1483
+
1484
+ # ----- @module help.tcl -----
1485
+
1486
+ set modsource(help.tcl) {
1487
+ # Copyright (c) 2010 WorkWare Systems http://workware.net.au/
1488
+ # All rights reserved
1489
+
1490
+ # Module which provides usage, help and the command reference
1491
+
1492
+ proc autosetup_help {what} {
1493
+ use_pager
1494
+
1495
+ puts "Usage: [file tail $::autosetup(exe)] \[options\] \[settings\]\n"
1496
+ puts "This is [autosetup_version], a build environment \"autoconfigurator\""
1497
+ puts "See the documentation online at https://msteveb.github.io/autosetup/\n"
1498
+
1499
+ if {$what in {all local}} {
1500
+ # Need to load auto.def now
1501
+ if {[file exists $::autosetup(autodef)]} {
1502
+ # Load auto.def as module "auto.def"
1503
+ autosetup_load_module auto.def source $::autosetup(autodef)
1504
+ }
1505
+ if {$what eq "all"} {
1506
+ set what *
1507
+ } else {
1508
+ set what auto.def
1509
+ }
1510
+ } else {
1511
+ use $what
1512
+ puts "Options for module $what:"
1513
+ }
1514
+ options-show $what
1515
+ exit 0
1516
+ }
1517
+
1518
+ proc autosetup_show_license {} {
1519
+ global modsource autosetup
1520
+ use_pager
1521
+
1522
+ if {[info exists modsource(LICENSE)]} {
1523
+ puts $modsource(LICENSE)
1524
+ return
1525
+ }
1526
+ foreach dir [list $autosetup(libdir) $autosetup(srcdir)] {
1527
+ set path [file join $dir LICENSE]
1528
+ if {[file exists $path]} {
1529
+ puts [readfile $path]
1530
+ return
1531
+ }
1532
+ }
1533
+ puts "LICENSE not found"
1534
+ }
1535
+
1536
+ # If not already paged and stdout is a tty, pipe the output through the pager
1537
+ # This is done by reinvoking autosetup with --nopager added
1538
+ proc use_pager {} {
1539
+ if {![opt-bool nopager] && [getenv PAGER ""] ne "" && [isatty? stdin] && [isatty? stdout]} {
1540
+ if {[catch {
1541
+ exec [info nameofexecutable] $::argv0 --nopager {*}$::argv |& {*}[getenv PAGER] >@stdout <@stdin 2>@stderr
1542
+ } msg opts] == 1} {
1543
+ if {[dict get $opts -errorcode] eq "NONE"} {
1544
+ # an internal/exec error
1545
+ puts stderr $msg
1546
+ exit 1
1547
+ }
1548
+ }
1549
+ exit 0
1550
+ }
1551
+ }
1552
+
1553
+ # Outputs the autosetup references in one of several formats
1554
+ proc autosetup_reference {{type text}} {
1555
+
1556
+ use_pager
1557
+
1558
+ switch -glob -- $type {
1559
+ wiki {use wiki-formatting}
1560
+ ascii* {use asciidoc-formatting}
1561
+ md - markdown {use markdown-formatting}
1562
+ default {use text-formatting}
1563
+ }
1564
+
1565
+ title "[autosetup_version] -- Command Reference"
1566
+
1567
+ section {Introduction}
1568
+
1569
+ p {
1570
+ See https://msteveb.github.io/autosetup/ for the online documentation for 'autosetup'.
1571
+ This documentation can also be accessed locally with `autosetup --ref`.
1572
+ }
1573
+
1574
+ p {
1575
+ 'autosetup' provides a number of built-in commands which
1576
+ are documented below. These may be used from 'auto.def' to test
1577
+ for features, define variables, create files from templates and
1578
+ other similar actions.
1579
+ }
1580
+
1581
+ automf_command_reference
1582
+
1583
+ exit 0
1584
+ }
1585
+
1586
+ proc autosetup_output_block {type lines} {
1587
+ if {[llength $lines]} {
1588
+ switch $type {
1589
+ section {
1590
+ section $lines
1591
+ }
1592
+ subsection {
1593
+ subsection $lines
1594
+ }
1595
+ code {
1596
+ codelines $lines
1597
+ }
1598
+ p {
1599
+ p [join $lines]
1600
+ }
1601
+ list {
1602
+ foreach line $lines {
1603
+ bullet $line
1604
+ }
1605
+ nl
1606
+ }
1607
+ }
1608
+ }
1609
+ }
1610
+
1611
+ # Generate a command reference from inline documentation
1612
+ proc automf_command_reference {} {
1613
+ lappend files $::autosetup(prog)
1614
+ lappend files {*}[lsort [glob -nocomplain $::autosetup(libdir)/*.tcl]]
1615
+
1616
+ # We want to process all non-module files before module files
1617
+ # and then modules in alphabetical order.
1618
+ # So examine all files and extract docs into doc($modulename) and doc(_core_)
1619
+ #
1620
+ # Each entry is a list of {type data} where $type is one of: section, subsection, code, list, p
1621
+ # and $data is a string for section, subsection or a list of text lines for other types.
1622
+
1623
+ # XXX: Should commands be in alphabetical order too? Currently they are in file order.
1624
+
1625
+ set doc(_core_) {}
1626
+ lappend doc(_core_) [list section "Core Commands"]
1627
+
1628
+ foreach file $files {
1629
+ set modulename [file rootname [file tail $file]]
1630
+ set current _core_
1631
+ set f [open $file]
1632
+ while {![eof $f]} {
1633
+ set line [gets $f]
1634
+
1635
+ if {[regexp {^#.*@section (.*)$} $line -> section]} {
1636
+ lappend doc($current) [list section $section]
1637
+ continue
1638
+ }
1639
+
1640
+ # Find embedded module names
1641
+ if {[regexp {^#.*@module ([^ ]*)} $line -> modulename]} {
1642
+ continue
1643
+ }
1644
+
1645
+ # Find lines starting with "# @*" and continuing through the remaining comment lines
1646
+ if {![regexp {^# @(.*)} $line -> cmd]} {
1647
+ continue
1648
+ }
1649
+
1650
+ # Synopsis or command?
1651
+ if {$cmd eq "synopsis:"} {
1652
+ set current $modulename
1653
+ lappend doc($current) [list section "Module: $modulename"]
1654
+ } else {
1655
+ lappend doc($current) [list subsection $cmd]
1656
+ }
1657
+
1658
+ set lines {}
1659
+ set type p
1660
+
1661
+ # Now the description
1662
+ while {![eof $f]} {
1663
+ set line [gets $f]
1664
+
1665
+ if {![regexp {^#(#)? ?(.*)} $line -> hash cmd]} {
1666
+ break
1667
+ }
1668
+ if {$hash eq "#"} {
1669
+ set t code
1670
+ } elseif {[regexp {^- (.*)} $cmd -> cmd]} {
1671
+ set t list
1672
+ } else {
1673
+ set t p
1674
+ }
1675
+
1676
+ #puts "hash=$hash, oldhash=$oldhash, lines=[llength $lines], cmd=$cmd"
1677
+
1678
+ if {$t ne $type || $cmd eq ""} {
1679
+ # Finish the current block
1680
+ lappend doc($current) [list $type $lines]
1681
+ set lines {}
1682
+ set type $t
1683
+ }
1684
+ if {$cmd ne ""} {
1685
+ lappend lines $cmd
1686
+ }
1687
+ }
1688
+
1689
+ lappend doc($current) [list $type $lines]
1690
+ }
1691
+ close $f
1692
+ }
1693
+
1694
+ # Now format and output the results
1695
+
1696
+ # _core_ will sort first
1697
+ foreach module [lsort [array names doc]] {
1698
+ foreach item $doc($module) {
1699
+ autosetup_output_block {*}$item
1700
+ }
1701
+ }
1702
+ }
1703
+ }
1704
+
1705
+ # ----- @module init.tcl -----
1706
+
1707
+ set modsource(init.tcl) {
1708
+ # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1709
+ # All rights reserved
1710
+
1711
+ # Module to help create auto.def and configure
1712
+
1713
+ proc autosetup_init {type} {
1714
+ set help 0
1715
+ if {$type in {? help}} {
1716
+ incr help
1717
+ } elseif {![dict exists $::autosetup(inittypes) $type]} {
1718
+ puts "Unknown type, --init=$type"
1719
+ incr help
1720
+ }
1721
+ if {$help} {
1722
+ puts "Use one of the following types (e.g. --init=make)\n"
1723
+ foreach type [lsort [dict keys $::autosetup(inittypes)]] {
1724
+ lassign [dict get $::autosetup(inittypes) $type] desc
1725
+ # XXX: Use the options-show code to wrap the description
1726
+ puts [format "%-10s %s" $type $desc]
1727
+ }
1728
+ return
1729
+ }
1730
+ lassign [dict get $::autosetup(inittypes) $type] desc script
1731
+
1732
+ puts "Initialising $type: $desc\n"
1733
+
1734
+ # All initialisations happens in the top level srcdir
1735
+ cd $::autosetup(srcdir)
1736
+
1737
+ uplevel #0 $script
1738
+ }
1739
+
1740
+ proc autosetup_add_init_type {type desc script} {
1741
+ dict set ::autosetup(inittypes) $type [list $desc $script]
1742
+ }
1743
+
1744
+ # This is for in creating build-system init scripts
1745
+ #
1746
+ # If the file doesn't exist, create it containing $contents
1747
+ # If the file does exist, only overwrite if --force is specified.
1748
+ #
1749
+ proc autosetup_check_create {filename contents} {
1750
+ if {[file exists $filename]} {
1751
+ if {!$::autosetup(force)} {
1752
+ puts "I see $filename already exists."
1753
+ return
1754
+ } else {
1755
+ puts "I will overwrite the existing $filename because you used --force."
1756
+ }
1757
+ } else {
1758
+ puts "I don't see $filename, so I will create it."
1759
+ }
1760
+ writefile $filename $contents
1761
+ }
1762
+ }
1763
+
1764
+ # ----- @module install.tcl -----
1765
+
1766
+ set modsource(install.tcl) {
1767
+ # Copyright (c) 2006-2010 WorkWare Systems http://www.workware.net.au/
1768
+ # All rights reserved
1769
+
1770
+ # Module which can install autosetup
1771
+
1772
+ # autosetup(installed)=1 means that autosetup is not running from source
1773
+ # autosetup(sysinstall)=1 means that autosetup is running from a sysinstall version
1774
+ # shared=1 means that we are trying to do a sysinstall. This is only possible from the development source.
1775
+
1776
+ proc autosetup_install {dir {shared 0}} {
1777
+ global autosetup
1778
+ if {$shared} {
1779
+ if {$autosetup(installed) || $autosetup(sysinstall)} {
1780
+ user-error "Can only --sysinstall from development sources"
1781
+ }
1782
+ } elseif {$autosetup(installed) && !$autosetup(sysinstall)} {
1783
+ user-error "Can't --install from project install"
1784
+ }
1785
+
1786
+ if {$autosetup(sysinstall)} {
1787
+ # This is the sysinstall version, so install just uses references
1788
+ cd $dir
1789
+
1790
+ puts "[autosetup_version] creating configure to use system-installed autosetup"
1791
+ autosetup_create_configure 1
1792
+ puts "Creating autosetup/README.autosetup"
1793
+ file mkdir autosetup
1794
+ autosetup_install_readme autosetup/README.autosetup 1
1795
+ return
1796
+ }
1797
+
1798
+ if {[catch {
1799
+ if {$shared} {
1800
+ set target $dir/bin/autosetup
1801
+ set installedas $target
1802
+ } else {
1803
+ if {$dir eq "."} {
1804
+ set installedas autosetup
1805
+ } else {
1806
+ set installedas $dir/autosetup
1807
+ }
1808
+ cd $dir
1809
+ file mkdir autosetup
1810
+ set target autosetup/autosetup
1811
+ }
1812
+ set targetdir [file dirname $target]
1813
+ file mkdir $targetdir
1814
+
1815
+ set f [open $target w]
1816
+
1817
+ set publicmodules {}
1818
+
1819
+ # First the main script, but only up until "CUT HERE"
1820
+ set in [open $autosetup(dir)/autosetup]
1821
+ while {[gets $in buf] >= 0} {
1822
+ if {$buf ne "##-- CUT HERE --##"} {
1823
+ puts $f $buf
1824
+ continue
1825
+ }
1826
+
1827
+ # Insert the static modules here
1828
+ # i.e. those which don't contain @synopsis:
1829
+ # All modules are inserted if $shared is set
1830
+ puts $f "set autosetup(installed) 1"
1831
+ puts $f "set autosetup(sysinstall) $shared"
1832
+ foreach file [lsort [glob $autosetup(libdir)/*.{tcl,auto}]] {
1833
+ set modname [file tail $file]
1834
+ set ext [file ext $modname]
1835
+ set buf [readfile $file]
1836
+ if {!$shared} {
1837
+ if {$ext eq ".auto" || [string match "*\n# @synopsis:*" $buf]} {
1838
+ lappend publicmodules $file
1839
+ continue
1840
+ }
1841
+ }
1842
+ dputs "install: importing lib/[file tail $file]"
1843
+ puts $f "# ----- @module $modname -----"
1844
+ puts $f "\nset modsource($modname) \{"
1845
+ puts $f $buf
1846
+ puts $f "\}\n"
1847
+ }
1848
+ if {$shared} {
1849
+ foreach {srcname destname} [list $autosetup(libdir)/README.autosetup-lib README.autosetup \
1850
+ $autosetup(srcdir)/LICENSE LICENSE] {
1851
+ dputs "install: importing $srcname as $destname"
1852
+ puts $f "\nset modsource($destname) \\\n[list [readfile $srcname]\n]\n"
1853
+ }
1854
+ }
1855
+ }
1856
+ close $in
1857
+ close $f
1858
+ catch {exec chmod 755 $target}
1859
+
1860
+ set installfiles {autosetup-config.guess autosetup-config.sub autosetup-test-tclsh}
1861
+ set removefiles {}
1862
+
1863
+ if {!$shared} {
1864
+ autosetup_install_readme $targetdir/README.autosetup 0
1865
+
1866
+ # Install public modules
1867
+ foreach file $publicmodules {
1868
+ set tail [file tail $file]
1869
+ autosetup_install_file $file $targetdir/$tail
1870
+ }
1871
+ lappend installfiles jimsh0.c autosetup-find-tclsh LICENSE
1872
+ lappend removefiles config.guess config.sub test-tclsh find-tclsh
1873
+ } else {
1874
+ lappend installfiles {sys-find-tclsh autosetup-find-tclsh}
1875
+ }
1876
+
1877
+ # Install support files
1878
+ foreach fileinfo $installfiles {
1879
+ if {[llength $fileinfo] == 2} {
1880
+ lassign $fileinfo source dest
1881
+ } else {
1882
+ lassign $fileinfo source
1883
+ set dest $source
1884
+ }
1885
+ autosetup_install_file $autosetup(dir)/$source $targetdir/$dest
1886
+ }
1887
+
1888
+ # Remove obsolete files
1889
+ foreach file $removefiles {
1890
+ if {[file exists $targetdir/$file]} {
1891
+ file delete $targetdir/$file
1892
+ }
1893
+ }
1894
+ } error]} {
1895
+ user-error "Failed to install autosetup: $error"
1896
+ }
1897
+ if {$shared} {
1898
+ set type "system"
1899
+ } else {
1900
+ set type "local"
1901
+ }
1902
+ puts "Installed $type [autosetup_version] to $installedas"
1903
+
1904
+ if {!$shared} {
1905
+ # Now create 'configure' if necessary
1906
+ autosetup_create_configure 0
1907
+ }
1908
+ }
1909
+
1910
+ proc autosetup_create_configure {shared} {
1911
+ if {[file exists configure]} {
1912
+ if {!$::autosetup(force)} {
1913
+ # Could this be an autosetup configure?
1914
+ if {![string match "*\nWRAPPER=*" [readfile configure]]} {
1915
+ puts "I see configure, but not created by autosetup, so I won't overwrite it."
1916
+ puts "Remove it or use --force to overwrite."
1917
+ return
1918
+ }
1919
+ } else {
1920
+ puts "I will overwrite the existing configure because you used --force."
1921
+ }
1922
+ } else {
1923
+ puts "I don't see configure, so I will create it."
1924
+ }
1925
+ if {$shared} {
1926
+ writefile configure \
1927
+ {#!/bin/sh
1928
+ WRAPPER="$0"; export WRAPPER; "autosetup" "$@"
1929
+ }
1930
+ } else {
1931
+ writefile configure \
1932
+ {#!/bin/sh
1933
+ dir="`dirname "$0"`/autosetup"
1934
+ #@@INITCHECK@@#
1935
+ WRAPPER="$0"; export WRAPPER; exec "`"$dir/autosetup-find-tclsh"`" "$dir/autosetup" "$@"
1936
+ }
1937
+ }
1938
+ catch {exec chmod 755 configure}
1939
+ }
1940
+
1941
+ # Append the contents of $file to filehandle $f
1942
+ proc autosetup_install_append {f file} {
1943
+ dputs "install: include $file"
1944
+ set in [open $file]
1945
+ puts $f [read $in]
1946
+ close $in
1947
+ }
1948
+
1949
+ proc autosetup_install_file {source target} {
1950
+ dputs "install: $source => $target"
1951
+ if {![file exists $source]} {
1952
+ error "Missing installation file '$source'"
1953
+ }
1954
+ writefile $target [readfile $source]\n
1955
+ # If possible, copy the file mode
1956
+ file stat $source stat
1957
+ set mode [format %o [expr {$stat(mode) & 0x1ff}]]
1958
+ catch {exec chmod $mode $target}
1959
+ }
1960
+
1961
+ proc autosetup_install_readme {target sysinstall} {
1962
+ set readme "README.autosetup created by [autosetup_version]\n\n"
1963
+ if {$sysinstall} {
1964
+ append readme \
1965
+ {This is the autosetup directory for a system install of autosetup.
1966
+ Loadable modules can be added here.
1967
+ }
1968
+ } else {
1969
+ append readme \
1970
+ {This is the autosetup directory for a local install of autosetup.
1971
+ It contains autosetup, support files and loadable modules.
1972
+ }
1973
+ }
1974
+
1975
+ append readme {
1976
+ *.tcl files in this directory are optional modules which
1977
+ can be loaded with the 'use' directive.
1978
+
1979
+ *.auto files in this directory are auto-loaded.
1980
+
1981
+ For more information, see https://msteveb.github.io/autosetup/
1982
+ }
1983
+ dputs "install: autosetup/README.autosetup"
1984
+ writefile $target $readme
1985
+ }
1986
+ }
1987
+
1988
+ # ----- @module markdown-formatting.tcl -----
1989
+
1990
+ set modsource(markdown-formatting.tcl) {
1991
+ # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
1992
+ # All rights reserved
1993
+
1994
+ # Module which provides text formatting
1995
+ # markdown format (kramdown syntax)
1996
+
1997
+ use formatting
1998
+
1999
+ proc para {text} {
2000
+ regsub -all "\[ \t\n\]+" [string trim $text] " " text
2001
+ regsub -all {([^a-zA-Z])'([^']*)'} $text {\1**`\2`**} text
2002
+ regsub -all {^'([^']*)'} $text {**`\1`**} text
2003
+ regsub -all {(http[^ \t\n]*)} $text {[\1](\1)} text
2004
+ return $text
2005
+ }
2006
+ proc title {text} {
2007
+ underline [para $text] =
2008
+ nl
2009
+ }
2010
+ proc p {text} {
2011
+ puts [para $text]
2012
+ nl
2013
+ }
2014
+ proc codelines {lines} {
2015
+ puts "~~~~~~~~~~~~"
2016
+ foreach line $lines {
2017
+ puts $line
2018
+ }
2019
+ puts "~~~~~~~~~~~~"
2020
+ nl
2021
+ }
2022
+ proc code {text} {
2023
+ puts "~~~~~~~~~~~~"
2024
+ foreach line [parse_code_block $text] {
2025
+ puts $line
2026
+ }
2027
+ puts "~~~~~~~~~~~~"
2028
+ nl
2029
+ }
2030
+ proc nl {} {
2031
+ puts ""
2032
+ }
2033
+ proc underline {text char} {
2034
+ regexp "^(\[ \t\]*)(.*)" $text -> indent words
2035
+ puts $text
2036
+ puts $indent[string repeat $char [string length $words]]
2037
+ }
2038
+ proc section {text} {
2039
+ underline "[para $text]" -
2040
+ nl
2041
+ }
2042
+ proc subsection {text} {
2043
+ puts "### `$text`"
2044
+ nl
2045
+ }
2046
+ proc bullet {text} {
2047
+ puts "* [para $text]"
2048
+ }
2049
+ proc defn {first args} {
2050
+ puts "^"
2051
+ set defn [string trim [join $args \n]]
2052
+ if {$first ne ""} {
2053
+ puts "**${first}**"
2054
+ puts -nonewline ": "
2055
+ regsub -all "\n\n" $defn "\n: " defn
2056
+ }
2057
+ puts "$defn"
2058
+ }
2059
+ }
2060
+
2061
+ # ----- @module misc.tcl -----
2062
+
2063
+ set modsource(misc.tcl) {
2064
+ # Copyright (c) 2007-2010 WorkWare Systems http://www.workware.net.au/
2065
+ # All rights reserved
2066
+
2067
+ # Module containing misc procs useful to modules
2068
+ # Largely for platform compatibility
2069
+
2070
+ set autosetup(istcl) [info exists ::tcl_library]
2071
+ set autosetup(iswin) [string equal windows $tcl_platform(platform)]
2072
+
2073
+ if {$autosetup(iswin)} {
2074
+ # mingw/windows separates $PATH with semicolons
2075
+ # and doesn't have an executable bit
2076
+ proc split-path {} {
2077
+ split [getenv PATH .] {;}
2078
+ }
2079
+ proc file-isexec {exec} {
2080
+ # Basic test for windows. We ignore .bat
2081
+ if {[file isfile $exec] || [file isfile $exec.exe]} {
2082
+ return 1
2083
+ }
2084
+ return 0
2085
+ }
2086
+ } else {
2087
+ # unix separates $PATH with colons and has and executable bit
2088
+ proc split-path {} {
2089
+ split [getenv PATH .] :
2090
+ }
2091
+ proc file-isexec {exec} {
2092
+ file executable $exec
2093
+ }
2094
+ }
2095
+
2096
+ # Assume that exec can return stdout and stderr
2097
+ proc exec-with-stderr {args} {
2098
+ exec {*}$args 2>@1
2099
+ }
2100
+
2101
+ if {$autosetup(istcl)} {
2102
+ # Tcl doesn't have the env command
2103
+ proc getenv {name args} {
2104
+ if {[info exists ::env($name)]} {
2105
+ return $::env($name)
2106
+ }
2107
+ if {[llength $args]} {
2108
+ return [lindex $args 0]
2109
+ }
2110
+ return -code error "environment variable \"$name\" does not exist"
2111
+ }
2112
+ proc isatty? {channel} {
2113
+ dict exists [fconfigure $channel] -xchar
2114
+ }
2115
+ # Jim-compatible stacktrace using info frame
2116
+ proc stacktrace {} {
2117
+ set stacktrace {}
2118
+ # 2 to skip the current frame
2119
+ for {set i 2} {$i < [info frame]} {incr i} {
2120
+ set frame [info frame -$i]
2121
+ if {[dict exists $frame file]} {
2122
+ # We don't need proc, so use ""
2123
+ lappend stacktrace "" [dict get $frame file] [dict get $frame line]
2124
+ }
2125
+ }
2126
+ return $stacktrace
2127
+ }
2128
+ } else {
2129
+ if {$autosetup(iswin)} {
2130
+ # On Windows, backslash convert all environment variables
2131
+ # (Assume that Tcl does this for us)
2132
+ proc getenv {name args} {
2133
+ string map {\\ /} [env $name {*}$args]
2134
+ }
2135
+ } else {
2136
+ # Jim on unix is simple
2137
+ alias getenv env
2138
+ }
2139
+ proc isatty? {channel} {
2140
+ set tty 0
2141
+ catch {
2142
+ # isatty is a recent addition to Jim Tcl
2143
+ set tty [$channel isatty]
2144
+ }
2145
+ return $tty
2146
+ }
2147
+ }
2148
+
2149
+ # In case 'file normalize' doesn't exist
2150
+ #
2151
+ proc file-normalize {path} {
2152
+ if {[catch {file normalize $path} result]} {
2153
+ if {$path eq ""} {
2154
+ return ""
2155
+ }
2156
+ set oldpwd [pwd]
2157
+ if {[file isdir $path]} {
2158
+ cd $path
2159
+ set result [pwd]
2160
+ } else {
2161
+ cd [file dirname $path]
2162
+ set result [file join [pwd] [file tail $path]]
2163
+ }
2164
+ cd $oldpwd
2165
+ }
2166
+ return $result
2167
+ }
2168
+
2169
+ # If everything is working properly, the only errors which occur
2170
+ # should be generated in user code (e.g. auto.def).
2171
+ # By default, we only want to show the error location in user code.
2172
+ # We use [info frame] to achieve this, but it works differently on Tcl and Jim.
2173
+ #
2174
+ # This is designed to be called for incorrect usage in auto.def, via autosetup-error
2175
+ #
2176
+ proc error-location {msg} {
2177
+ if {$::autosetup(debug)} {
2178
+ return -code error $msg
2179
+ }
2180
+ # Search back through the stack trace for the first error in a .def file
2181
+ foreach {p f l} [stacktrace] {
2182
+ if {[string match *.def $f]} {
2183
+ return "[relative-path $f]:$l: Error: $msg"
2184
+ }
2185
+ #puts "Skipping $f:$l"
2186
+ }
2187
+ return $msg
2188
+ }
2189
+
2190
+ # If everything is working properly, the only errors which occur
2191
+ # should be generated in user code (e.g. auto.def).
2192
+ # By default, we only want to show the error location in user code.
2193
+ # We use [info frame] to achieve this, but it works differently on Tcl and Jim.
2194
+ #
2195
+ # This is designed to be called for incorrect usage in auto.def, via autosetup-error
2196
+ #
2197
+ proc error-stacktrace {msg} {
2198
+ if {$::autosetup(debug)} {
2199
+ return -code error $msg
2200
+ }
2201
+ # Search back through the stack trace for the first error in a .def file
2202
+ for {set i 1} {$i < [info level]} {incr i} {
2203
+ if {$::autosetup(istcl)} {
2204
+ array set info [info frame -$i]
2205
+ } else {
2206
+ lassign [info frame -$i] info(caller) info(file) info(line)
2207
+ }
2208
+ if {[string match *.def $info(file)]} {
2209
+ return "[relative-path $info(file)]:$info(line): Error: $msg"
2210
+ }
2211
+ #puts "Skipping $info(file):$info(line)"
2212
+ }
2213
+ return $msg
2214
+ }
2215
+
2216
+ # Given the return from [catch {...} msg opts], returns an appropriate
2217
+ # error message. A nice one for Jim and a less-nice one for Tcl.
2218
+ # If 'fulltrace' is set, a full stack trace is provided.
2219
+ # Otherwise a simple message is provided.
2220
+ #
2221
+ # This is designed for developer errors, e.g. in module code or auto.def code
2222
+ #
2223
+ #
2224
+ proc error-dump {msg opts fulltrace} {
2225
+ if {$::autosetup(istcl)} {
2226
+ if {$fulltrace} {
2227
+ return "Error: [dict get $opts -errorinfo]"
2228
+ } else {
2229
+ return "Error: $msg"
2230
+ }
2231
+ } else {
2232
+ lassign $opts(-errorinfo) p f l
2233
+ if {$f ne ""} {
2234
+ set result "$f:$l: Error: "
2235
+ }
2236
+ append result "$msg\n"
2237
+ if {$fulltrace} {
2238
+ append result [stackdump $opts(-errorinfo)]
2239
+ }
2240
+
2241
+ # Remove the trailing newline
2242
+ string trim $result
2243
+ }
2244
+ }
2245
+ }
2246
+
2247
+ # ----- @module text-formatting.tcl -----
2248
+
2249
+ set modsource(text-formatting.tcl) {
2250
+ # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
2251
+ # All rights reserved
2252
+
2253
+ # Module which provides text formatting
2254
+
2255
+ use formatting
2256
+
2257
+ proc wordwrap {text length {firstprefix ""} {nextprefix ""}} {
2258
+ set len 0
2259
+ set space $firstprefix
2260
+
2261
+ foreach word [split $text] {
2262
+ set word [string trim $word]
2263
+ if {$word eq ""} {
2264
+ continue
2265
+ }
2266
+ if {[info exists partial]} {
2267
+ append partial " " $word
2268
+ if {[string first $quote $word] < 0} {
2269
+ # Haven't found end of quoted word
2270
+ continue
2271
+ }
2272
+ # Finished quoted word
2273
+ set word $partial
2274
+ unset partial
2275
+ unset quote
2276
+ } else {
2277
+ set quote [string index $word 0]
2278
+ if {$quote in {' *}} {
2279
+ if {[string first $quote $word 1] < 0} {
2280
+ # Haven't found end of quoted word
2281
+ # Not a whole word.
2282
+ set first [string index $word 0]
2283
+ # Start of quoted word
2284
+ set partial $word
2285
+ continue
2286
+ }
2287
+ }
2288
+ }
2289
+
2290
+ if {$len && [string length $space$word] + $len >= $length} {
2291
+ puts ""
2292
+ set len 0
2293
+ set space $nextprefix
2294
+ }
2295
+ incr len [string length $space$word]
2296
+
2297
+ # Use man-page conventions for highlighting 'quoted' and *quoted*
2298
+ # single words.
2299
+ # Use x^Hx for *bold* and _^Hx for 'underline'.
2300
+ #
2301
+ # less and more will both understand this.
2302
+ # Pipe through 'col -b' to remove them.
2303
+ if {[regexp {^'(.*)'(.*)} $word -> quoted after]} {
2304
+ set quoted [string map {~ " "} $quoted]
2305
+ regsub -all . $quoted "&\b&" quoted
2306
+ set word $quoted$after
2307
+ } elseif {[regexp {^[*](.*)[*](.*)} $word -> quoted after]} {
2308
+ set quoted [string map {~ " "} $quoted]
2309
+ regsub -all . $quoted "_\b&" quoted
2310
+ set word $quoted$after
2311
+ }
2312
+ puts -nonewline $space$word
2313
+ set space " "
2314
+ }
2315
+ if {[info exists partial]} {
2316
+ # Missing end of quote
2317
+ puts -nonewline $space$partial
2318
+ }
2319
+ if {$len} {
2320
+ puts ""
2321
+ }
2322
+ }
2323
+ proc title {text} {
2324
+ underline [string trim $text] =
2325
+ nl
2326
+ }
2327
+ proc p {text} {
2328
+ wordwrap $text 80
2329
+ nl
2330
+ }
2331
+ proc codelines {lines} {
2332
+ foreach line $lines {
2333
+ puts " $line"
2334
+ }
2335
+ nl
2336
+ }
2337
+ proc nl {} {
2338
+ puts ""
2339
+ }
2340
+ proc underline {text char} {
2341
+ regexp "^(\[ \t\]*)(.*)" $text -> indent words
2342
+ puts $text
2343
+ puts $indent[string repeat $char [string length $words]]
2344
+ }
2345
+ proc section {text} {
2346
+ underline "[string trim $text]" -
2347
+ nl
2348
+ }
2349
+ proc subsection {text} {
2350
+ underline "$text" ~
2351
+ nl
2352
+ }
2353
+ proc bullet {text} {
2354
+ wordwrap $text 76 " * " " "
2355
+ }
2356
+ proc indent {text} {
2357
+ wordwrap $text 76 " " " "
2358
+ }
2359
+ proc defn {first args} {
2360
+ if {$first ne ""} {
2361
+ underline " $first" ~
2362
+ }
2363
+ foreach p $args {
2364
+ if {$p ne ""} {
2365
+ indent $p
2366
+ }
2367
+ }
2368
+ }
2369
+ }
2370
+
2371
+ # ----- @module util.tcl -----
2372
+
2373
+ set modsource(util.tcl) {
2374
+ # Copyright (c) 2012 WorkWare Systems http://www.workware.net.au/
2375
+ # All rights reserved
2376
+
2377
+ # Module which contains miscellaneous utility functions
2378
+
2379
+ # @section Utilities
2380
+
2381
+ # @compare-versions version1 version2
2382
+ #
2383
+ # Versions are of the form 'a.b.c' (may be any number of numeric components)
2384
+ #
2385
+ # Compares the two versions and returns:
2386
+ ## -1 if v1 < v2
2387
+ ## 0 if v1 == v2
2388
+ ## 1 if v1 > v2
2389
+ #
2390
+ # If one version has fewer components than the other, 0 is substituted to the right. e.g.
2391
+ ## 0.2 < 0.3
2392
+ ## 0.2.5 > 0.2
2393
+ ## 1.1 == 1.1.0
2394
+ #
2395
+ proc compare-versions {v1 v2} {
2396
+ foreach c1 [split $v1 .] c2 [split $v2 .] {
2397
+ if {$c1 eq ""} {
2398
+ set c1 0
2399
+ }
2400
+ if {$c2 eq ""} {
2401
+ set c2 0
2402
+ }
2403
+ if {$c1 < $c2} {
2404
+ return -1
2405
+ }
2406
+ if {$c1 > $c2} {
2407
+ return 1
2408
+ }
2409
+ }
2410
+ return 0
2411
+ }
2412
+
2413
+ # @suffix suf list
2414
+ #
2415
+ # Takes a list and returns a new list with '$suf' appended
2416
+ # to each element
2417
+ #
2418
+ ## suffix .c {a b c} => {a.c b.c c.c}
2419
+ #
2420
+ proc suffix {suf list} {
2421
+ set result {}
2422
+ foreach p $list {
2423
+ lappend result $p$suf
2424
+ }
2425
+ return $result
2426
+ }
2427
+
2428
+ # @prefix pre list
2429
+ #
2430
+ # Takes a list and returns a new list with '$pre' prepended
2431
+ # to each element
2432
+ #
2433
+ ## prefix jim- {a.c b.c} => {jim-a.c jim-b.c}
2434
+ #
2435
+ proc prefix {pre list} {
2436
+ set result {}
2437
+ foreach p $list {
2438
+ lappend result $pre$p
2439
+ }
2440
+ return $result
2441
+ }
2442
+
2443
+ # @lpop list
2444
+ #
2445
+ # Removes the last entry from the given list and returns it.
2446
+ proc lpop {listname} {
2447
+ upvar $listname list
2448
+ set val [lindex $list end]
2449
+ set list [lrange $list 0 end-1]
2450
+ return $val
2451
+ }
2452
+ }
2453
+
2454
+ # ----- @module wiki-formatting.tcl -----
2455
+
2456
+ set modsource(wiki-formatting.tcl) {
2457
+ # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
2458
+ # All rights reserved
2459
+
2460
+ # Module which provides text formatting
2461
+ # wiki.tcl.tk format output
2462
+
2463
+ use formatting
2464
+
2465
+ proc joinlines {text} {
2466
+ set lines {}
2467
+ foreach l [split [string trim $text] \n] {
2468
+ lappend lines [string trim $l]
2469
+ }
2470
+ join $lines
2471
+ }
2472
+ proc p {text} {
2473
+ puts [joinlines $text]
2474
+ puts ""
2475
+ }
2476
+ proc title {text} {
2477
+ puts "*** [joinlines $text] ***"
2478
+ puts ""
2479
+ }
2480
+ proc codelines {lines} {
2481
+ puts "======"
2482
+ foreach line $lines {
2483
+ puts " $line"
2484
+ }
2485
+ puts "======"
2486
+ }
2487
+ proc code {text} {
2488
+ puts "======"
2489
+ foreach line [parse_code_block $text] {
2490
+ puts " $line"
2491
+ }
2492
+ puts "======"
2493
+ }
2494
+ proc nl {} {
2495
+ }
2496
+ proc section {text} {
2497
+ puts "'''$text'''"
2498
+ puts ""
2499
+ }
2500
+ proc subsection {text} {
2501
+ puts "''$text''"
2502
+ puts ""
2503
+ }
2504
+ proc bullet {text} {
2505
+ puts " * [joinlines $text]"
2506
+ }
2507
+ proc indent {text} {
2508
+ puts " : [joinlines $text]"
2509
+ }
2510
+ proc defn {first args} {
2511
+ if {$first ne ""} {
2512
+ indent '''$first'''
2513
+ }
2514
+
2515
+ foreach p $args {
2516
+ p $p
2517
+ }
2518
+ }
2519
+ }
2520
+
2521
+
2522
+ ##################################################################
2523
+ #
2524
+ # Entry/Exit
2525
+ #
2526
+ if {$autosetup(debug)} {
2527
+ main $argv
2528
+ }
2529
+ if {[catch {main $argv} msg opts] == 1} {
2530
+ show-notices
2531
+ autosetup-full-error [error-dump $msg $opts $autosetup(debug)]
2532
+ if {!$autosetup(debug)} {
2533
+ puts stderr "Try: '[file tail $autosetup(exe)] --debug' for a full stack trace"
2534
+ }
2535
+ exit 1
2536
+ }
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/autosetup-config.guess ADDED
@@ -0,0 +1,1815 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #! /bin/sh
2
+ # Attempt to guess a canonical system name.
3
+ # Copyright 1992-2024 Free Software Foundation, Inc.
4
+
5
+ # shellcheck disable=SC2006,SC2268 # see below for rationale
6
+
7
+ timestamp='2024-07-27'
8
+
9
+ # This file is free software; you can redistribute it and/or modify it
10
+ # under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful, but
15
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ # General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program; if not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+ # As a special exception to the GNU General Public License, if you
23
+ # distribute this file as part of a program that contains a
24
+ # configuration script generated by Autoconf, you may include it under
25
+ # the same distribution terms that you use for the rest of that
26
+ # program. This Exception is an additional permission under section 7
27
+ # of the GNU General Public License, version 3 ("GPLv3").
28
+ #
29
+ # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
30
+ #
31
+ # You can get the latest version of this script from:
32
+ # https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
33
+ #
34
+ # Please send patches to <[email protected]>.
35
+
36
+
37
+ # The "shellcheck disable" line above the timestamp inhibits complaints
38
+ # about features and limitations of the classic Bourne shell that were
39
+ # superseded or lifted in POSIX. However, this script identifies a wide
40
+ # variety of pre-POSIX systems that do not have POSIX shells at all, and
41
+ # even some reasonably current systems (Solaris 10 as case-in-point) still
42
+ # have a pre-POSIX /bin/sh.
43
+
44
+
45
+ me=`echo "$0" | sed -e 's,.*/,,'`
46
+
47
+ usage="\
48
+ Usage: $0 [OPTION]
49
+
50
+ Output the configuration name of the system '$me' is run on.
51
+
52
+ Options:
53
+ -h, --help print this help, then exit
54
+ -t, --time-stamp print date of last modification, then exit
55
+ -v, --version print version number, then exit
56
+
57
+ Report bugs and patches to <[email protected]>."
58
+
59
+ version="\
60
+ GNU config.guess ($timestamp)
61
+
62
+ Originally written by Per Bothner.
63
+ Copyright 1992-2024 Free Software Foundation, Inc.
64
+
65
+ This is free software; see the source for copying conditions. There is NO
66
+ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
67
+
68
+ help="
69
+ Try '$me --help' for more information."
70
+
71
+ # Parse command line
72
+ while test $# -gt 0 ; do
73
+ case $1 in
74
+ --time-stamp | --time* | -t )
75
+ echo "$timestamp" ; exit ;;
76
+ --version | -v )
77
+ echo "$version" ; exit ;;
78
+ --help | --h* | -h )
79
+ echo "$usage"; exit ;;
80
+ -- ) # Stop option processing
81
+ shift; break ;;
82
+ - ) # Use stdin as input.
83
+ break ;;
84
+ -* )
85
+ echo "$me: invalid option $1$help" >&2
86
+ exit 1 ;;
87
+ * )
88
+ break ;;
89
+ esac
90
+ done
91
+
92
+ if test $# != 0; then
93
+ echo "$me: too many arguments$help" >&2
94
+ exit 1
95
+ fi
96
+
97
+ # Just in case it came from the environment.
98
+ GUESS=
99
+
100
+ # CC_FOR_BUILD -- compiler used by this script. Note that the use of a
101
+ # compiler to aid in system detection is discouraged as it requires
102
+ # temporary files to be created and, as you can see below, it is a
103
+ # headache to deal with in a portable fashion.
104
+
105
+ # Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still
106
+ # use 'HOST_CC' if defined, but it is deprecated.
107
+
108
+ # Portable tmp directory creation inspired by the Autoconf team.
109
+
110
+ tmp=
111
+ # shellcheck disable=SC2172
112
+ trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
113
+
114
+ set_cc_for_build() {
115
+ # prevent multiple calls if $tmp is already set
116
+ test "$tmp" && return 0
117
+ : "${TMPDIR=/tmp}"
118
+ # shellcheck disable=SC2039,SC3028
119
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
120
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
121
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
122
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
123
+ dummy=$tmp/dummy
124
+ case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
125
+ ,,) echo "int x;" > "$dummy.c"
126
+ for driver in cc gcc c17 c99 c89 ; do
127
+ if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
128
+ CC_FOR_BUILD=$driver
129
+ break
130
+ fi
131
+ done
132
+ if test x"$CC_FOR_BUILD" = x ; then
133
+ CC_FOR_BUILD=no_compiler_found
134
+ fi
135
+ ;;
136
+ ,,*) CC_FOR_BUILD=$CC ;;
137
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
138
+ esac
139
+ }
140
+
141
+ # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
142
+ # ([email protected] 1994-08-24)
143
+ if test -f /.attbin/uname ; then
144
+ PATH=$PATH:/.attbin ; export PATH
145
+ fi
146
+
147
+ UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
148
+ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
149
+ UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
150
+ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
151
+
152
+ case $UNAME_SYSTEM in
153
+ Linux|GNU|GNU/*)
154
+ LIBC=unknown
155
+
156
+ set_cc_for_build
157
+ cat <<-EOF > "$dummy.c"
158
+ #if defined(__ANDROID__)
159
+ LIBC=android
160
+ #else
161
+ #include <features.h>
162
+ #if defined(__UCLIBC__)
163
+ LIBC=uclibc
164
+ #elif defined(__dietlibc__)
165
+ LIBC=dietlibc
166
+ #elif defined(__GLIBC__)
167
+ LIBC=gnu
168
+ #elif defined(__LLVM_LIBC__)
169
+ LIBC=llvm
170
+ #else
171
+ #include <stdarg.h>
172
+ /* First heuristic to detect musl libc. */
173
+ #ifdef __DEFINED_va_list
174
+ LIBC=musl
175
+ #endif
176
+ #endif
177
+ #endif
178
+ EOF
179
+ cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
180
+ eval "$cc_set_libc"
181
+
182
+ # Second heuristic to detect musl libc.
183
+ if [ "$LIBC" = unknown ] &&
184
+ command -v ldd >/dev/null &&
185
+ ldd --version 2>&1 | grep -q ^musl; then
186
+ LIBC=musl
187
+ fi
188
+
189
+ # If the system lacks a compiler, then just pick glibc.
190
+ # We could probably try harder.
191
+ if [ "$LIBC" = unknown ]; then
192
+ LIBC=gnu
193
+ fi
194
+ ;;
195
+ esac
196
+
197
+ # Note: order is significant - the case branches are not exclusive.
198
+
199
+ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
200
+ *:NetBSD:*:*)
201
+ # NetBSD (nbsd) targets should (where applicable) match one or
202
+ # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
203
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
204
+ # switched to ELF, *-*-netbsd* would select the old
205
+ # object file format. This provides both forward
206
+ # compatibility and a consistent mechanism for selecting the
207
+ # object file format.
208
+ #
209
+ # Note: NetBSD doesn't particularly care about the vendor
210
+ # portion of the name. We always set it to "unknown".
211
+ UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
212
+ /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
213
+ /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
214
+ echo unknown)`
215
+ case $UNAME_MACHINE_ARCH in
216
+ aarch64eb) machine=aarch64_be-unknown ;;
217
+ armeb) machine=armeb-unknown ;;
218
+ arm*) machine=arm-unknown ;;
219
+ sh3el) machine=shl-unknown ;;
220
+ sh3eb) machine=sh-unknown ;;
221
+ sh5el) machine=sh5le-unknown ;;
222
+ earmv*)
223
+ arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
224
+ endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
225
+ machine=${arch}${endian}-unknown
226
+ ;;
227
+ *) machine=$UNAME_MACHINE_ARCH-unknown ;;
228
+ esac
229
+ # The Operating System including object format, if it has switched
230
+ # to ELF recently (or will in the future) and ABI.
231
+ case $UNAME_MACHINE_ARCH in
232
+ earm*)
233
+ os=netbsdelf
234
+ ;;
235
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
236
+ set_cc_for_build
237
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
238
+ | grep -q __ELF__
239
+ then
240
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
241
+ # Return netbsd for either. FIX?
242
+ os=netbsd
243
+ else
244
+ os=netbsdelf
245
+ fi
246
+ ;;
247
+ *)
248
+ os=netbsd
249
+ ;;
250
+ esac
251
+ # Determine ABI tags.
252
+ case $UNAME_MACHINE_ARCH in
253
+ earm*)
254
+ expr='s/^earmv[0-9]/-eabi/;s/eb$//'
255
+ abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
256
+ ;;
257
+ esac
258
+ # The OS release
259
+ # Debian GNU/NetBSD machines have a different userland, and
260
+ # thus, need a distinct triplet. However, they do not need
261
+ # kernel version information, so it can be replaced with a
262
+ # suitable tag, in the style of linux-gnu.
263
+ case $UNAME_VERSION in
264
+ Debian*)
265
+ release='-gnu'
266
+ ;;
267
+ *)
268
+ release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
269
+ ;;
270
+ esac
271
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
272
+ # contains redundant information, the shorter form:
273
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
274
+ GUESS=$machine-${os}${release}${abi-}
275
+ ;;
276
+ *:Bitrig:*:*)
277
+ UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
278
+ GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
279
+ ;;
280
+ *:OpenBSD:*:*)
281
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
282
+ GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
283
+ ;;
284
+ *:SecBSD:*:*)
285
+ UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
286
+ GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
287
+ ;;
288
+ *:LibertyBSD:*:*)
289
+ UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
290
+ GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
291
+ ;;
292
+ *:MidnightBSD:*:*)
293
+ GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
294
+ ;;
295
+ *:ekkoBSD:*:*)
296
+ GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
297
+ ;;
298
+ *:SolidBSD:*:*)
299
+ GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
300
+ ;;
301
+ *:OS108:*:*)
302
+ GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
303
+ ;;
304
+ macppc:MirBSD:*:*)
305
+ GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
306
+ ;;
307
+ *:MirBSD:*:*)
308
+ GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
309
+ ;;
310
+ *:Sortix:*:*)
311
+ GUESS=$UNAME_MACHINE-unknown-sortix
312
+ ;;
313
+ *:Twizzler:*:*)
314
+ GUESS=$UNAME_MACHINE-unknown-twizzler
315
+ ;;
316
+ *:Redox:*:*)
317
+ GUESS=$UNAME_MACHINE-unknown-redox
318
+ ;;
319
+ mips:OSF1:*.*)
320
+ GUESS=mips-dec-osf1
321
+ ;;
322
+ alpha:OSF1:*:*)
323
+ # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
324
+ trap '' 0
325
+ case $UNAME_RELEASE in
326
+ *4.0)
327
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
328
+ ;;
329
+ *5.*)
330
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
331
+ ;;
332
+ esac
333
+ # According to Compaq, /usr/sbin/psrinfo has been available on
334
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
335
+ # covers most systems running today. This code pipes the CPU
336
+ # types through head -n 1, so we only detect the type of CPU 0.
337
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
338
+ case $ALPHA_CPU_TYPE in
339
+ "EV4 (21064)")
340
+ UNAME_MACHINE=alpha ;;
341
+ "EV4.5 (21064)")
342
+ UNAME_MACHINE=alpha ;;
343
+ "LCA4 (21066/21068)")
344
+ UNAME_MACHINE=alpha ;;
345
+ "EV5 (21164)")
346
+ UNAME_MACHINE=alphaev5 ;;
347
+ "EV5.6 (21164A)")
348
+ UNAME_MACHINE=alphaev56 ;;
349
+ "EV5.6 (21164PC)")
350
+ UNAME_MACHINE=alphapca56 ;;
351
+ "EV5.7 (21164PC)")
352
+ UNAME_MACHINE=alphapca57 ;;
353
+ "EV6 (21264)")
354
+ UNAME_MACHINE=alphaev6 ;;
355
+ "EV6.7 (21264A)")
356
+ UNAME_MACHINE=alphaev67 ;;
357
+ "EV6.8CB (21264C)")
358
+ UNAME_MACHINE=alphaev68 ;;
359
+ "EV6.8AL (21264B)")
360
+ UNAME_MACHINE=alphaev68 ;;
361
+ "EV6.8CX (21264D)")
362
+ UNAME_MACHINE=alphaev68 ;;
363
+ "EV6.9A (21264/EV69A)")
364
+ UNAME_MACHINE=alphaev69 ;;
365
+ "EV7 (21364)")
366
+ UNAME_MACHINE=alphaev7 ;;
367
+ "EV7.9 (21364A)")
368
+ UNAME_MACHINE=alphaev79 ;;
369
+ esac
370
+ # A Pn.n version is a patched version.
371
+ # A Vn.n version is a released version.
372
+ # A Tn.n version is a released field test version.
373
+ # A Xn.n version is an unreleased experimental baselevel.
374
+ # 1.2 uses "1.2" for uname -r.
375
+ OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
376
+ GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
377
+ ;;
378
+ Amiga*:UNIX_System_V:4.0:*)
379
+ GUESS=m68k-unknown-sysv4
380
+ ;;
381
+ *:[Aa]miga[Oo][Ss]:*:*)
382
+ GUESS=$UNAME_MACHINE-unknown-amigaos
383
+ ;;
384
+ *:[Mm]orph[Oo][Ss]:*:*)
385
+ GUESS=$UNAME_MACHINE-unknown-morphos
386
+ ;;
387
+ *:OS/390:*:*)
388
+ GUESS=i370-ibm-openedition
389
+ ;;
390
+ *:z/VM:*:*)
391
+ GUESS=s390-ibm-zvmoe
392
+ ;;
393
+ *:OS400:*:*)
394
+ GUESS=powerpc-ibm-os400
395
+ ;;
396
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
397
+ GUESS=arm-acorn-riscix$UNAME_RELEASE
398
+ ;;
399
+ arm*:riscos:*:*|arm*:RISCOS:*:*)
400
+ GUESS=arm-unknown-riscos
401
+ ;;
402
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
403
+ GUESS=hppa1.1-hitachi-hiuxmpp
404
+ ;;
405
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
406
+ # [email protected] (Earle F. Ake) contributed MIS and NILE.
407
+ case `(/bin/universe) 2>/dev/null` in
408
+ att) GUESS=pyramid-pyramid-sysv3 ;;
409
+ *) GUESS=pyramid-pyramid-bsd ;;
410
+ esac
411
+ ;;
412
+ NILE*:*:*:dcosx)
413
+ GUESS=pyramid-pyramid-svr4
414
+ ;;
415
+ DRS?6000:unix:4.0:6*)
416
+ GUESS=sparc-icl-nx6
417
+ ;;
418
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
419
+ case `/usr/bin/uname -p` in
420
+ sparc) GUESS=sparc-icl-nx7 ;;
421
+ esac
422
+ ;;
423
+ s390x:SunOS:*:*)
424
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
425
+ GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
426
+ ;;
427
+ sun4H:SunOS:5.*:*)
428
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
429
+ GUESS=sparc-hal-solaris2$SUN_REL
430
+ ;;
431
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
432
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
433
+ GUESS=sparc-sun-solaris2$SUN_REL
434
+ ;;
435
+ i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
436
+ GUESS=i386-pc-auroraux$UNAME_RELEASE
437
+ ;;
438
+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
439
+ set_cc_for_build
440
+ SUN_ARCH=i386
441
+ # If there is a compiler, see if it is configured for 64-bit objects.
442
+ # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
443
+ # This test works for both compilers.
444
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
445
+ if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
446
+ (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
447
+ grep IS_64BIT_ARCH >/dev/null
448
+ then
449
+ SUN_ARCH=x86_64
450
+ fi
451
+ fi
452
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
453
+ GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
454
+ ;;
455
+ sun4*:SunOS:6*:*)
456
+ # According to config.sub, this is the proper way to canonicalize
457
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
458
+ # it's likely to be more like Solaris than SunOS4.
459
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
460
+ GUESS=sparc-sun-solaris3$SUN_REL
461
+ ;;
462
+ sun4*:SunOS:*:*)
463
+ case `/usr/bin/arch -k` in
464
+ Series*|S4*)
465
+ UNAME_RELEASE=`uname -v`
466
+ ;;
467
+ esac
468
+ # Japanese Language versions have a version number like '4.1.3-JL'.
469
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
470
+ GUESS=sparc-sun-sunos$SUN_REL
471
+ ;;
472
+ sun3*:SunOS:*:*)
473
+ GUESS=m68k-sun-sunos$UNAME_RELEASE
474
+ ;;
475
+ sun*:*:4.2BSD:*)
476
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
477
+ test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
478
+ case `/bin/arch` in
479
+ sun3)
480
+ GUESS=m68k-sun-sunos$UNAME_RELEASE
481
+ ;;
482
+ sun4)
483
+ GUESS=sparc-sun-sunos$UNAME_RELEASE
484
+ ;;
485
+ esac
486
+ ;;
487
+ aushp:SunOS:*:*)
488
+ GUESS=sparc-auspex-sunos$UNAME_RELEASE
489
+ ;;
490
+ # The situation for MiNT is a little confusing. The machine name
491
+ # can be virtually everything (everything which is not
492
+ # "atarist" or "atariste" at least should have a processor
493
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
494
+ # to the lowercase version "mint" (or "freemint"). Finally
495
+ # the system name "TOS" denotes a system which is actually not
496
+ # MiNT. But MiNT is downward compatible to TOS, so this should
497
+ # be no problem.
498
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
499
+ GUESS=m68k-atari-mint$UNAME_RELEASE
500
+ ;;
501
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
502
+ GUESS=m68k-atari-mint$UNAME_RELEASE
503
+ ;;
504
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
505
+ GUESS=m68k-atari-mint$UNAME_RELEASE
506
+ ;;
507
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
508
+ GUESS=m68k-milan-mint$UNAME_RELEASE
509
+ ;;
510
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
511
+ GUESS=m68k-hades-mint$UNAME_RELEASE
512
+ ;;
513
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
514
+ GUESS=m68k-unknown-mint$UNAME_RELEASE
515
+ ;;
516
+ m68k:machten:*:*)
517
+ GUESS=m68k-apple-machten$UNAME_RELEASE
518
+ ;;
519
+ powerpc:machten:*:*)
520
+ GUESS=powerpc-apple-machten$UNAME_RELEASE
521
+ ;;
522
+ RISC*:Mach:*:*)
523
+ GUESS=mips-dec-mach_bsd4.3
524
+ ;;
525
+ RISC*:ULTRIX:*:*)
526
+ GUESS=mips-dec-ultrix$UNAME_RELEASE
527
+ ;;
528
+ VAX*:ULTRIX*:*:*)
529
+ GUESS=vax-dec-ultrix$UNAME_RELEASE
530
+ ;;
531
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
532
+ GUESS=clipper-intergraph-clix$UNAME_RELEASE
533
+ ;;
534
+ mips:*:*:UMIPS | mips:*:*:RISCos)
535
+ set_cc_for_build
536
+ sed 's/^ //' << EOF > "$dummy.c"
537
+ #ifdef __cplusplus
538
+ #include <stdio.h> /* for printf() prototype */
539
+ int main (int argc, char *argv[]) {
540
+ #else
541
+ int main (argc, argv) int argc; char *argv[]; {
542
+ #endif
543
+ #if defined (host_mips) && defined (MIPSEB)
544
+ #if defined (SYSTYPE_SYSV)
545
+ printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
546
+ #endif
547
+ #if defined (SYSTYPE_SVR4)
548
+ printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
549
+ #endif
550
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
551
+ printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
552
+ #endif
553
+ #endif
554
+ exit (-1);
555
+ }
556
+ EOF
557
+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
558
+ dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
559
+ SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
560
+ { echo "$SYSTEM_NAME"; exit; }
561
+ GUESS=mips-mips-riscos$UNAME_RELEASE
562
+ ;;
563
+ Motorola:PowerMAX_OS:*:*)
564
+ GUESS=powerpc-motorola-powermax
565
+ ;;
566
+ Motorola:*:4.3:PL8-*)
567
+ GUESS=powerpc-harris-powermax
568
+ ;;
569
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
570
+ GUESS=powerpc-harris-powermax
571
+ ;;
572
+ Night_Hawk:Power_UNIX:*:*)
573
+ GUESS=powerpc-harris-powerunix
574
+ ;;
575
+ m88k:CX/UX:7*:*)
576
+ GUESS=m88k-harris-cxux7
577
+ ;;
578
+ m88k:*:4*:R4*)
579
+ GUESS=m88k-motorola-sysv4
580
+ ;;
581
+ m88k:*:3*:R3*)
582
+ GUESS=m88k-motorola-sysv3
583
+ ;;
584
+ AViiON:dgux:*:*)
585
+ # DG/UX returns AViiON for all architectures
586
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
587
+ if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
588
+ then
589
+ if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
590
+ test "$TARGET_BINARY_INTERFACE"x = x
591
+ then
592
+ GUESS=m88k-dg-dgux$UNAME_RELEASE
593
+ else
594
+ GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
595
+ fi
596
+ else
597
+ GUESS=i586-dg-dgux$UNAME_RELEASE
598
+ fi
599
+ ;;
600
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
601
+ GUESS=m88k-dolphin-sysv3
602
+ ;;
603
+ M88*:*:R3*:*)
604
+ # Delta 88k system running SVR3
605
+ GUESS=m88k-motorola-sysv3
606
+ ;;
607
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
608
+ GUESS=m88k-tektronix-sysv3
609
+ ;;
610
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
611
+ GUESS=m68k-tektronix-bsd
612
+ ;;
613
+ *:IRIX*:*:*)
614
+ IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
615
+ GUESS=mips-sgi-irix$IRIX_REL
616
+ ;;
617
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
618
+ GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id
619
+ ;; # Note that: echo "'`uname -s`'" gives 'AIX '
620
+ i*86:AIX:*:*)
621
+ GUESS=i386-ibm-aix
622
+ ;;
623
+ ia64:AIX:*:*)
624
+ if test -x /usr/bin/oslevel ; then
625
+ IBM_REV=`/usr/bin/oslevel`
626
+ else
627
+ IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
628
+ fi
629
+ GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
630
+ ;;
631
+ *:AIX:2:3)
632
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
633
+ set_cc_for_build
634
+ sed 's/^ //' << EOF > "$dummy.c"
635
+ #include <sys/systemcfg.h>
636
+
637
+ int
638
+ main ()
639
+ {
640
+ if (!__power_pc())
641
+ exit(1);
642
+ puts("powerpc-ibm-aix3.2.5");
643
+ exit(0);
644
+ }
645
+ EOF
646
+ if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
647
+ then
648
+ GUESS=$SYSTEM_NAME
649
+ else
650
+ GUESS=rs6000-ibm-aix3.2.5
651
+ fi
652
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
653
+ GUESS=rs6000-ibm-aix3.2.4
654
+ else
655
+ GUESS=rs6000-ibm-aix3.2
656
+ fi
657
+ ;;
658
+ *:AIX:*:[4567])
659
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
660
+ if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
661
+ IBM_ARCH=rs6000
662
+ else
663
+ IBM_ARCH=powerpc
664
+ fi
665
+ if test -x /usr/bin/lslpp ; then
666
+ IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
667
+ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
668
+ else
669
+ IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
670
+ fi
671
+ GUESS=$IBM_ARCH-ibm-aix$IBM_REV
672
+ ;;
673
+ *:AIX:*:*)
674
+ GUESS=rs6000-ibm-aix
675
+ ;;
676
+ ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
677
+ GUESS=romp-ibm-bsd4.4
678
+ ;;
679
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
680
+ GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to
681
+ ;; # report: romp-ibm BSD 4.3
682
+ *:BOSX:*:*)
683
+ GUESS=rs6000-bull-bosx
684
+ ;;
685
+ DPX/2?00:B.O.S.:*:*)
686
+ GUESS=m68k-bull-sysv3
687
+ ;;
688
+ 9000/[34]??:4.3bsd:1.*:*)
689
+ GUESS=m68k-hp-bsd
690
+ ;;
691
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
692
+ GUESS=m68k-hp-bsd4.4
693
+ ;;
694
+ 9000/[34678]??:HP-UX:*:*)
695
+ HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
696
+ case $UNAME_MACHINE in
697
+ 9000/31?) HP_ARCH=m68000 ;;
698
+ 9000/[34]??) HP_ARCH=m68k ;;
699
+ 9000/[678][0-9][0-9])
700
+ if test -x /usr/bin/getconf; then
701
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
702
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
703
+ case $sc_cpu_version in
704
+ 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
705
+ 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
706
+ 532) # CPU_PA_RISC2_0
707
+ case $sc_kernel_bits in
708
+ 32) HP_ARCH=hppa2.0n ;;
709
+ 64) HP_ARCH=hppa2.0w ;;
710
+ '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20
711
+ esac ;;
712
+ esac
713
+ fi
714
+ if test "$HP_ARCH" = ""; then
715
+ set_cc_for_build
716
+ sed 's/^ //' << EOF > "$dummy.c"
717
+
718
+ #define _HPUX_SOURCE
719
+ #include <stdlib.h>
720
+ #include <unistd.h>
721
+
722
+ int
723
+ main ()
724
+ {
725
+ #if defined(_SC_KERNEL_BITS)
726
+ long bits = sysconf(_SC_KERNEL_BITS);
727
+ #endif
728
+ long cpu = sysconf (_SC_CPU_VERSION);
729
+
730
+ switch (cpu)
731
+ {
732
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
733
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
734
+ case CPU_PA_RISC2_0:
735
+ #if defined(_SC_KERNEL_BITS)
736
+ switch (bits)
737
+ {
738
+ case 64: puts ("hppa2.0w"); break;
739
+ case 32: puts ("hppa2.0n"); break;
740
+ default: puts ("hppa2.0"); break;
741
+ } break;
742
+ #else /* !defined(_SC_KERNEL_BITS) */
743
+ puts ("hppa2.0"); break;
744
+ #endif
745
+ default: puts ("hppa1.0"); break;
746
+ }
747
+ exit (0);
748
+ }
749
+ EOF
750
+ (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
751
+ test -z "$HP_ARCH" && HP_ARCH=hppa
752
+ fi ;;
753
+ esac
754
+ if test "$HP_ARCH" = hppa2.0w
755
+ then
756
+ set_cc_for_build
757
+
758
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
759
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
760
+ # generating 64-bit code. GNU and HP use different nomenclature:
761
+ #
762
+ # $ CC_FOR_BUILD=cc ./config.guess
763
+ # => hppa2.0w-hp-hpux11.23
764
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
765
+ # => hppa64-hp-hpux11.23
766
+
767
+ if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
768
+ grep -q __LP64__
769
+ then
770
+ HP_ARCH=hppa2.0w
771
+ else
772
+ HP_ARCH=hppa64
773
+ fi
774
+ fi
775
+ GUESS=$HP_ARCH-hp-hpux$HPUX_REV
776
+ ;;
777
+ ia64:HP-UX:*:*)
778
+ HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
779
+ GUESS=ia64-hp-hpux$HPUX_REV
780
+ ;;
781
+ 3050*:HI-UX:*:*)
782
+ set_cc_for_build
783
+ sed 's/^ //' << EOF > "$dummy.c"
784
+ #include <unistd.h>
785
+ int
786
+ main ()
787
+ {
788
+ long cpu = sysconf (_SC_CPU_VERSION);
789
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
790
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
791
+ results, however. */
792
+ if (CPU_IS_PA_RISC (cpu))
793
+ {
794
+ switch (cpu)
795
+ {
796
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
797
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
798
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
799
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
800
+ }
801
+ }
802
+ else if (CPU_IS_HP_MC68K (cpu))
803
+ puts ("m68k-hitachi-hiuxwe2");
804
+ else puts ("unknown-hitachi-hiuxwe2");
805
+ exit (0);
806
+ }
807
+ EOF
808
+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
809
+ { echo "$SYSTEM_NAME"; exit; }
810
+ GUESS=unknown-hitachi-hiuxwe2
811
+ ;;
812
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
813
+ GUESS=hppa1.1-hp-bsd
814
+ ;;
815
+ 9000/8??:4.3bsd:*:*)
816
+ GUESS=hppa1.0-hp-bsd
817
+ ;;
818
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
819
+ GUESS=hppa1.0-hp-mpeix
820
+ ;;
821
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
822
+ GUESS=hppa1.1-hp-osf
823
+ ;;
824
+ hp8??:OSF1:*:*)
825
+ GUESS=hppa1.0-hp-osf
826
+ ;;
827
+ i*86:OSF1:*:*)
828
+ if test -x /usr/sbin/sysversion ; then
829
+ GUESS=$UNAME_MACHINE-unknown-osf1mk
830
+ else
831
+ GUESS=$UNAME_MACHINE-unknown-osf1
832
+ fi
833
+ ;;
834
+ parisc*:Lites*:*:*)
835
+ GUESS=hppa1.1-hp-lites
836
+ ;;
837
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
838
+ GUESS=c1-convex-bsd
839
+ ;;
840
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
841
+ if getsysinfo -f scalar_acc
842
+ then echo c32-convex-bsd
843
+ else echo c2-convex-bsd
844
+ fi
845
+ exit ;;
846
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
847
+ GUESS=c34-convex-bsd
848
+ ;;
849
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
850
+ GUESS=c38-convex-bsd
851
+ ;;
852
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
853
+ GUESS=c4-convex-bsd
854
+ ;;
855
+ CRAY*Y-MP:*:*:*)
856
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
857
+ GUESS=ymp-cray-unicos$CRAY_REL
858
+ ;;
859
+ CRAY*[A-Z]90:*:*:*)
860
+ echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
861
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
862
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
863
+ -e 's/\.[^.]*$/.X/'
864
+ exit ;;
865
+ CRAY*TS:*:*:*)
866
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
867
+ GUESS=t90-cray-unicos$CRAY_REL
868
+ ;;
869
+ CRAY*T3E:*:*:*)
870
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
871
+ GUESS=alphaev5-cray-unicosmk$CRAY_REL
872
+ ;;
873
+ CRAY*SV1:*:*:*)
874
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
875
+ GUESS=sv1-cray-unicos$CRAY_REL
876
+ ;;
877
+ *:UNICOS/mp:*:*)
878
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
879
+ GUESS=craynv-cray-unicosmp$CRAY_REL
880
+ ;;
881
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
882
+ FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
883
+ FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
884
+ FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
885
+ GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
886
+ ;;
887
+ 5000:UNIX_System_V:4.*:*)
888
+ FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
889
+ FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
890
+ GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
891
+ ;;
892
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
893
+ GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
894
+ ;;
895
+ sparc*:BSD/OS:*:*)
896
+ GUESS=sparc-unknown-bsdi$UNAME_RELEASE
897
+ ;;
898
+ *:BSD/OS:*:*)
899
+ GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
900
+ ;;
901
+ arm:FreeBSD:*:*)
902
+ UNAME_PROCESSOR=`uname -p`
903
+ set_cc_for_build
904
+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
905
+ | grep -q __ARM_PCS_VFP
906
+ then
907
+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
908
+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
909
+ else
910
+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
911
+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
912
+ fi
913
+ ;;
914
+ *:FreeBSD:*:*)
915
+ UNAME_PROCESSOR=`uname -p`
916
+ case $UNAME_PROCESSOR in
917
+ amd64)
918
+ UNAME_PROCESSOR=x86_64 ;;
919
+ i386)
920
+ UNAME_PROCESSOR=i586 ;;
921
+ esac
922
+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
923
+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
924
+ ;;
925
+ i*:CYGWIN*:*)
926
+ GUESS=$UNAME_MACHINE-pc-cygwin
927
+ ;;
928
+ *:MINGW64*:*)
929
+ GUESS=$UNAME_MACHINE-pc-mingw64
930
+ ;;
931
+ *:MINGW*:*)
932
+ GUESS=$UNAME_MACHINE-pc-mingw32
933
+ ;;
934
+ *:MSYS*:*)
935
+ GUESS=$UNAME_MACHINE-pc-msys
936
+ ;;
937
+ i*:PW*:*)
938
+ GUESS=$UNAME_MACHINE-pc-pw32
939
+ ;;
940
+ *:SerenityOS:*:*)
941
+ GUESS=$UNAME_MACHINE-pc-serenity
942
+ ;;
943
+ *:Interix*:*)
944
+ case $UNAME_MACHINE in
945
+ x86)
946
+ GUESS=i586-pc-interix$UNAME_RELEASE
947
+ ;;
948
+ authenticamd | genuineintel | EM64T)
949
+ GUESS=x86_64-unknown-interix$UNAME_RELEASE
950
+ ;;
951
+ IA64)
952
+ GUESS=ia64-unknown-interix$UNAME_RELEASE
953
+ ;;
954
+ esac ;;
955
+ i*:UWIN*:*)
956
+ GUESS=$UNAME_MACHINE-pc-uwin
957
+ ;;
958
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
959
+ GUESS=x86_64-pc-cygwin
960
+ ;;
961
+ prep*:SunOS:5.*:*)
962
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
963
+ GUESS=powerpcle-unknown-solaris2$SUN_REL
964
+ ;;
965
+ *:GNU:*:*)
966
+ # the GNU system
967
+ GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
968
+ GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
969
+ GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
970
+ ;;
971
+ *:GNU/*:*:*)
972
+ # other systems with GNU libc and userland
973
+ GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
974
+ GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
975
+ GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
976
+ ;;
977
+ x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
978
+ GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
979
+ ;;
980
+ *:[Mm]anagarm:*:*)
981
+ GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
982
+ ;;
983
+ *:Minix:*:*)
984
+ GUESS=$UNAME_MACHINE-unknown-minix
985
+ ;;
986
+ aarch64:Linux:*:*)
987
+ set_cc_for_build
988
+ CPU=$UNAME_MACHINE
989
+ LIBCABI=$LIBC
990
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
991
+ ABI=64
992
+ sed 's/^ //' << EOF > "$dummy.c"
993
+ #ifdef __ARM_EABI__
994
+ #ifdef __ARM_PCS_VFP
995
+ ABI=eabihf
996
+ #else
997
+ ABI=eabi
998
+ #endif
999
+ #endif
1000
+ EOF
1001
+ cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
1002
+ eval "$cc_set_abi"
1003
+ case $ABI in
1004
+ eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;
1005
+ esac
1006
+ fi
1007
+ GUESS=$CPU-unknown-linux-$LIBCABI
1008
+ ;;
1009
+ aarch64_be:Linux:*:*)
1010
+ UNAME_MACHINE=aarch64_be
1011
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1012
+ ;;
1013
+ alpha:Linux:*:*)
1014
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
1015
+ EV5) UNAME_MACHINE=alphaev5 ;;
1016
+ EV56) UNAME_MACHINE=alphaev56 ;;
1017
+ PCA56) UNAME_MACHINE=alphapca56 ;;
1018
+ PCA57) UNAME_MACHINE=alphapca56 ;;
1019
+ EV6) UNAME_MACHINE=alphaev6 ;;
1020
+ EV67) UNAME_MACHINE=alphaev67 ;;
1021
+ EV68*) UNAME_MACHINE=alphaev68 ;;
1022
+ esac
1023
+ objdump --private-headers /bin/sh | grep -q ld.so.1
1024
+ if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
1025
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1026
+ ;;
1027
+ arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
1028
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1029
+ ;;
1030
+ arm*:Linux:*:*)
1031
+ set_cc_for_build
1032
+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
1033
+ | grep -q __ARM_EABI__
1034
+ then
1035
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1036
+ else
1037
+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
1038
+ | grep -q __ARM_PCS_VFP
1039
+ then
1040
+ GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
1041
+ else
1042
+ GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
1043
+ fi
1044
+ fi
1045
+ ;;
1046
+ avr32*:Linux:*:*)
1047
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1048
+ ;;
1049
+ cris:Linux:*:*)
1050
+ GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1051
+ ;;
1052
+ crisv32:Linux:*:*)
1053
+ GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1054
+ ;;
1055
+ e2k:Linux:*:*)
1056
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1057
+ ;;
1058
+ frv:Linux:*:*)
1059
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1060
+ ;;
1061
+ hexagon:Linux:*:*)
1062
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1063
+ ;;
1064
+ i*86:Linux:*:*)
1065
+ GUESS=$UNAME_MACHINE-pc-linux-$LIBC
1066
+ ;;
1067
+ ia64:Linux:*:*)
1068
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1069
+ ;;
1070
+ k1om:Linux:*:*)
1071
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1072
+ ;;
1073
+ kvx:Linux:*:*)
1074
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1075
+ ;;
1076
+ kvx:cos:*:*)
1077
+ GUESS=$UNAME_MACHINE-unknown-cos
1078
+ ;;
1079
+ kvx:mbr:*:*)
1080
+ GUESS=$UNAME_MACHINE-unknown-mbr
1081
+ ;;
1082
+ loongarch32:Linux:*:* | loongarch64:Linux:*:*)
1083
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1084
+ ;;
1085
+ m32r*:Linux:*:*)
1086
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1087
+ ;;
1088
+ m68*:Linux:*:*)
1089
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1090
+ ;;
1091
+ mips:Linux:*:* | mips64:Linux:*:*)
1092
+ set_cc_for_build
1093
+ IS_GLIBC=0
1094
+ test x"${LIBC}" = xgnu && IS_GLIBC=1
1095
+ sed 's/^ //' << EOF > "$dummy.c"
1096
+ #undef CPU
1097
+ #undef mips
1098
+ #undef mipsel
1099
+ #undef mips64
1100
+ #undef mips64el
1101
+ #if ${IS_GLIBC} && defined(_ABI64)
1102
+ LIBCABI=gnuabi64
1103
+ #else
1104
+ #if ${IS_GLIBC} && defined(_ABIN32)
1105
+ LIBCABI=gnuabin32
1106
+ #else
1107
+ LIBCABI=${LIBC}
1108
+ #endif
1109
+ #endif
1110
+
1111
+ #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1112
+ CPU=mipsisa64r6
1113
+ #else
1114
+ #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1115
+ CPU=mipsisa32r6
1116
+ #else
1117
+ #if defined(__mips64)
1118
+ CPU=mips64
1119
+ #else
1120
+ CPU=mips
1121
+ #endif
1122
+ #endif
1123
+ #endif
1124
+
1125
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
1126
+ MIPS_ENDIAN=el
1127
+ #else
1128
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
1129
+ MIPS_ENDIAN=
1130
+ #else
1131
+ MIPS_ENDIAN=
1132
+ #endif
1133
+ #endif
1134
+ EOF
1135
+ cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
1136
+ eval "$cc_set_vars"
1137
+ test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
1138
+ ;;
1139
+ mips64el:Linux:*:*)
1140
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1141
+ ;;
1142
+ openrisc*:Linux:*:*)
1143
+ GUESS=or1k-unknown-linux-$LIBC
1144
+ ;;
1145
+ or32:Linux:*:* | or1k*:Linux:*:*)
1146
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1147
+ ;;
1148
+ padre:Linux:*:*)
1149
+ GUESS=sparc-unknown-linux-$LIBC
1150
+ ;;
1151
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
1152
+ GUESS=hppa64-unknown-linux-$LIBC
1153
+ ;;
1154
+ parisc:Linux:*:* | hppa:Linux:*:*)
1155
+ # Look for CPU level
1156
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
1157
+ PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
1158
+ PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
1159
+ *) GUESS=hppa-unknown-linux-$LIBC ;;
1160
+ esac
1161
+ ;;
1162
+ ppc64:Linux:*:*)
1163
+ GUESS=powerpc64-unknown-linux-$LIBC
1164
+ ;;
1165
+ ppc:Linux:*:*)
1166
+ GUESS=powerpc-unknown-linux-$LIBC
1167
+ ;;
1168
+ ppc64le:Linux:*:*)
1169
+ GUESS=powerpc64le-unknown-linux-$LIBC
1170
+ ;;
1171
+ ppcle:Linux:*:*)
1172
+ GUESS=powerpcle-unknown-linux-$LIBC
1173
+ ;;
1174
+ riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
1175
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1176
+ ;;
1177
+ s390:Linux:*:* | s390x:Linux:*:*)
1178
+ GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
1179
+ ;;
1180
+ sh64*:Linux:*:*)
1181
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1182
+ ;;
1183
+ sh*:Linux:*:*)
1184
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1185
+ ;;
1186
+ sparc:Linux:*:* | sparc64:Linux:*:*)
1187
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1188
+ ;;
1189
+ tile*:Linux:*:*)
1190
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1191
+ ;;
1192
+ vax:Linux:*:*)
1193
+ GUESS=$UNAME_MACHINE-dec-linux-$LIBC
1194
+ ;;
1195
+ x86_64:Linux:*:*)
1196
+ set_cc_for_build
1197
+ CPU=$UNAME_MACHINE
1198
+ LIBCABI=$LIBC
1199
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
1200
+ ABI=64
1201
+ sed 's/^ //' << EOF > "$dummy.c"
1202
+ #ifdef __i386__
1203
+ ABI=x86
1204
+ #else
1205
+ #ifdef __ILP32__
1206
+ ABI=x32
1207
+ #endif
1208
+ #endif
1209
+ EOF
1210
+ cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
1211
+ eval "$cc_set_abi"
1212
+ case $ABI in
1213
+ x86) CPU=i686 ;;
1214
+ x32) LIBCABI=${LIBC}x32 ;;
1215
+ esac
1216
+ fi
1217
+ GUESS=$CPU-pc-linux-$LIBCABI
1218
+ ;;
1219
+ xtensa*:Linux:*:*)
1220
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1221
+ ;;
1222
+ i*86:DYNIX/ptx:4*:*)
1223
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
1224
+ # earlier versions are messed up and put the nodename in both
1225
+ # sysname and nodename.
1226
+ GUESS=i386-sequent-sysv4
1227
+ ;;
1228
+ i*86:UNIX_SV:4.2MP:2.*)
1229
+ # Unixware is an offshoot of SVR4, but it has its own version
1230
+ # number series starting with 2...
1231
+ # I am not positive that other SVR4 systems won't match this,
1232
+ # I just have to hope. -- rms.
1233
+ # Use sysv4.2uw... so that sysv4* matches it.
1234
+ GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
1235
+ ;;
1236
+ i*86:OS/2:*:*)
1237
+ # If we were able to find 'uname', then EMX Unix compatibility
1238
+ # is probably installed.
1239
+ GUESS=$UNAME_MACHINE-pc-os2-emx
1240
+ ;;
1241
+ i*86:XTS-300:*:STOP)
1242
+ GUESS=$UNAME_MACHINE-unknown-stop
1243
+ ;;
1244
+ i*86:atheos:*:*)
1245
+ GUESS=$UNAME_MACHINE-unknown-atheos
1246
+ ;;
1247
+ i*86:syllable:*:*)
1248
+ GUESS=$UNAME_MACHINE-pc-syllable
1249
+ ;;
1250
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
1251
+ GUESS=i386-unknown-lynxos$UNAME_RELEASE
1252
+ ;;
1253
+ i*86:*DOS:*:*)
1254
+ GUESS=$UNAME_MACHINE-pc-msdosdjgpp
1255
+ ;;
1256
+ i*86:*:4.*:*)
1257
+ UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
1258
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1259
+ GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
1260
+ else
1261
+ GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
1262
+ fi
1263
+ ;;
1264
+ i*86:*:5:[678]*)
1265
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
1266
+ case `/bin/uname -X | grep "^Machine"` in
1267
+ *486*) UNAME_MACHINE=i486 ;;
1268
+ *Pentium) UNAME_MACHINE=i586 ;;
1269
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1270
+ esac
1271
+ GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1272
+ ;;
1273
+ i*86:*:3.2:*)
1274
+ if test -f /usr/options/cb.name; then
1275
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1276
+ GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
1277
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
1278
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1279
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1280
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1281
+ && UNAME_MACHINE=i586
1282
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1283
+ && UNAME_MACHINE=i686
1284
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1285
+ && UNAME_MACHINE=i686
1286
+ GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
1287
+ else
1288
+ GUESS=$UNAME_MACHINE-pc-sysv32
1289
+ fi
1290
+ ;;
1291
+ pc:*:*:*)
1292
+ # Left here for compatibility:
1293
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
1294
+ # the processor, so we play safe by assuming i586.
1295
+ # Note: whatever this is, it MUST be the same as what config.sub
1296
+ # prints for the "djgpp" host, or else GDB configure will decide that
1297
+ # this is a cross-build.
1298
+ GUESS=i586-pc-msdosdjgpp
1299
+ ;;
1300
+ Intel:Mach:3*:*)
1301
+ GUESS=i386-pc-mach3
1302
+ ;;
1303
+ paragon:*:*:*)
1304
+ GUESS=i860-intel-osf1
1305
+ ;;
1306
+ i860:*:4.*:*) # i860-SVR4
1307
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1308
+ GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4
1309
+ else # Add other i860-SVR4 vendors below as they are discovered.
1310
+ GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4
1311
+ fi
1312
+ ;;
1313
+ mini*:CTIX:SYS*5:*)
1314
+ # "miniframe"
1315
+ GUESS=m68010-convergent-sysv
1316
+ ;;
1317
+ mc68k:UNIX:SYSTEM5:3.51m)
1318
+ GUESS=m68k-convergent-sysv
1319
+ ;;
1320
+ M680?0:D-NIX:5.3:*)
1321
+ GUESS=m68k-diab-dnix
1322
+ ;;
1323
+ M68*:*:R3V[5678]*:*)
1324
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
1325
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
1326
+ OS_REL=''
1327
+ test -r /etc/.relid \
1328
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1329
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1330
+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
1331
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1332
+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1333
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
1334
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1335
+ && { echo i486-ncr-sysv4; exit; } ;;
1336
+ NCR*:*:4.2:* | MPRAS*:*:4.2:*)
1337
+ OS_REL='.3'
1338
+ test -r /etc/.relid \
1339
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1340
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1341
+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
1342
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1343
+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
1344
+ /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
1345
+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1346
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
1347
+ GUESS=m68k-unknown-lynxos$UNAME_RELEASE
1348
+ ;;
1349
+ mc68030:UNIX_System_V:4.*:*)
1350
+ GUESS=m68k-atari-sysv4
1351
+ ;;
1352
+ TSUNAMI:LynxOS:2.*:*)
1353
+ GUESS=sparc-unknown-lynxos$UNAME_RELEASE
1354
+ ;;
1355
+ rs6000:LynxOS:2.*:*)
1356
+ GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
1357
+ ;;
1358
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
1359
+ GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
1360
+ ;;
1361
+ SM[BE]S:UNIX_SV:*:*)
1362
+ GUESS=mips-dde-sysv$UNAME_RELEASE
1363
+ ;;
1364
+ RM*:ReliantUNIX-*:*:*)
1365
+ GUESS=mips-sni-sysv4
1366
+ ;;
1367
+ RM*:SINIX-*:*:*)
1368
+ GUESS=mips-sni-sysv4
1369
+ ;;
1370
+ *:SINIX-*:*:*)
1371
+ if uname -p 2>/dev/null >/dev/null ; then
1372
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
1373
+ GUESS=$UNAME_MACHINE-sni-sysv4
1374
+ else
1375
+ GUESS=ns32k-sni-sysv
1376
+ fi
1377
+ ;;
1378
+ PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort
1379
+ # says <[email protected]>
1380
+ GUESS=i586-unisys-sysv4
1381
+ ;;
1382
+ *:UNIX_System_V:4*:FTX*)
1383
+ # From Gerald Hewes <[email protected]>.
1384
+ # How about differentiating between stratus architectures? -djm
1385
+ GUESS=hppa1.1-stratus-sysv4
1386
+ ;;
1387
+ *:*:*:FTX*)
1388
+ # From [email protected].
1389
+ GUESS=i860-stratus-sysv4
1390
+ ;;
1391
+ i*86:VOS:*:*)
1392
+ # From [email protected].
1393
+ GUESS=$UNAME_MACHINE-stratus-vos
1394
+ ;;
1395
+ *:VOS:*:*)
1396
+ # From [email protected].
1397
+ GUESS=hppa1.1-stratus-vos
1398
+ ;;
1399
+ mc68*:A/UX:*:*)
1400
+ GUESS=m68k-apple-aux$UNAME_RELEASE
1401
+ ;;
1402
+ news*:NEWS-OS:6*:*)
1403
+ GUESS=mips-sony-newsos6
1404
+ ;;
1405
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1406
+ if test -d /usr/nec; then
1407
+ GUESS=mips-nec-sysv$UNAME_RELEASE
1408
+ else
1409
+ GUESS=mips-unknown-sysv$UNAME_RELEASE
1410
+ fi
1411
+ ;;
1412
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
1413
+ GUESS=powerpc-be-beos
1414
+ ;;
1415
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
1416
+ GUESS=powerpc-apple-beos
1417
+ ;;
1418
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
1419
+ GUESS=i586-pc-beos
1420
+ ;;
1421
+ BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
1422
+ GUESS=i586-pc-haiku
1423
+ ;;
1424
+ ppc:Haiku:*:*) # Haiku running on Apple PowerPC
1425
+ GUESS=powerpc-apple-haiku
1426
+ ;;
1427
+ *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat)
1428
+ GUESS=$UNAME_MACHINE-unknown-haiku
1429
+ ;;
1430
+ SX-4:SUPER-UX:*:*)
1431
+ GUESS=sx4-nec-superux$UNAME_RELEASE
1432
+ ;;
1433
+ SX-5:SUPER-UX:*:*)
1434
+ GUESS=sx5-nec-superux$UNAME_RELEASE
1435
+ ;;
1436
+ SX-6:SUPER-UX:*:*)
1437
+ GUESS=sx6-nec-superux$UNAME_RELEASE
1438
+ ;;
1439
+ SX-7:SUPER-UX:*:*)
1440
+ GUESS=sx7-nec-superux$UNAME_RELEASE
1441
+ ;;
1442
+ SX-8:SUPER-UX:*:*)
1443
+ GUESS=sx8-nec-superux$UNAME_RELEASE
1444
+ ;;
1445
+ SX-8R:SUPER-UX:*:*)
1446
+ GUESS=sx8r-nec-superux$UNAME_RELEASE
1447
+ ;;
1448
+ SX-ACE:SUPER-UX:*:*)
1449
+ GUESS=sxace-nec-superux$UNAME_RELEASE
1450
+ ;;
1451
+ Power*:Rhapsody:*:*)
1452
+ GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
1453
+ ;;
1454
+ *:Rhapsody:*:*)
1455
+ GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
1456
+ ;;
1457
+ arm64:Darwin:*:*)
1458
+ GUESS=aarch64-apple-darwin$UNAME_RELEASE
1459
+ ;;
1460
+ *:Darwin:*:*)
1461
+ UNAME_PROCESSOR=`uname -p`
1462
+ case $UNAME_PROCESSOR in
1463
+ unknown) UNAME_PROCESSOR=powerpc ;;
1464
+ esac
1465
+ if command -v xcode-select > /dev/null 2> /dev/null && \
1466
+ ! xcode-select --print-path > /dev/null 2> /dev/null ; then
1467
+ # Avoid executing cc if there is no toolchain installed as
1468
+ # cc will be a stub that puts up a graphical alert
1469
+ # prompting the user to install developer tools.
1470
+ CC_FOR_BUILD=no_compiler_found
1471
+ else
1472
+ set_cc_for_build
1473
+ fi
1474
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
1475
+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
1476
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1477
+ grep IS_64BIT_ARCH >/dev/null
1478
+ then
1479
+ case $UNAME_PROCESSOR in
1480
+ i386) UNAME_PROCESSOR=x86_64 ;;
1481
+ powerpc) UNAME_PROCESSOR=powerpc64 ;;
1482
+ esac
1483
+ fi
1484
+ # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
1485
+ if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
1486
+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1487
+ grep IS_PPC >/dev/null
1488
+ then
1489
+ UNAME_PROCESSOR=powerpc
1490
+ fi
1491
+ elif test "$UNAME_PROCESSOR" = i386 ; then
1492
+ # uname -m returns i386 or x86_64
1493
+ UNAME_PROCESSOR=$UNAME_MACHINE
1494
+ fi
1495
+ GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
1496
+ ;;
1497
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
1498
+ UNAME_PROCESSOR=`uname -p`
1499
+ if test "$UNAME_PROCESSOR" = x86; then
1500
+ UNAME_PROCESSOR=i386
1501
+ UNAME_MACHINE=pc
1502
+ fi
1503
+ GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
1504
+ ;;
1505
+ *:QNX:*:4*)
1506
+ GUESS=i386-pc-qnx
1507
+ ;;
1508
+ NEO-*:NONSTOP_KERNEL:*:*)
1509
+ GUESS=neo-tandem-nsk$UNAME_RELEASE
1510
+ ;;
1511
+ NSE-*:NONSTOP_KERNEL:*:*)
1512
+ GUESS=nse-tandem-nsk$UNAME_RELEASE
1513
+ ;;
1514
+ NSR-*:NONSTOP_KERNEL:*:*)
1515
+ GUESS=nsr-tandem-nsk$UNAME_RELEASE
1516
+ ;;
1517
+ NSV-*:NONSTOP_KERNEL:*:*)
1518
+ GUESS=nsv-tandem-nsk$UNAME_RELEASE
1519
+ ;;
1520
+ NSX-*:NONSTOP_KERNEL:*:*)
1521
+ GUESS=nsx-tandem-nsk$UNAME_RELEASE
1522
+ ;;
1523
+ *:NonStop-UX:*:*)
1524
+ GUESS=mips-compaq-nonstopux
1525
+ ;;
1526
+ BS2000:POSIX*:*:*)
1527
+ GUESS=bs2000-siemens-sysv
1528
+ ;;
1529
+ DS/*:UNIX_System_V:*:*)
1530
+ GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
1531
+ ;;
1532
+ *:Plan9:*:*)
1533
+ # "uname -m" is not consistent, so use $cputype instead. 386
1534
+ # is converted to i386 for consistency with other x86
1535
+ # operating systems.
1536
+ if test "${cputype-}" = 386; then
1537
+ UNAME_MACHINE=i386
1538
+ elif test "x${cputype-}" != x; then
1539
+ UNAME_MACHINE=$cputype
1540
+ fi
1541
+ GUESS=$UNAME_MACHINE-unknown-plan9
1542
+ ;;
1543
+ *:TOPS-10:*:*)
1544
+ GUESS=pdp10-unknown-tops10
1545
+ ;;
1546
+ *:TENEX:*:*)
1547
+ GUESS=pdp10-unknown-tenex
1548
+ ;;
1549
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1550
+ GUESS=pdp10-dec-tops20
1551
+ ;;
1552
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1553
+ GUESS=pdp10-xkl-tops20
1554
+ ;;
1555
+ *:TOPS-20:*:*)
1556
+ GUESS=pdp10-unknown-tops20
1557
+ ;;
1558
+ *:ITS:*:*)
1559
+ GUESS=pdp10-unknown-its
1560
+ ;;
1561
+ SEI:*:*:SEIUX)
1562
+ GUESS=mips-sei-seiux$UNAME_RELEASE
1563
+ ;;
1564
+ *:DragonFly:*:*)
1565
+ DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
1566
+ GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
1567
+ ;;
1568
+ *:*VMS:*:*)
1569
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
1570
+ case $UNAME_MACHINE in
1571
+ A*) GUESS=alpha-dec-vms ;;
1572
+ I*) GUESS=ia64-dec-vms ;;
1573
+ V*) GUESS=vax-dec-vms ;;
1574
+ esac ;;
1575
+ *:XENIX:*:SysV)
1576
+ GUESS=i386-pc-xenix
1577
+ ;;
1578
+ i*86:skyos:*:*)
1579
+ SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
1580
+ GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
1581
+ ;;
1582
+ i*86:rdos:*:*)
1583
+ GUESS=$UNAME_MACHINE-pc-rdos
1584
+ ;;
1585
+ i*86:Fiwix:*:*)
1586
+ GUESS=$UNAME_MACHINE-pc-fiwix
1587
+ ;;
1588
+ *:AROS:*:*)
1589
+ GUESS=$UNAME_MACHINE-unknown-aros
1590
+ ;;
1591
+ x86_64:VMkernel:*:*)
1592
+ GUESS=$UNAME_MACHINE-unknown-esx
1593
+ ;;
1594
+ amd64:Isilon\ OneFS:*:*)
1595
+ GUESS=x86_64-unknown-onefs
1596
+ ;;
1597
+ *:Unleashed:*:*)
1598
+ GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
1599
+ ;;
1600
+ *:Ironclad:*:*)
1601
+ GUESS=$UNAME_MACHINE-unknown-ironclad
1602
+ ;;
1603
+ esac
1604
+
1605
+ # Do we have a guess based on uname results?
1606
+ if test "x$GUESS" != x; then
1607
+ echo "$GUESS"
1608
+ exit
1609
+ fi
1610
+
1611
+ # No uname command or uname output not recognized.
1612
+ set_cc_for_build
1613
+ cat > "$dummy.c" <<EOF
1614
+ #ifdef _SEQUENT_
1615
+ #include <sys/types.h>
1616
+ #include <sys/utsname.h>
1617
+ #endif
1618
+ #if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1619
+ #if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1620
+ #include <signal.h>
1621
+ #if defined(_SIZE_T_) || defined(SIGLOST)
1622
+ #include <sys/utsname.h>
1623
+ #endif
1624
+ #endif
1625
+ #endif
1626
+ int
1627
+ main ()
1628
+ {
1629
+ #if defined (sony)
1630
+ #if defined (MIPSEB)
1631
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
1632
+ I don't know.... */
1633
+ printf ("mips-sony-bsd\n"); exit (0);
1634
+ #else
1635
+ #include <sys/param.h>
1636
+ printf ("m68k-sony-newsos%s\n",
1637
+ #ifdef NEWSOS4
1638
+ "4"
1639
+ #else
1640
+ ""
1641
+ #endif
1642
+ ); exit (0);
1643
+ #endif
1644
+ #endif
1645
+
1646
+ #if defined (NeXT)
1647
+ #if !defined (__ARCHITECTURE__)
1648
+ #define __ARCHITECTURE__ "m68k"
1649
+ #endif
1650
+ int version;
1651
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1652
+ if (version < 4)
1653
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1654
+ else
1655
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1656
+ exit (0);
1657
+ #endif
1658
+
1659
+ #if defined (MULTIMAX) || defined (n16)
1660
+ #if defined (UMAXV)
1661
+ printf ("ns32k-encore-sysv\n"); exit (0);
1662
+ #else
1663
+ #if defined (CMU)
1664
+ printf ("ns32k-encore-mach\n"); exit (0);
1665
+ #else
1666
+ printf ("ns32k-encore-bsd\n"); exit (0);
1667
+ #endif
1668
+ #endif
1669
+ #endif
1670
+
1671
+ #if defined (__386BSD__)
1672
+ printf ("i386-pc-bsd\n"); exit (0);
1673
+ #endif
1674
+
1675
+ #if defined (sequent)
1676
+ #if defined (i386)
1677
+ printf ("i386-sequent-dynix\n"); exit (0);
1678
+ #endif
1679
+ #if defined (ns32000)
1680
+ printf ("ns32k-sequent-dynix\n"); exit (0);
1681
+ #endif
1682
+ #endif
1683
+
1684
+ #if defined (_SEQUENT_)
1685
+ struct utsname un;
1686
+
1687
+ uname(&un);
1688
+ if (strncmp(un.version, "V2", 2) == 0) {
1689
+ printf ("i386-sequent-ptx2\n"); exit (0);
1690
+ }
1691
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
1692
+ printf ("i386-sequent-ptx1\n"); exit (0);
1693
+ }
1694
+ printf ("i386-sequent-ptx\n"); exit (0);
1695
+ #endif
1696
+
1697
+ #if defined (vax)
1698
+ #if !defined (ultrix)
1699
+ #include <sys/param.h>
1700
+ #if defined (BSD)
1701
+ #if BSD == 43
1702
+ printf ("vax-dec-bsd4.3\n"); exit (0);
1703
+ #else
1704
+ #if BSD == 199006
1705
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
1706
+ #else
1707
+ printf ("vax-dec-bsd\n"); exit (0);
1708
+ #endif
1709
+ #endif
1710
+ #else
1711
+ printf ("vax-dec-bsd\n"); exit (0);
1712
+ #endif
1713
+ #else
1714
+ #if defined(_SIZE_T_) || defined(SIGLOST)
1715
+ struct utsname un;
1716
+ uname (&un);
1717
+ printf ("vax-dec-ultrix%s\n", un.release); exit (0);
1718
+ #else
1719
+ printf ("vax-dec-ultrix\n"); exit (0);
1720
+ #endif
1721
+ #endif
1722
+ #endif
1723
+ #if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1724
+ #if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1725
+ #if defined(_SIZE_T_) || defined(SIGLOST)
1726
+ struct utsname *un;
1727
+ uname (&un);
1728
+ printf ("mips-dec-ultrix%s\n", un.release); exit (0);
1729
+ #else
1730
+ printf ("mips-dec-ultrix\n"); exit (0);
1731
+ #endif
1732
+ #endif
1733
+ #endif
1734
+
1735
+ #if defined (alliant) && defined (i860)
1736
+ printf ("i860-alliant-bsd\n"); exit (0);
1737
+ #endif
1738
+
1739
+ exit (1);
1740
+ }
1741
+ EOF
1742
+
1743
+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
1744
+ { echo "$SYSTEM_NAME"; exit; }
1745
+
1746
+ # Apollos put the system type in the environment.
1747
+ test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
1748
+
1749
+ echo "$0: unable to guess system type" >&2
1750
+
1751
+ case $UNAME_MACHINE:$UNAME_SYSTEM in
1752
+ mips:Linux | mips64:Linux)
1753
+ # If we got here on MIPS GNU/Linux, output extra information.
1754
+ cat >&2 <<EOF
1755
+
1756
+ NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
1757
+ the system type. Please install a C compiler and try again.
1758
+ EOF
1759
+ ;;
1760
+ esac
1761
+
1762
+ cat >&2 <<EOF
1763
+
1764
+ This script (version $timestamp), has failed to recognize the
1765
+ operating system you are using. If your script is old, overwrite *all*
1766
+ copies of config.guess and config.sub with the latest versions from:
1767
+
1768
+ https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
1769
+ and
1770
+ https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
1771
+ EOF
1772
+
1773
+ our_year=`echo $timestamp | sed 's,-.*,,'`
1774
+ thisyear=`date +%Y`
1775
+ # shellcheck disable=SC2003
1776
+ script_age=`expr "$thisyear" - "$our_year"`
1777
+ if test "$script_age" -lt 3 ; then
1778
+ cat >&2 <<EOF
1779
+
1780
+ If $0 has already been updated, send the following data and any
1781
+ information you think might be pertinent to [email protected] to
1782
+ provide the necessary information to handle your system.
1783
+
1784
+ config.guess timestamp = $timestamp
1785
+
1786
+ uname -m = `(uname -m) 2>/dev/null || echo unknown`
1787
+ uname -r = `(uname -r) 2>/dev/null || echo unknown`
1788
+ uname -s = `(uname -s) 2>/dev/null || echo unknown`
1789
+ uname -v = `(uname -v) 2>/dev/null || echo unknown`
1790
+
1791
+ /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
1792
+ /bin/uname -X = `(/bin/uname -X) 2>/dev/null`
1793
+
1794
+ hostinfo = `(hostinfo) 2>/dev/null`
1795
+ /bin/universe = `(/bin/universe) 2>/dev/null`
1796
+ /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
1797
+ /bin/arch = `(/bin/arch) 2>/dev/null`
1798
+ /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
1799
+ /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
1800
+
1801
+ UNAME_MACHINE = "$UNAME_MACHINE"
1802
+ UNAME_RELEASE = "$UNAME_RELEASE"
1803
+ UNAME_SYSTEM = "$UNAME_SYSTEM"
1804
+ UNAME_VERSION = "$UNAME_VERSION"
1805
+ EOF
1806
+ fi
1807
+
1808
+ exit 1
1809
+
1810
+ # Local variables:
1811
+ # eval: (add-hook 'before-save-hook 'time-stamp)
1812
+ # time-stamp-start: "timestamp='"
1813
+ # time-stamp-format: "%:y-%02m-%02d"
1814
+ # time-stamp-end: "'"
1815
+ # End:
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/autosetup-config.sub ADDED
@@ -0,0 +1,2354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #! /bin/sh
2
+ # Configuration validation subroutine script.
3
+ # Copyright 1992-2024 Free Software Foundation, Inc.
4
+
5
+ # shellcheck disable=SC2006,SC2268,SC2162 # see below for rationale
6
+
7
+ timestamp='2024-05-27'
8
+
9
+ # This file is free software; you can redistribute it and/or modify it
10
+ # under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful, but
15
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ # General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program; if not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+ # As a special exception to the GNU General Public License, if you
23
+ # distribute this file as part of a program that contains a
24
+ # configuration script generated by Autoconf, you may include it under
25
+ # the same distribution terms that you use for the rest of that
26
+ # program. This Exception is an additional permission under section 7
27
+ # of the GNU General Public License, version 3 ("GPLv3").
28
+
29
+
30
+ # Please send patches to <[email protected]>.
31
+ #
32
+ # Configuration subroutine to validate and canonicalize a configuration type.
33
+ # Supply the specified configuration type as an argument.
34
+ # If it is invalid, we print an error message on stderr and exit with code 1.
35
+ # Otherwise, we print the canonical config type on stdout and succeed.
36
+
37
+ # You can get the latest version of this script from:
38
+ # https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
39
+
40
+ # This file is supposed to be the same for all GNU packages
41
+ # and recognize all the CPU types, system types and aliases
42
+ # that are meaningful with *any* GNU software.
43
+ # Each package is responsible for reporting which valid configurations
44
+ # it does not support. The user should be able to distinguish
45
+ # a failure to support a valid configuration from a meaningless
46
+ # configuration.
47
+
48
+ # The goal of this file is to map all the various variations of a given
49
+ # machine specification into a single specification in the form:
50
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
51
+ # or in some cases, the newer four-part form:
52
+ # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
53
+ # It is wrong to echo any other type of specification.
54
+
55
+ # The "shellcheck disable" line above the timestamp inhibits complaints
56
+ # about features and limitations of the classic Bourne shell that were
57
+ # superseded or lifted in POSIX. However, this script identifies a wide
58
+ # variety of pre-POSIX systems that do not have POSIX shells at all, and
59
+ # even some reasonably current systems (Solaris 10 as case-in-point) still
60
+ # have a pre-POSIX /bin/sh.
61
+
62
+ me=`echo "$0" | sed -e 's,.*/,,'`
63
+
64
+ usage="\
65
+ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
66
+
67
+ Canonicalize a configuration name.
68
+
69
+ Options:
70
+ -h, --help print this help, then exit
71
+ -t, --time-stamp print date of last modification, then exit
72
+ -v, --version print version number, then exit
73
+
74
+ Report bugs and patches to <[email protected]>."
75
+
76
+ version="\
77
+ GNU config.sub ($timestamp)
78
+
79
+ Copyright 1992-2024 Free Software Foundation, Inc.
80
+
81
+ This is free software; see the source for copying conditions. There is NO
82
+ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
83
+
84
+ help="
85
+ Try '$me --help' for more information."
86
+
87
+ # Parse command line
88
+ while test $# -gt 0 ; do
89
+ case $1 in
90
+ --time-stamp | --time* | -t )
91
+ echo "$timestamp" ; exit ;;
92
+ --version | -v )
93
+ echo "$version" ; exit ;;
94
+ --help | --h* | -h )
95
+ echo "$usage"; exit ;;
96
+ -- ) # Stop option processing
97
+ shift; break ;;
98
+ - ) # Use stdin as input.
99
+ break ;;
100
+ -* )
101
+ echo "$me: invalid option $1$help" >&2
102
+ exit 1 ;;
103
+
104
+ *local*)
105
+ # First pass through any local machine types.
106
+ echo "$1"
107
+ exit ;;
108
+
109
+ * )
110
+ break ;;
111
+ esac
112
+ done
113
+
114
+ case $# in
115
+ 0) echo "$me: missing argument$help" >&2
116
+ exit 1;;
117
+ 1) ;;
118
+ *) echo "$me: too many arguments$help" >&2
119
+ exit 1;;
120
+ esac
121
+
122
+ # Split fields of configuration type
123
+ saved_IFS=$IFS
124
+ IFS="-" read field1 field2 field3 field4 <<EOF
125
+ $1
126
+ EOF
127
+ IFS=$saved_IFS
128
+
129
+ # Separate into logical components for further validation
130
+ case $1 in
131
+ *-*-*-*-*)
132
+ echo "Invalid configuration '$1': more than four components" >&2
133
+ exit 1
134
+ ;;
135
+ *-*-*-*)
136
+ basic_machine=$field1-$field2
137
+ basic_os=$field3-$field4
138
+ ;;
139
+ *-*-*)
140
+ # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
141
+ # parts
142
+ maybe_os=$field2-$field3
143
+ case $maybe_os in
144
+ cloudabi*-eabi* \
145
+ | kfreebsd*-gnu* \
146
+ | knetbsd*-gnu* \
147
+ | kopensolaris*-gnu* \
148
+ | linux-* \
149
+ | managarm-* \
150
+ | netbsd*-eabi* \
151
+ | netbsd*-gnu* \
152
+ | nto-qnx* \
153
+ | os2-emx* \
154
+ | rtmk-nova* \
155
+ | storm-chaos* \
156
+ | uclinux-gnu* \
157
+ | uclinux-uclibc* \
158
+ | windows-* )
159
+ basic_machine=$field1
160
+ basic_os=$maybe_os
161
+ ;;
162
+ android-linux)
163
+ basic_machine=$field1-unknown
164
+ basic_os=linux-android
165
+ ;;
166
+ *)
167
+ basic_machine=$field1-$field2
168
+ basic_os=$field3
169
+ ;;
170
+ esac
171
+ ;;
172
+ *-*)
173
+ case $field1-$field2 in
174
+ # Shorthands that happen to contain a single dash
175
+ convex-c[12] | convex-c3[248])
176
+ basic_machine=$field2-convex
177
+ basic_os=
178
+ ;;
179
+ decstation-3100)
180
+ basic_machine=mips-dec
181
+ basic_os=
182
+ ;;
183
+ *-*)
184
+ # Second component is usually, but not always the OS
185
+ case $field2 in
186
+ # Do not treat sunos as a manufacturer
187
+ sun*os*)
188
+ basic_machine=$field1
189
+ basic_os=$field2
190
+ ;;
191
+ # Manufacturers
192
+ 3100* \
193
+ | 32* \
194
+ | 3300* \
195
+ | 3600* \
196
+ | 7300* \
197
+ | acorn \
198
+ | altos* \
199
+ | apollo \
200
+ | apple \
201
+ | atari \
202
+ | att* \
203
+ | axis \
204
+ | be \
205
+ | bull \
206
+ | cbm \
207
+ | ccur \
208
+ | cisco \
209
+ | commodore \
210
+ | convergent* \
211
+ | convex* \
212
+ | cray \
213
+ | crds \
214
+ | dec* \
215
+ | delta* \
216
+ | dg \
217
+ | digital \
218
+ | dolphin \
219
+ | encore* \
220
+ | gould \
221
+ | harris \
222
+ | highlevel \
223
+ | hitachi* \
224
+ | hp \
225
+ | ibm* \
226
+ | intergraph \
227
+ | isi* \
228
+ | knuth \
229
+ | masscomp \
230
+ | microblaze* \
231
+ | mips* \
232
+ | motorola* \
233
+ | ncr* \
234
+ | news \
235
+ | next \
236
+ | ns \
237
+ | oki \
238
+ | omron* \
239
+ | pc533* \
240
+ | rebel \
241
+ | rom68k \
242
+ | rombug \
243
+ | semi \
244
+ | sequent* \
245
+ | siemens \
246
+ | sgi* \
247
+ | siemens \
248
+ | sim \
249
+ | sni \
250
+ | sony* \
251
+ | stratus \
252
+ | sun \
253
+ | sun[234]* \
254
+ | tektronix \
255
+ | tti* \
256
+ | ultra \
257
+ | unicom* \
258
+ | wec \
259
+ | winbond \
260
+ | wrs)
261
+ basic_machine=$field1-$field2
262
+ basic_os=
263
+ ;;
264
+ zephyr*)
265
+ basic_machine=$field1-unknown
266
+ basic_os=$field2
267
+ ;;
268
+ *)
269
+ basic_machine=$field1
270
+ basic_os=$field2
271
+ ;;
272
+ esac
273
+ ;;
274
+ esac
275
+ ;;
276
+ *)
277
+ # Convert single-component short-hands not valid as part of
278
+ # multi-component configurations.
279
+ case $field1 in
280
+ 386bsd)
281
+ basic_machine=i386-pc
282
+ basic_os=bsd
283
+ ;;
284
+ a29khif)
285
+ basic_machine=a29k-amd
286
+ basic_os=udi
287
+ ;;
288
+ adobe68k)
289
+ basic_machine=m68010-adobe
290
+ basic_os=scout
291
+ ;;
292
+ alliant)
293
+ basic_machine=fx80-alliant
294
+ basic_os=
295
+ ;;
296
+ altos | altos3068)
297
+ basic_machine=m68k-altos
298
+ basic_os=
299
+ ;;
300
+ am29k)
301
+ basic_machine=a29k-none
302
+ basic_os=bsd
303
+ ;;
304
+ amdahl)
305
+ basic_machine=580-amdahl
306
+ basic_os=sysv
307
+ ;;
308
+ amiga)
309
+ basic_machine=m68k-unknown
310
+ basic_os=
311
+ ;;
312
+ amigaos | amigados)
313
+ basic_machine=m68k-unknown
314
+ basic_os=amigaos
315
+ ;;
316
+ amigaunix | amix)
317
+ basic_machine=m68k-unknown
318
+ basic_os=sysv4
319
+ ;;
320
+ apollo68)
321
+ basic_machine=m68k-apollo
322
+ basic_os=sysv
323
+ ;;
324
+ apollo68bsd)
325
+ basic_machine=m68k-apollo
326
+ basic_os=bsd
327
+ ;;
328
+ aros)
329
+ basic_machine=i386-pc
330
+ basic_os=aros
331
+ ;;
332
+ aux)
333
+ basic_machine=m68k-apple
334
+ basic_os=aux
335
+ ;;
336
+ balance)
337
+ basic_machine=ns32k-sequent
338
+ basic_os=dynix
339
+ ;;
340
+ blackfin)
341
+ basic_machine=bfin-unknown
342
+ basic_os=linux
343
+ ;;
344
+ cegcc)
345
+ basic_machine=arm-unknown
346
+ basic_os=cegcc
347
+ ;;
348
+ cray)
349
+ basic_machine=j90-cray
350
+ basic_os=unicos
351
+ ;;
352
+ crds | unos)
353
+ basic_machine=m68k-crds
354
+ basic_os=
355
+ ;;
356
+ da30)
357
+ basic_machine=m68k-da30
358
+ basic_os=
359
+ ;;
360
+ decstation | pmax | pmin | dec3100 | decstatn)
361
+ basic_machine=mips-dec
362
+ basic_os=
363
+ ;;
364
+ delta88)
365
+ basic_machine=m88k-motorola
366
+ basic_os=sysv3
367
+ ;;
368
+ dicos)
369
+ basic_machine=i686-pc
370
+ basic_os=dicos
371
+ ;;
372
+ djgpp)
373
+ basic_machine=i586-pc
374
+ basic_os=msdosdjgpp
375
+ ;;
376
+ ebmon29k)
377
+ basic_machine=a29k-amd
378
+ basic_os=ebmon
379
+ ;;
380
+ es1800 | OSE68k | ose68k | ose | OSE)
381
+ basic_machine=m68k-ericsson
382
+ basic_os=ose
383
+ ;;
384
+ gmicro)
385
+ basic_machine=tron-gmicro
386
+ basic_os=sysv
387
+ ;;
388
+ go32)
389
+ basic_machine=i386-pc
390
+ basic_os=go32
391
+ ;;
392
+ h8300hms)
393
+ basic_machine=h8300-hitachi
394
+ basic_os=hms
395
+ ;;
396
+ h8300xray)
397
+ basic_machine=h8300-hitachi
398
+ basic_os=xray
399
+ ;;
400
+ h8500hms)
401
+ basic_machine=h8500-hitachi
402
+ basic_os=hms
403
+ ;;
404
+ harris)
405
+ basic_machine=m88k-harris
406
+ basic_os=sysv3
407
+ ;;
408
+ hp300 | hp300hpux)
409
+ basic_machine=m68k-hp
410
+ basic_os=hpux
411
+ ;;
412
+ hp300bsd)
413
+ basic_machine=m68k-hp
414
+ basic_os=bsd
415
+ ;;
416
+ hppaosf)
417
+ basic_machine=hppa1.1-hp
418
+ basic_os=osf
419
+ ;;
420
+ hppro)
421
+ basic_machine=hppa1.1-hp
422
+ basic_os=proelf
423
+ ;;
424
+ i386mach)
425
+ basic_machine=i386-mach
426
+ basic_os=mach
427
+ ;;
428
+ isi68 | isi)
429
+ basic_machine=m68k-isi
430
+ basic_os=sysv
431
+ ;;
432
+ m68knommu)
433
+ basic_machine=m68k-unknown
434
+ basic_os=linux
435
+ ;;
436
+ magnum | m3230)
437
+ basic_machine=mips-mips
438
+ basic_os=sysv
439
+ ;;
440
+ merlin)
441
+ basic_machine=ns32k-utek
442
+ basic_os=sysv
443
+ ;;
444
+ mingw64)
445
+ basic_machine=x86_64-pc
446
+ basic_os=mingw64
447
+ ;;
448
+ mingw32)
449
+ basic_machine=i686-pc
450
+ basic_os=mingw32
451
+ ;;
452
+ mingw32ce)
453
+ basic_machine=arm-unknown
454
+ basic_os=mingw32ce
455
+ ;;
456
+ monitor)
457
+ basic_machine=m68k-rom68k
458
+ basic_os=coff
459
+ ;;
460
+ morphos)
461
+ basic_machine=powerpc-unknown
462
+ basic_os=morphos
463
+ ;;
464
+ moxiebox)
465
+ basic_machine=moxie-unknown
466
+ basic_os=moxiebox
467
+ ;;
468
+ msdos)
469
+ basic_machine=i386-pc
470
+ basic_os=msdos
471
+ ;;
472
+ msys)
473
+ basic_machine=i686-pc
474
+ basic_os=msys
475
+ ;;
476
+ mvs)
477
+ basic_machine=i370-ibm
478
+ basic_os=mvs
479
+ ;;
480
+ nacl)
481
+ basic_machine=le32-unknown
482
+ basic_os=nacl
483
+ ;;
484
+ ncr3000)
485
+ basic_machine=i486-ncr
486
+ basic_os=sysv4
487
+ ;;
488
+ netbsd386)
489
+ basic_machine=i386-pc
490
+ basic_os=netbsd
491
+ ;;
492
+ netwinder)
493
+ basic_machine=armv4l-rebel
494
+ basic_os=linux
495
+ ;;
496
+ news | news700 | news800 | news900)
497
+ basic_machine=m68k-sony
498
+ basic_os=newsos
499
+ ;;
500
+ news1000)
501
+ basic_machine=m68030-sony
502
+ basic_os=newsos
503
+ ;;
504
+ necv70)
505
+ basic_machine=v70-nec
506
+ basic_os=sysv
507
+ ;;
508
+ nh3000)
509
+ basic_machine=m68k-harris
510
+ basic_os=cxux
511
+ ;;
512
+ nh[45]000)
513
+ basic_machine=m88k-harris
514
+ basic_os=cxux
515
+ ;;
516
+ nindy960)
517
+ basic_machine=i960-intel
518
+ basic_os=nindy
519
+ ;;
520
+ mon960)
521
+ basic_machine=i960-intel
522
+ basic_os=mon960
523
+ ;;
524
+ nonstopux)
525
+ basic_machine=mips-compaq
526
+ basic_os=nonstopux
527
+ ;;
528
+ os400)
529
+ basic_machine=powerpc-ibm
530
+ basic_os=os400
531
+ ;;
532
+ OSE68000 | ose68000)
533
+ basic_machine=m68000-ericsson
534
+ basic_os=ose
535
+ ;;
536
+ os68k)
537
+ basic_machine=m68k-none
538
+ basic_os=os68k
539
+ ;;
540
+ paragon)
541
+ basic_machine=i860-intel
542
+ basic_os=osf
543
+ ;;
544
+ parisc)
545
+ basic_machine=hppa-unknown
546
+ basic_os=linux
547
+ ;;
548
+ psp)
549
+ basic_machine=mipsallegrexel-sony
550
+ basic_os=psp
551
+ ;;
552
+ pw32)
553
+ basic_machine=i586-unknown
554
+ basic_os=pw32
555
+ ;;
556
+ rdos | rdos64)
557
+ basic_machine=x86_64-pc
558
+ basic_os=rdos
559
+ ;;
560
+ rdos32)
561
+ basic_machine=i386-pc
562
+ basic_os=rdos
563
+ ;;
564
+ rom68k)
565
+ basic_machine=m68k-rom68k
566
+ basic_os=coff
567
+ ;;
568
+ sa29200)
569
+ basic_machine=a29k-amd
570
+ basic_os=udi
571
+ ;;
572
+ sei)
573
+ basic_machine=mips-sei
574
+ basic_os=seiux
575
+ ;;
576
+ sequent)
577
+ basic_machine=i386-sequent
578
+ basic_os=
579
+ ;;
580
+ sps7)
581
+ basic_machine=m68k-bull
582
+ basic_os=sysv2
583
+ ;;
584
+ st2000)
585
+ basic_machine=m68k-tandem
586
+ basic_os=
587
+ ;;
588
+ stratus)
589
+ basic_machine=i860-stratus
590
+ basic_os=sysv4
591
+ ;;
592
+ sun2)
593
+ basic_machine=m68000-sun
594
+ basic_os=
595
+ ;;
596
+ sun2os3)
597
+ basic_machine=m68000-sun
598
+ basic_os=sunos3
599
+ ;;
600
+ sun2os4)
601
+ basic_machine=m68000-sun
602
+ basic_os=sunos4
603
+ ;;
604
+ sun3)
605
+ basic_machine=m68k-sun
606
+ basic_os=
607
+ ;;
608
+ sun3os3)
609
+ basic_machine=m68k-sun
610
+ basic_os=sunos3
611
+ ;;
612
+ sun3os4)
613
+ basic_machine=m68k-sun
614
+ basic_os=sunos4
615
+ ;;
616
+ sun4)
617
+ basic_machine=sparc-sun
618
+ basic_os=
619
+ ;;
620
+ sun4os3)
621
+ basic_machine=sparc-sun
622
+ basic_os=sunos3
623
+ ;;
624
+ sun4os4)
625
+ basic_machine=sparc-sun
626
+ basic_os=sunos4
627
+ ;;
628
+ sun4sol2)
629
+ basic_machine=sparc-sun
630
+ basic_os=solaris2
631
+ ;;
632
+ sun386 | sun386i | roadrunner)
633
+ basic_machine=i386-sun
634
+ basic_os=
635
+ ;;
636
+ sv1)
637
+ basic_machine=sv1-cray
638
+ basic_os=unicos
639
+ ;;
640
+ symmetry)
641
+ basic_machine=i386-sequent
642
+ basic_os=dynix
643
+ ;;
644
+ t3e)
645
+ basic_machine=alphaev5-cray
646
+ basic_os=unicos
647
+ ;;
648
+ t90)
649
+ basic_machine=t90-cray
650
+ basic_os=unicos
651
+ ;;
652
+ toad1)
653
+ basic_machine=pdp10-xkl
654
+ basic_os=tops20
655
+ ;;
656
+ tpf)
657
+ basic_machine=s390x-ibm
658
+ basic_os=tpf
659
+ ;;
660
+ udi29k)
661
+ basic_machine=a29k-amd
662
+ basic_os=udi
663
+ ;;
664
+ ultra3)
665
+ basic_machine=a29k-nyu
666
+ basic_os=sym1
667
+ ;;
668
+ v810 | necv810)
669
+ basic_machine=v810-nec
670
+ basic_os=none
671
+ ;;
672
+ vaxv)
673
+ basic_machine=vax-dec
674
+ basic_os=sysv
675
+ ;;
676
+ vms)
677
+ basic_machine=vax-dec
678
+ basic_os=vms
679
+ ;;
680
+ vsta)
681
+ basic_machine=i386-pc
682
+ basic_os=vsta
683
+ ;;
684
+ vxworks960)
685
+ basic_machine=i960-wrs
686
+ basic_os=vxworks
687
+ ;;
688
+ vxworks68)
689
+ basic_machine=m68k-wrs
690
+ basic_os=vxworks
691
+ ;;
692
+ vxworks29k)
693
+ basic_machine=a29k-wrs
694
+ basic_os=vxworks
695
+ ;;
696
+ xbox)
697
+ basic_machine=i686-pc
698
+ basic_os=mingw32
699
+ ;;
700
+ ymp)
701
+ basic_machine=ymp-cray
702
+ basic_os=unicos
703
+ ;;
704
+ *)
705
+ basic_machine=$1
706
+ basic_os=
707
+ ;;
708
+ esac
709
+ ;;
710
+ esac
711
+
712
+ # Decode 1-component or ad-hoc basic machines
713
+ case $basic_machine in
714
+ # Here we handle the default manufacturer of certain CPU types. It is in
715
+ # some cases the only manufacturer, in others, it is the most popular.
716
+ w89k)
717
+ cpu=hppa1.1
718
+ vendor=winbond
719
+ ;;
720
+ op50n)
721
+ cpu=hppa1.1
722
+ vendor=oki
723
+ ;;
724
+ op60c)
725
+ cpu=hppa1.1
726
+ vendor=oki
727
+ ;;
728
+ ibm*)
729
+ cpu=i370
730
+ vendor=ibm
731
+ ;;
732
+ orion105)
733
+ cpu=clipper
734
+ vendor=highlevel
735
+ ;;
736
+ mac | mpw | mac-mpw)
737
+ cpu=m68k
738
+ vendor=apple
739
+ ;;
740
+ pmac | pmac-mpw)
741
+ cpu=powerpc
742
+ vendor=apple
743
+ ;;
744
+
745
+ # Recognize the various machine names and aliases which stand
746
+ # for a CPU type and a company and sometimes even an OS.
747
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
748
+ cpu=m68000
749
+ vendor=att
750
+ ;;
751
+ 3b*)
752
+ cpu=we32k
753
+ vendor=att
754
+ ;;
755
+ bluegene*)
756
+ cpu=powerpc
757
+ vendor=ibm
758
+ basic_os=cnk
759
+ ;;
760
+ decsystem10* | dec10*)
761
+ cpu=pdp10
762
+ vendor=dec
763
+ basic_os=tops10
764
+ ;;
765
+ decsystem20* | dec20*)
766
+ cpu=pdp10
767
+ vendor=dec
768
+ basic_os=tops20
769
+ ;;
770
+ delta | 3300 | delta-motorola | 3300-motorola | motorola-delta | motorola-3300)
771
+ cpu=m68k
772
+ vendor=motorola
773
+ ;;
774
+ # This used to be dpx2*, but that gets the RS6000-based
775
+ # DPX/20 and the x86-based DPX/2-100 wrong. See
776
+ # https://oldskool.silicium.org/stations/bull_dpx20.htm
777
+ # https://www.feb-patrimoine.com/english/bull_dpx2.htm
778
+ # https://www.feb-patrimoine.com/english/unix_and_bull.htm
779
+ dpx2 | dpx2[23]00 | dpx2[23]xx)
780
+ cpu=m68k
781
+ vendor=bull
782
+ ;;
783
+ dpx2100 | dpx21xx)
784
+ cpu=i386
785
+ vendor=bull
786
+ ;;
787
+ dpx20)
788
+ cpu=rs6000
789
+ vendor=bull
790
+ ;;
791
+ encore | umax | mmax)
792
+ cpu=ns32k
793
+ vendor=encore
794
+ ;;
795
+ elxsi)
796
+ cpu=elxsi
797
+ vendor=elxsi
798
+ basic_os=${basic_os:-bsd}
799
+ ;;
800
+ fx2800)
801
+ cpu=i860
802
+ vendor=alliant
803
+ ;;
804
+ genix)
805
+ cpu=ns32k
806
+ vendor=ns
807
+ ;;
808
+ h3050r* | hiux*)
809
+ cpu=hppa1.1
810
+ vendor=hitachi
811
+ basic_os=hiuxwe2
812
+ ;;
813
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
814
+ cpu=hppa1.0
815
+ vendor=hp
816
+ ;;
817
+ hp9k2[0-9][0-9] | hp9k31[0-9])
818
+ cpu=m68000
819
+ vendor=hp
820
+ ;;
821
+ hp9k3[2-9][0-9])
822
+ cpu=m68k
823
+ vendor=hp
824
+ ;;
825
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
826
+ cpu=hppa1.0
827
+ vendor=hp
828
+ ;;
829
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
830
+ cpu=hppa1.1
831
+ vendor=hp
832
+ ;;
833
+ hp9k78[0-9] | hp78[0-9])
834
+ # FIXME: really hppa2.0-hp
835
+ cpu=hppa1.1
836
+ vendor=hp
837
+ ;;
838
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
839
+ # FIXME: really hppa2.0-hp
840
+ cpu=hppa1.1
841
+ vendor=hp
842
+ ;;
843
+ hp9k8[0-9][13679] | hp8[0-9][13679])
844
+ cpu=hppa1.1
845
+ vendor=hp
846
+ ;;
847
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
848
+ cpu=hppa1.0
849
+ vendor=hp
850
+ ;;
851
+ i*86v32)
852
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
853
+ vendor=pc
854
+ basic_os=sysv32
855
+ ;;
856
+ i*86v4*)
857
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
858
+ vendor=pc
859
+ basic_os=sysv4
860
+ ;;
861
+ i*86v)
862
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
863
+ vendor=pc
864
+ basic_os=sysv
865
+ ;;
866
+ i*86sol2)
867
+ cpu=`echo "$1" | sed -e 's/86.*/86/'`
868
+ vendor=pc
869
+ basic_os=solaris2
870
+ ;;
871
+ j90 | j90-cray)
872
+ cpu=j90
873
+ vendor=cray
874
+ basic_os=${basic_os:-unicos}
875
+ ;;
876
+ iris | iris4d)
877
+ cpu=mips
878
+ vendor=sgi
879
+ case $basic_os in
880
+ irix*)
881
+ ;;
882
+ *)
883
+ basic_os=irix4
884
+ ;;
885
+ esac
886
+ ;;
887
+ miniframe)
888
+ cpu=m68000
889
+ vendor=convergent
890
+ ;;
891
+ *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
892
+ cpu=m68k
893
+ vendor=atari
894
+ basic_os=mint
895
+ ;;
896
+ news-3600 | risc-news)
897
+ cpu=mips
898
+ vendor=sony
899
+ basic_os=newsos
900
+ ;;
901
+ next | m*-next)
902
+ cpu=m68k
903
+ vendor=next
904
+ ;;
905
+ np1)
906
+ cpu=np1
907
+ vendor=gould
908
+ ;;
909
+ op50n-* | op60c-*)
910
+ cpu=hppa1.1
911
+ vendor=oki
912
+ basic_os=proelf
913
+ ;;
914
+ pa-hitachi)
915
+ cpu=hppa1.1
916
+ vendor=hitachi
917
+ basic_os=hiuxwe2
918
+ ;;
919
+ pbd)
920
+ cpu=sparc
921
+ vendor=tti
922
+ ;;
923
+ pbb)
924
+ cpu=m68k
925
+ vendor=tti
926
+ ;;
927
+ pc532)
928
+ cpu=ns32k
929
+ vendor=pc532
930
+ ;;
931
+ pn)
932
+ cpu=pn
933
+ vendor=gould
934
+ ;;
935
+ power)
936
+ cpu=power
937
+ vendor=ibm
938
+ ;;
939
+ ps2)
940
+ cpu=i386
941
+ vendor=ibm
942
+ ;;
943
+ rm[46]00)
944
+ cpu=mips
945
+ vendor=siemens
946
+ ;;
947
+ rtpc | rtpc-*)
948
+ cpu=romp
949
+ vendor=ibm
950
+ ;;
951
+ sde)
952
+ cpu=mipsisa32
953
+ vendor=sde
954
+ basic_os=${basic_os:-elf}
955
+ ;;
956
+ simso-wrs)
957
+ cpu=sparclite
958
+ vendor=wrs
959
+ basic_os=vxworks
960
+ ;;
961
+ tower | tower-32)
962
+ cpu=m68k
963
+ vendor=ncr
964
+ ;;
965
+ vpp*|vx|vx-*)
966
+ cpu=f301
967
+ vendor=fujitsu
968
+ ;;
969
+ w65)
970
+ cpu=w65
971
+ vendor=wdc
972
+ ;;
973
+ w89k-*)
974
+ cpu=hppa1.1
975
+ vendor=winbond
976
+ basic_os=proelf
977
+ ;;
978
+ none)
979
+ cpu=none
980
+ vendor=none
981
+ ;;
982
+ leon|leon[3-9])
983
+ cpu=sparc
984
+ vendor=$basic_machine
985
+ ;;
986
+ leon-*|leon[3-9]-*)
987
+ cpu=sparc
988
+ vendor=`echo "$basic_machine" | sed 's/-.*//'`
989
+ ;;
990
+
991
+ *-*)
992
+ saved_IFS=$IFS
993
+ IFS="-" read cpu vendor <<EOF
994
+ $basic_machine
995
+ EOF
996
+ IFS=$saved_IFS
997
+ ;;
998
+ # We use 'pc' rather than 'unknown'
999
+ # because (1) that's what they normally are, and
1000
+ # (2) the word "unknown" tends to confuse beginning users.
1001
+ i*86 | x86_64)
1002
+ cpu=$basic_machine
1003
+ vendor=pc
1004
+ ;;
1005
+ # These rules are duplicated from below for sake of the special case above;
1006
+ # i.e. things that normalized to x86 arches should also default to "pc"
1007
+ pc98)
1008
+ cpu=i386
1009
+ vendor=pc
1010
+ ;;
1011
+ x64 | amd64)
1012
+ cpu=x86_64
1013
+ vendor=pc
1014
+ ;;
1015
+ # Recognize the basic CPU types without company name.
1016
+ *)
1017
+ cpu=$basic_machine
1018
+ vendor=unknown
1019
+ ;;
1020
+ esac
1021
+
1022
+ unset -v basic_machine
1023
+
1024
+ # Decode basic machines in the full and proper CPU-Company form.
1025
+ case $cpu-$vendor in
1026
+ # Here we handle the default manufacturer of certain CPU types in canonical form.
1027
+ # It is in some cases the only manufacturer, in others, it is the most popular.
1028
+ c[12]-convex | c[12]-unknown | c3[248]-convex | c3[248]-unknown)
1029
+ vendor=convex
1030
+ basic_os=${basic_os:-bsd}
1031
+ ;;
1032
+ craynv-unknown)
1033
+ vendor=cray
1034
+ basic_os=${basic_os:-unicosmp}
1035
+ ;;
1036
+ c90-unknown | c90-cray)
1037
+ vendor=cray
1038
+ basic_os=${basic_os:-unicos}
1039
+ ;;
1040
+ fx80-unknown)
1041
+ vendor=alliant
1042
+ ;;
1043
+ romp-unknown)
1044
+ vendor=ibm
1045
+ ;;
1046
+ mmix-unknown)
1047
+ vendor=knuth
1048
+ ;;
1049
+ microblaze-unknown | microblazeel-unknown)
1050
+ vendor=xilinx
1051
+ ;;
1052
+ rs6000-unknown)
1053
+ vendor=ibm
1054
+ ;;
1055
+ vax-unknown)
1056
+ vendor=dec
1057
+ ;;
1058
+ pdp11-unknown)
1059
+ vendor=dec
1060
+ ;;
1061
+ we32k-unknown)
1062
+ vendor=att
1063
+ ;;
1064
+ cydra-unknown)
1065
+ vendor=cydrome
1066
+ ;;
1067
+ i370-ibm*)
1068
+ vendor=ibm
1069
+ ;;
1070
+ orion-unknown)
1071
+ vendor=highlevel
1072
+ ;;
1073
+ xps-unknown | xps100-unknown)
1074
+ cpu=xps100
1075
+ vendor=honeywell
1076
+ ;;
1077
+
1078
+ # Here we normalize CPU types with a missing or matching vendor
1079
+ armh-unknown | armh-alt)
1080
+ cpu=armv7l
1081
+ vendor=alt
1082
+ basic_os=${basic_os:-linux-gnueabihf}
1083
+ ;;
1084
+
1085
+ # Normalized CPU+vendor pairs that imply an OS, if not otherwise specified
1086
+ m68k-isi)
1087
+ basic_os=${basic_os:-sysv}
1088
+ ;;
1089
+ m68k-sony)
1090
+ basic_os=${basic_os:-newsos}
1091
+ ;;
1092
+ m68k-tektronix)
1093
+ basic_os=${basic_os:-bsd}
1094
+ ;;
1095
+ m88k-harris)
1096
+ basic_os=${basic_os:-sysv3}
1097
+ ;;
1098
+ i386-bull | m68k-bull)
1099
+ basic_os=${basic_os:-sysv3}
1100
+ ;;
1101
+ rs6000-bull)
1102
+ basic_os=${basic_os:-bosx}
1103
+ ;;
1104
+ mips-sni)
1105
+ basic_os=${basic_os:-sysv4}
1106
+ ;;
1107
+
1108
+ # Here we normalize CPU types irrespective of the vendor
1109
+ amd64-*)
1110
+ cpu=x86_64
1111
+ ;;
1112
+ blackfin-*)
1113
+ cpu=bfin
1114
+ basic_os=${basic_os:-linux}
1115
+ ;;
1116
+ c54x-*)
1117
+ cpu=tic54x
1118
+ ;;
1119
+ c55x-*)
1120
+ cpu=tic55x
1121
+ ;;
1122
+ c6x-*)
1123
+ cpu=tic6x
1124
+ ;;
1125
+ e500v[12]-*)
1126
+ cpu=powerpc
1127
+ basic_os=${basic_os}"spe"
1128
+ ;;
1129
+ mips3*-*)
1130
+ cpu=mips64
1131
+ ;;
1132
+ ms1-*)
1133
+ cpu=mt
1134
+ ;;
1135
+ m68knommu-*)
1136
+ cpu=m68k
1137
+ basic_os=${basic_os:-linux}
1138
+ ;;
1139
+ m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
1140
+ cpu=s12z
1141
+ ;;
1142
+ openrisc-*)
1143
+ cpu=or32
1144
+ ;;
1145
+ parisc-*)
1146
+ cpu=hppa
1147
+ basic_os=${basic_os:-linux}
1148
+ ;;
1149
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
1150
+ cpu=i586
1151
+ ;;
1152
+ pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
1153
+ cpu=i686
1154
+ ;;
1155
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
1156
+ cpu=i686
1157
+ ;;
1158
+ pentium4-*)
1159
+ cpu=i786
1160
+ ;;
1161
+ ppc-* | ppcbe-*)
1162
+ cpu=powerpc
1163
+ ;;
1164
+ ppcle-* | powerpclittle-*)
1165
+ cpu=powerpcle
1166
+ ;;
1167
+ ppc64-*)
1168
+ cpu=powerpc64
1169
+ ;;
1170
+ ppc64le-* | powerpc64little-*)
1171
+ cpu=powerpc64le
1172
+ ;;
1173
+ sb1-*)
1174
+ cpu=mipsisa64sb1
1175
+ ;;
1176
+ sb1el-*)
1177
+ cpu=mipsisa64sb1el
1178
+ ;;
1179
+ sh5e[lb]-*)
1180
+ cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`
1181
+ ;;
1182
+ spur-*)
1183
+ cpu=spur
1184
+ ;;
1185
+ strongarm-* | thumb-*)
1186
+ cpu=arm
1187
+ ;;
1188
+ tx39-*)
1189
+ cpu=mipstx39
1190
+ ;;
1191
+ tx39el-*)
1192
+ cpu=mipstx39el
1193
+ ;;
1194
+ xscale-* | xscalee[bl]-*)
1195
+ cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
1196
+ ;;
1197
+ arm64-* | aarch64le-*)
1198
+ cpu=aarch64
1199
+ ;;
1200
+
1201
+ # Recognize the canonical CPU Types that limit and/or modify the
1202
+ # company names they are paired with.
1203
+ cr16-*)
1204
+ basic_os=${basic_os:-elf}
1205
+ ;;
1206
+ crisv32-* | etraxfs*-*)
1207
+ cpu=crisv32
1208
+ vendor=axis
1209
+ ;;
1210
+ cris-* | etrax*-*)
1211
+ cpu=cris
1212
+ vendor=axis
1213
+ ;;
1214
+ crx-*)
1215
+ basic_os=${basic_os:-elf}
1216
+ ;;
1217
+ neo-tandem)
1218
+ cpu=neo
1219
+ vendor=tandem
1220
+ ;;
1221
+ nse-tandem)
1222
+ cpu=nse
1223
+ vendor=tandem
1224
+ ;;
1225
+ nsr-tandem)
1226
+ cpu=nsr
1227
+ vendor=tandem
1228
+ ;;
1229
+ nsv-tandem)
1230
+ cpu=nsv
1231
+ vendor=tandem
1232
+ ;;
1233
+ nsx-tandem)
1234
+ cpu=nsx
1235
+ vendor=tandem
1236
+ ;;
1237
+ mipsallegrexel-sony)
1238
+ cpu=mipsallegrexel
1239
+ vendor=sony
1240
+ ;;
1241
+ tile*-*)
1242
+ basic_os=${basic_os:-linux-gnu}
1243
+ ;;
1244
+
1245
+ *)
1246
+ # Recognize the canonical CPU types that are allowed with any
1247
+ # company name.
1248
+ case $cpu in
1249
+ 1750a \
1250
+ | 580 \
1251
+ | [cjt]90 \
1252
+ | a29k \
1253
+ | aarch64 \
1254
+ | aarch64_be \
1255
+ | aarch64c \
1256
+ | abacus \
1257
+ | alpha \
1258
+ | alpha64 \
1259
+ | alpha64ev56 \
1260
+ | alpha64ev6[78] \
1261
+ | alpha64ev[4-8] \
1262
+ | alpha64pca5[67] \
1263
+ | alphaev56 \
1264
+ | alphaev6[78] \
1265
+ | alphaev[4-8] \
1266
+ | alphapca5[67] \
1267
+ | am33_2.0 \
1268
+ | amdgcn \
1269
+ | arc \
1270
+ | arc32 \
1271
+ | arc64 \
1272
+ | arceb \
1273
+ | arm \
1274
+ | arm64e \
1275
+ | arm64ec \
1276
+ | arm[lb]e \
1277
+ | arme[lb] \
1278
+ | armv* \
1279
+ | asmjs \
1280
+ | avr \
1281
+ | avr32 \
1282
+ | ba \
1283
+ | be32 \
1284
+ | be64 \
1285
+ | bfin \
1286
+ | bpf \
1287
+ | bs2000 \
1288
+ | c30 \
1289
+ | c4x \
1290
+ | c8051 \
1291
+ | c[123]* \
1292
+ | clipper \
1293
+ | craynv \
1294
+ | csky \
1295
+ | cydra \
1296
+ | d10v \
1297
+ | d30v \
1298
+ | dlx \
1299
+ | dsp16xx \
1300
+ | e2k \
1301
+ | elxsi \
1302
+ | epiphany \
1303
+ | f30[01] \
1304
+ | f700 \
1305
+ | fido \
1306
+ | fr30 \
1307
+ | frv \
1308
+ | ft32 \
1309
+ | fx80 \
1310
+ | h8300 \
1311
+ | h8500 \
1312
+ | hexagon \
1313
+ | hppa \
1314
+ | hppa1.[01] \
1315
+ | hppa2.0 \
1316
+ | hppa2.0[nw] \
1317
+ | hppa64 \
1318
+ | i*86 \
1319
+ | i370 \
1320
+ | i860 \
1321
+ | i960 \
1322
+ | ia16 \
1323
+ | ia64 \
1324
+ | ip2k \
1325
+ | iq2000 \
1326
+ | javascript \
1327
+ | k1om \
1328
+ | kvx \
1329
+ | le32 \
1330
+ | le64 \
1331
+ | lm32 \
1332
+ | loongarch32 \
1333
+ | loongarch64 \
1334
+ | m32c \
1335
+ | m32r \
1336
+ | m32rle \
1337
+ | m5200 \
1338
+ | m68000 \
1339
+ | m680[012346]0 \
1340
+ | m6811 \
1341
+ | m6812 \
1342
+ | m68360 \
1343
+ | m683?2 \
1344
+ | m68hc11 \
1345
+ | m68hc12 \
1346
+ | m68hcs12x \
1347
+ | m68k \
1348
+ | m88110 \
1349
+ | m88k \
1350
+ | maxq \
1351
+ | mb \
1352
+ | mcore \
1353
+ | mep \
1354
+ | metag \
1355
+ | microblaze \
1356
+ | microblazeel \
1357
+ | mips* \
1358
+ | mmix \
1359
+ | mn10200 \
1360
+ | mn10300 \
1361
+ | moxie \
1362
+ | msp430 \
1363
+ | mt \
1364
+ | nanomips* \
1365
+ | nds32 \
1366
+ | nds32be \
1367
+ | nds32le \
1368
+ | nfp \
1369
+ | nios \
1370
+ | nios2 \
1371
+ | nios2eb \
1372
+ | nios2el \
1373
+ | none \
1374
+ | np1 \
1375
+ | ns16k \
1376
+ | ns32k \
1377
+ | nvptx \
1378
+ | open8 \
1379
+ | or1k* \
1380
+ | or32 \
1381
+ | orion \
1382
+ | pdp10 \
1383
+ | pdp11 \
1384
+ | picochip \
1385
+ | pj \
1386
+ | pjl \
1387
+ | pn \
1388
+ | power \
1389
+ | powerpc \
1390
+ | powerpc64 \
1391
+ | powerpc64le \
1392
+ | powerpcle \
1393
+ | powerpcspe \
1394
+ | pru \
1395
+ | pyramid \
1396
+ | riscv \
1397
+ | riscv32 \
1398
+ | riscv32be \
1399
+ | riscv64 \
1400
+ | riscv64be \
1401
+ | rl78 \
1402
+ | romp \
1403
+ | rs6000 \
1404
+ | rx \
1405
+ | s390 \
1406
+ | s390x \
1407
+ | score \
1408
+ | sh \
1409
+ | sh64 \
1410
+ | sh64le \
1411
+ | sh[12345][lb]e \
1412
+ | sh[1234] \
1413
+ | sh[1234]e[lb] \
1414
+ | sh[23]e \
1415
+ | sh[23]ele \
1416
+ | sh[24]a \
1417
+ | sh[24]ae[lb] \
1418
+ | sh[lb]e \
1419
+ | she[lb] \
1420
+ | shl \
1421
+ | sparc \
1422
+ | sparc64 \
1423
+ | sparc64b \
1424
+ | sparc64v \
1425
+ | sparc86x \
1426
+ | sparclet \
1427
+ | sparclite \
1428
+ | sparcv8 \
1429
+ | sparcv9 \
1430
+ | sparcv9b \
1431
+ | sparcv9v \
1432
+ | spu \
1433
+ | sv1 \
1434
+ | sx* \
1435
+ | tahoe \
1436
+ | thumbv7* \
1437
+ | tic30 \
1438
+ | tic4x \
1439
+ | tic54x \
1440
+ | tic55x \
1441
+ | tic6x \
1442
+ | tic80 \
1443
+ | tron \
1444
+ | ubicom32 \
1445
+ | v70 \
1446
+ | v810 \
1447
+ | v850 \
1448
+ | v850e \
1449
+ | v850e1 \
1450
+ | v850e2 \
1451
+ | v850e2v3 \
1452
+ | v850es \
1453
+ | vax \
1454
+ | vc4 \
1455
+ | visium \
1456
+ | w65 \
1457
+ | wasm32 \
1458
+ | wasm64 \
1459
+ | we32k \
1460
+ | x86 \
1461
+ | x86_64 \
1462
+ | xc16x \
1463
+ | xgate \
1464
+ | xps100 \
1465
+ | xstormy16 \
1466
+ | xtensa* \
1467
+ | ymp \
1468
+ | z80 \
1469
+ | z8k)
1470
+ ;;
1471
+
1472
+ *)
1473
+ echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
1474
+ exit 1
1475
+ ;;
1476
+ esac
1477
+ ;;
1478
+ esac
1479
+
1480
+ # Here we canonicalize certain aliases for manufacturers.
1481
+ case $vendor in
1482
+ digital*)
1483
+ vendor=dec
1484
+ ;;
1485
+ commodore*)
1486
+ vendor=cbm
1487
+ ;;
1488
+ *)
1489
+ ;;
1490
+ esac
1491
+
1492
+ # Decode manufacturer-specific aliases for certain operating systems.
1493
+
1494
+ if test x"$basic_os" != x
1495
+ then
1496
+
1497
+ # First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
1498
+ # set os.
1499
+ obj=
1500
+ case $basic_os in
1501
+ gnu/linux*)
1502
+ kernel=linux
1503
+ os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
1504
+ ;;
1505
+ os2-emx)
1506
+ kernel=os2
1507
+ os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
1508
+ ;;
1509
+ nto-qnx*)
1510
+ kernel=nto
1511
+ os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
1512
+ ;;
1513
+ *-*)
1514
+ saved_IFS=$IFS
1515
+ IFS="-" read kernel os <<EOF
1516
+ $basic_os
1517
+ EOF
1518
+ IFS=$saved_IFS
1519
+ ;;
1520
+ # Default OS when just kernel was specified
1521
+ nto*)
1522
+ kernel=nto
1523
+ os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
1524
+ ;;
1525
+ linux*)
1526
+ kernel=linux
1527
+ os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
1528
+ ;;
1529
+ managarm*)
1530
+ kernel=managarm
1531
+ os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
1532
+ ;;
1533
+ *)
1534
+ kernel=
1535
+ os=$basic_os
1536
+ ;;
1537
+ esac
1538
+
1539
+ # Now, normalize the OS (knowing we just have one component, it's not a kernel,
1540
+ # etc.)
1541
+ case $os in
1542
+ # First match some system type aliases that might get confused
1543
+ # with valid system types.
1544
+ # solaris* is a basic system type, with this one exception.
1545
+ auroraux)
1546
+ os=auroraux
1547
+ ;;
1548
+ bluegene*)
1549
+ os=cnk
1550
+ ;;
1551
+ solaris1 | solaris1.*)
1552
+ os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
1553
+ ;;
1554
+ solaris)
1555
+ os=solaris2
1556
+ ;;
1557
+ unixware*)
1558
+ os=sysv4.2uw
1559
+ ;;
1560
+ # The marketing names for NeXT's operating systems were
1561
+ # NeXTSTEP, NeXTSTEP 2, OpenSTEP 3, OpenSTEP 4. 'openstep' is
1562
+ # mapped to 'openstep3', but 'openstep1' and 'openstep2' are
1563
+ # mapped to 'nextstep' and 'nextstep2', consistent with the
1564
+ # treatment of SunOS/Solaris.
1565
+ ns | ns1 | nextstep | nextstep1 | openstep1)
1566
+ os=nextstep
1567
+ ;;
1568
+ ns2 | nextstep2 | openstep2)
1569
+ os=nextstep2
1570
+ ;;
1571
+ ns3 | nextstep3 | openstep | openstep3)
1572
+ os=openstep3
1573
+ ;;
1574
+ ns4 | nextstep4 | openstep4)
1575
+ os=openstep4
1576
+ ;;
1577
+ # es1800 is here to avoid being matched by es* (a different OS)
1578
+ es1800*)
1579
+ os=ose
1580
+ ;;
1581
+ # Some version numbers need modification
1582
+ chorusos*)
1583
+ os=chorusos
1584
+ ;;
1585
+ isc)
1586
+ os=isc2.2
1587
+ ;;
1588
+ sco6)
1589
+ os=sco5v6
1590
+ ;;
1591
+ sco5)
1592
+ os=sco3.2v5
1593
+ ;;
1594
+ sco4)
1595
+ os=sco3.2v4
1596
+ ;;
1597
+ sco3.2.[4-9]*)
1598
+ os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
1599
+ ;;
1600
+ sco*v* | scout)
1601
+ # Don't match below
1602
+ ;;
1603
+ sco*)
1604
+ os=sco3.2v2
1605
+ ;;
1606
+ psos*)
1607
+ os=psos
1608
+ ;;
1609
+ qnx*)
1610
+ os=qnx
1611
+ ;;
1612
+ hiux*)
1613
+ os=hiuxwe2
1614
+ ;;
1615
+ lynx*178)
1616
+ os=lynxos178
1617
+ ;;
1618
+ lynx*5)
1619
+ os=lynxos5
1620
+ ;;
1621
+ lynxos*)
1622
+ # don't get caught up in next wildcard
1623
+ ;;
1624
+ lynx*)
1625
+ os=lynxos
1626
+ ;;
1627
+ mac[0-9]*)
1628
+ os=`echo "$os" | sed -e 's|mac|macos|'`
1629
+ ;;
1630
+ opened*)
1631
+ os=openedition
1632
+ ;;
1633
+ os400*)
1634
+ os=os400
1635
+ ;;
1636
+ sunos5*)
1637
+ os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
1638
+ ;;
1639
+ sunos6*)
1640
+ os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
1641
+ ;;
1642
+ wince*)
1643
+ os=wince
1644
+ ;;
1645
+ utek*)
1646
+ os=bsd
1647
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|tektronix|'`
1648
+ ;;
1649
+ dynix*)
1650
+ os=bsd
1651
+ ;;
1652
+ acis*)
1653
+ os=aos
1654
+ ;;
1655
+ atheos*)
1656
+ os=atheos
1657
+ ;;
1658
+ syllable*)
1659
+ os=syllable
1660
+ ;;
1661
+ 386bsd)
1662
+ os=bsd
1663
+ ;;
1664
+ ctix*)
1665
+ os=sysv
1666
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|convergent|'`
1667
+ ;;
1668
+ uts*)
1669
+ os=sysv
1670
+ ;;
1671
+ nova*)
1672
+ kernel=rtmk
1673
+ os=nova
1674
+ ;;
1675
+ # Preserve the version number of sinix5.
1676
+ sinix5.*)
1677
+ os=`echo "$os" | sed -e 's|sinix|sysv|'`
1678
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
1679
+ ;;
1680
+ sinix*)
1681
+ os=sysv4
1682
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
1683
+ ;;
1684
+ tpf*)
1685
+ os=tpf
1686
+ ;;
1687
+ triton*)
1688
+ os=sysv3
1689
+ ;;
1690
+ oss*)
1691
+ os=sysv3
1692
+ ;;
1693
+ svr4*)
1694
+ os=sysv4
1695
+ ;;
1696
+ svr3)
1697
+ os=sysv3
1698
+ ;;
1699
+ sysvr4)
1700
+ os=sysv4
1701
+ ;;
1702
+ ose*)
1703
+ os=ose
1704
+ ;;
1705
+ *mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
1706
+ os=mint
1707
+ ;;
1708
+ dicos*)
1709
+ os=dicos
1710
+ ;;
1711
+ pikeos*)
1712
+ # Until real need of OS specific support for
1713
+ # particular features comes up, bare metal
1714
+ # configurations are quite functional.
1715
+ case $cpu in
1716
+ arm*)
1717
+ os=eabi
1718
+ ;;
1719
+ *)
1720
+ os=
1721
+ obj=elf
1722
+ ;;
1723
+ esac
1724
+ ;;
1725
+ aout* | coff* | elf* | pe*)
1726
+ # These are machine code file formats, not OSes
1727
+ obj=$os
1728
+ os=
1729
+ ;;
1730
+ *)
1731
+ # No normalization, but not necessarily accepted, that comes below.
1732
+ ;;
1733
+ esac
1734
+
1735
+ else
1736
+
1737
+ # Here we handle the default operating systems that come with various machines.
1738
+ # The value should be what the vendor currently ships out the door with their
1739
+ # machine or put another way, the most popular os provided with the machine.
1740
+
1741
+ # Note that if you're going to try to match "-MANUFACTURER" here (say,
1742
+ # "-sun"), then you have to tell the case statement up towards the top
1743
+ # that MANUFACTURER isn't an operating system. Otherwise, code above
1744
+ # will signal an error saying that MANUFACTURER isn't an operating
1745
+ # system, and we'll never get to this point.
1746
+
1747
+ kernel=
1748
+ obj=
1749
+ case $cpu-$vendor in
1750
+ score-*)
1751
+ os=
1752
+ obj=elf
1753
+ ;;
1754
+ spu-*)
1755
+ os=
1756
+ obj=elf
1757
+ ;;
1758
+ *-acorn)
1759
+ os=riscix1.2
1760
+ ;;
1761
+ arm*-rebel)
1762
+ kernel=linux
1763
+ os=gnu
1764
+ ;;
1765
+ arm*-semi)
1766
+ os=
1767
+ obj=aout
1768
+ ;;
1769
+ c4x-* | tic4x-*)
1770
+ os=
1771
+ obj=coff
1772
+ ;;
1773
+ c8051-*)
1774
+ os=
1775
+ obj=elf
1776
+ ;;
1777
+ clipper-intergraph)
1778
+ os=clix
1779
+ ;;
1780
+ hexagon-*)
1781
+ os=
1782
+ obj=elf
1783
+ ;;
1784
+ tic54x-*)
1785
+ os=
1786
+ obj=coff
1787
+ ;;
1788
+ tic55x-*)
1789
+ os=
1790
+ obj=coff
1791
+ ;;
1792
+ tic6x-*)
1793
+ os=
1794
+ obj=coff
1795
+ ;;
1796
+ # This must come before the *-dec entry.
1797
+ pdp10-*)
1798
+ os=tops20
1799
+ ;;
1800
+ pdp11-*)
1801
+ os=none
1802
+ ;;
1803
+ *-dec | vax-*)
1804
+ os=ultrix4.2
1805
+ ;;
1806
+ m68*-apollo)
1807
+ os=domain
1808
+ ;;
1809
+ i386-sun)
1810
+ os=sunos4.0.2
1811
+ ;;
1812
+ m68000-sun)
1813
+ os=sunos3
1814
+ ;;
1815
+ m68*-cisco)
1816
+ os=
1817
+ obj=aout
1818
+ ;;
1819
+ mep-*)
1820
+ os=
1821
+ obj=elf
1822
+ ;;
1823
+ # The -sgi and -siemens entries must be before the mips- entry
1824
+ # or we get the wrong os.
1825
+ *-sgi)
1826
+ os=irix
1827
+ ;;
1828
+ *-siemens)
1829
+ os=sysv4
1830
+ ;;
1831
+ mips*-cisco)
1832
+ os=
1833
+ obj=elf
1834
+ ;;
1835
+ mips*-*|nanomips*-*)
1836
+ os=
1837
+ obj=elf
1838
+ ;;
1839
+ or32-*)
1840
+ os=
1841
+ obj=coff
1842
+ ;;
1843
+ # This must be before the sparc-* entry or we get the wrong os.
1844
+ *-tti)
1845
+ os=sysv3
1846
+ ;;
1847
+ sparc-* | *-sun)
1848
+ os=sunos4.1.1
1849
+ ;;
1850
+ pru-*)
1851
+ os=
1852
+ obj=elf
1853
+ ;;
1854
+ *-be)
1855
+ os=beos
1856
+ ;;
1857
+ *-ibm)
1858
+ os=aix
1859
+ ;;
1860
+ *-knuth)
1861
+ os=mmixware
1862
+ ;;
1863
+ *-wec)
1864
+ os=proelf
1865
+ ;;
1866
+ *-winbond)
1867
+ os=proelf
1868
+ ;;
1869
+ *-oki)
1870
+ os=proelf
1871
+ ;;
1872
+ *-hp)
1873
+ os=hpux
1874
+ ;;
1875
+ *-hitachi)
1876
+ os=hiuxwe2
1877
+ ;;
1878
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1879
+ os=sysv
1880
+ ;;
1881
+ *-cbm)
1882
+ os=amigaos
1883
+ ;;
1884
+ *-dg)
1885
+ os=dgux
1886
+ ;;
1887
+ *-dolphin)
1888
+ os=sysv3
1889
+ ;;
1890
+ m68k-ccur)
1891
+ os=rtu
1892
+ ;;
1893
+ m88k-omron*)
1894
+ os=luna
1895
+ ;;
1896
+ *-next)
1897
+ os=nextstep
1898
+ ;;
1899
+ *-sequent)
1900
+ os=ptx
1901
+ ;;
1902
+ *-crds)
1903
+ os=unos
1904
+ ;;
1905
+ *-ns)
1906
+ os=genix
1907
+ ;;
1908
+ i370-*)
1909
+ os=mvs
1910
+ ;;
1911
+ *-gould)
1912
+ os=sysv
1913
+ ;;
1914
+ *-highlevel)
1915
+ os=bsd
1916
+ ;;
1917
+ *-encore)
1918
+ os=bsd
1919
+ ;;
1920
+ *-masscomp)
1921
+ os=rtu
1922
+ ;;
1923
+ f30[01]-fujitsu | f700-fujitsu)
1924
+ os=uxpv
1925
+ ;;
1926
+ *-rom68k)
1927
+ os=
1928
+ obj=coff
1929
+ ;;
1930
+ *-*bug)
1931
+ os=
1932
+ obj=coff
1933
+ ;;
1934
+ *-apple)
1935
+ os=macos
1936
+ ;;
1937
+ *-atari*)
1938
+ os=mint
1939
+ ;;
1940
+ *-wrs)
1941
+ os=vxworks
1942
+ ;;
1943
+ *)
1944
+ os=none
1945
+ ;;
1946
+ esac
1947
+
1948
+ fi
1949
+
1950
+ # Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
1951
+
1952
+ case $os in
1953
+ # Sometimes we do "kernel-libc", so those need to count as OSes.
1954
+ llvm* | musl* | newlib* | relibc* | uclibc*)
1955
+ ;;
1956
+ # Likewise for "kernel-abi"
1957
+ eabi* | gnueabi*)
1958
+ ;;
1959
+ # VxWorks passes extra cpu info in the 4th filed.
1960
+ simlinux | simwindows | spe)
1961
+ ;;
1962
+ # See `case $cpu-$os` validation below
1963
+ ghcjs)
1964
+ ;;
1965
+ # Now accept the basic system types.
1966
+ # Each alternative MUST end in a * to match a version number.
1967
+ abug \
1968
+ | aix* \
1969
+ | amdhsa* \
1970
+ | amigados* \
1971
+ | amigaos* \
1972
+ | android* \
1973
+ | aof* \
1974
+ | aos* \
1975
+ | aros* \
1976
+ | atheos* \
1977
+ | auroraux* \
1978
+ | aux* \
1979
+ | beos* \
1980
+ | bitrig* \
1981
+ | bme* \
1982
+ | bosx* \
1983
+ | bsd* \
1984
+ | cegcc* \
1985
+ | chorusos* \
1986
+ | chorusrdb* \
1987
+ | clix* \
1988
+ | cloudabi* \
1989
+ | cnk* \
1990
+ | conix* \
1991
+ | cos* \
1992
+ | cxux* \
1993
+ | cygwin* \
1994
+ | darwin* \
1995
+ | dgux* \
1996
+ | dicos* \
1997
+ | dnix* \
1998
+ | domain* \
1999
+ | dragonfly* \
2000
+ | drops* \
2001
+ | ebmon* \
2002
+ | ecoff* \
2003
+ | ekkobsd* \
2004
+ | emscripten* \
2005
+ | emx* \
2006
+ | es* \
2007
+ | fiwix* \
2008
+ | freebsd* \
2009
+ | fuchsia* \
2010
+ | genix* \
2011
+ | genode* \
2012
+ | glidix* \
2013
+ | gnu* \
2014
+ | go32* \
2015
+ | haiku* \
2016
+ | hcos* \
2017
+ | hiux* \
2018
+ | hms* \
2019
+ | hpux* \
2020
+ | ieee* \
2021
+ | interix* \
2022
+ | ios* \
2023
+ | iris* \
2024
+ | irix* \
2025
+ | ironclad* \
2026
+ | isc* \
2027
+ | its* \
2028
+ | l4re* \
2029
+ | libertybsd* \
2030
+ | lites* \
2031
+ | lnews* \
2032
+ | luna* \
2033
+ | lynxos* \
2034
+ | mach* \
2035
+ | macos* \
2036
+ | magic* \
2037
+ | mbr* \
2038
+ | midipix* \
2039
+ | midnightbsd* \
2040
+ | mingw32* \
2041
+ | mingw64* \
2042
+ | minix* \
2043
+ | mint* \
2044
+ | mirbsd* \
2045
+ | mks* \
2046
+ | mlibc* \
2047
+ | mmixware* \
2048
+ | mon960* \
2049
+ | morphos* \
2050
+ | moss* \
2051
+ | moxiebox* \
2052
+ | mpeix* \
2053
+ | mpw* \
2054
+ | msdos* \
2055
+ | msys* \
2056
+ | mvs* \
2057
+ | nacl* \
2058
+ | netbsd* \
2059
+ | netware* \
2060
+ | newsos* \
2061
+ | nextstep* \
2062
+ | nindy* \
2063
+ | nonstopux* \
2064
+ | nova* \
2065
+ | nsk* \
2066
+ | nucleus* \
2067
+ | nx6 \
2068
+ | nx7 \
2069
+ | oabi* \
2070
+ | ohos* \
2071
+ | onefs* \
2072
+ | openbsd* \
2073
+ | openedition* \
2074
+ | openstep* \
2075
+ | os108* \
2076
+ | os2* \
2077
+ | os400* \
2078
+ | os68k* \
2079
+ | os9* \
2080
+ | ose* \
2081
+ | osf* \
2082
+ | oskit* \
2083
+ | osx* \
2084
+ | palmos* \
2085
+ | phoenix* \
2086
+ | plan9* \
2087
+ | powermax* \
2088
+ | powerunix* \
2089
+ | proelf* \
2090
+ | psos* \
2091
+ | psp* \
2092
+ | ptx* \
2093
+ | pw32* \
2094
+ | qnx* \
2095
+ | rdos* \
2096
+ | redox* \
2097
+ | rhapsody* \
2098
+ | riscix* \
2099
+ | riscos* \
2100
+ | rtems* \
2101
+ | rtmk* \
2102
+ | rtu* \
2103
+ | scout* \
2104
+ | secbsd* \
2105
+ | sei* \
2106
+ | serenity* \
2107
+ | sim* \
2108
+ | skyos* \
2109
+ | solaris* \
2110
+ | solidbsd* \
2111
+ | sortix* \
2112
+ | storm-chaos* \
2113
+ | sunos \
2114
+ | sunos[34]* \
2115
+ | superux* \
2116
+ | syllable* \
2117
+ | sym* \
2118
+ | sysv* \
2119
+ | tenex* \
2120
+ | tirtos* \
2121
+ | toppers* \
2122
+ | tops10* \
2123
+ | tops20* \
2124
+ | tpf* \
2125
+ | tvos* \
2126
+ | twizzler* \
2127
+ | uclinux* \
2128
+ | udi* \
2129
+ | udk* \
2130
+ | ultrix* \
2131
+ | unicos* \
2132
+ | uniplus* \
2133
+ | unleashed* \
2134
+ | unos* \
2135
+ | uwin* \
2136
+ | uxpv* \
2137
+ | v88r* \
2138
+ |*vms* \
2139
+ | vos* \
2140
+ | vsta* \
2141
+ | vxsim* \
2142
+ | vxworks* \
2143
+ | wasi* \
2144
+ | watchos* \
2145
+ | wince* \
2146
+ | windiss* \
2147
+ | windows* \
2148
+ | winnt* \
2149
+ | xenix* \
2150
+ | xray* \
2151
+ | zephyr* \
2152
+ | zvmoe* )
2153
+ ;;
2154
+ # This one is extra strict with allowed versions
2155
+ sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
2156
+ # Don't forget version if it is 3.2v4 or newer.
2157
+ ;;
2158
+ # This refers to builds using the UEFI calling convention
2159
+ # (which depends on the architecture) and PE file format.
2160
+ # Note that this is both a different calling convention and
2161
+ # different file format than that of GNU-EFI
2162
+ # (x86_64-w64-mingw32).
2163
+ uefi)
2164
+ ;;
2165
+ none)
2166
+ ;;
2167
+ kernel* | msvc* )
2168
+ # Restricted further below
2169
+ ;;
2170
+ '')
2171
+ if test x"$obj" = x
2172
+ then
2173
+ echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
2174
+ fi
2175
+ ;;
2176
+ *)
2177
+ echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
2178
+ exit 1
2179
+ ;;
2180
+ esac
2181
+
2182
+ case $obj in
2183
+ aout* | coff* | elf* | pe*)
2184
+ ;;
2185
+ '')
2186
+ # empty is fine
2187
+ ;;
2188
+ *)
2189
+ echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
2190
+ exit 1
2191
+ ;;
2192
+ esac
2193
+
2194
+ # Here we handle the constraint that a (synthetic) cpu and os are
2195
+ # valid only in combination with each other and nowhere else.
2196
+ case $cpu-$os in
2197
+ # The "javascript-unknown-ghcjs" triple is used by GHC; we
2198
+ # accept it here in order to tolerate that, but reject any
2199
+ # variations.
2200
+ javascript-ghcjs)
2201
+ ;;
2202
+ javascript-* | *-ghcjs)
2203
+ echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
2204
+ exit 1
2205
+ ;;
2206
+ esac
2207
+
2208
+ # As a final step for OS-related things, validate the OS-kernel combination
2209
+ # (given a valid OS), if there is a kernel.
2210
+ case $kernel-$os-$obj in
2211
+ linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
2212
+ | linux-mlibc*- | linux-musl*- | linux-newlib*- \
2213
+ | linux-relibc*- | linux-uclibc*- | linux-ohos*- )
2214
+ ;;
2215
+ uclinux-uclibc*- | uclinux-gnu*- )
2216
+ ;;
2217
+ managarm-mlibc*- | managarm-kernel*- )
2218
+ ;;
2219
+ windows*-msvc*-)
2220
+ ;;
2221
+ -dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \
2222
+ | -uclibc*- )
2223
+ # These are just libc implementations, not actual OSes, and thus
2224
+ # require a kernel.
2225
+ echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
2226
+ exit 1
2227
+ ;;
2228
+ -kernel*- )
2229
+ echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
2230
+ exit 1
2231
+ ;;
2232
+ *-kernel*- )
2233
+ echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
2234
+ exit 1
2235
+ ;;
2236
+ *-msvc*- )
2237
+ echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
2238
+ exit 1
2239
+ ;;
2240
+ kfreebsd*-gnu*- | knetbsd*-gnu*- | netbsd*-gnu*- | kopensolaris*-gnu*-)
2241
+ ;;
2242
+ vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
2243
+ ;;
2244
+ nto-qnx*-)
2245
+ ;;
2246
+ os2-emx-)
2247
+ ;;
2248
+ rtmk-nova-)
2249
+ ;;
2250
+ *-eabi*- | *-gnueabi*-)
2251
+ ;;
2252
+ none--*)
2253
+ # None (no kernel, i.e. freestanding / bare metal),
2254
+ # can be paired with an machine code file format
2255
+ ;;
2256
+ -*-)
2257
+ # Blank kernel with real OS is always fine.
2258
+ ;;
2259
+ --*)
2260
+ # Blank kernel and OS with real machine code file format is always fine.
2261
+ ;;
2262
+ *-*-*)
2263
+ echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
2264
+ exit 1
2265
+ ;;
2266
+ esac
2267
+
2268
+ # Here we handle the case where we know the os, and the CPU type, but not the
2269
+ # manufacturer. We pick the logical manufacturer.
2270
+ case $vendor in
2271
+ unknown)
2272
+ case $cpu-$os in
2273
+ *-riscix*)
2274
+ vendor=acorn
2275
+ ;;
2276
+ *-sunos* | *-solaris*)
2277
+ vendor=sun
2278
+ ;;
2279
+ *-cnk* | *-aix*)
2280
+ vendor=ibm
2281
+ ;;
2282
+ *-beos*)
2283
+ vendor=be
2284
+ ;;
2285
+ *-hpux*)
2286
+ vendor=hp
2287
+ ;;
2288
+ *-mpeix*)
2289
+ vendor=hp
2290
+ ;;
2291
+ *-hiux*)
2292
+ vendor=hitachi
2293
+ ;;
2294
+ *-unos*)
2295
+ vendor=crds
2296
+ ;;
2297
+ *-dgux*)
2298
+ vendor=dg
2299
+ ;;
2300
+ *-luna*)
2301
+ vendor=omron
2302
+ ;;
2303
+ *-genix*)
2304
+ vendor=ns
2305
+ ;;
2306
+ *-clix*)
2307
+ vendor=intergraph
2308
+ ;;
2309
+ *-mvs* | *-opened*)
2310
+ vendor=ibm
2311
+ ;;
2312
+ *-os400*)
2313
+ vendor=ibm
2314
+ ;;
2315
+ s390-* | s390x-*)
2316
+ vendor=ibm
2317
+ ;;
2318
+ *-ptx*)
2319
+ vendor=sequent
2320
+ ;;
2321
+ *-tpf*)
2322
+ vendor=ibm
2323
+ ;;
2324
+ *-vxsim* | *-vxworks* | *-windiss*)
2325
+ vendor=wrs
2326
+ ;;
2327
+ *-aux*)
2328
+ vendor=apple
2329
+ ;;
2330
+ *-hms*)
2331
+ vendor=hitachi
2332
+ ;;
2333
+ *-mpw* | *-macos*)
2334
+ vendor=apple
2335
+ ;;
2336
+ *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
2337
+ vendor=atari
2338
+ ;;
2339
+ *-vos*)
2340
+ vendor=stratus
2341
+ ;;
2342
+ esac
2343
+ ;;
2344
+ esac
2345
+
2346
+ echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
2347
+ exit
2348
+
2349
+ # Local variables:
2350
+ # eval: (add-hook 'before-save-hook 'time-stamp)
2351
+ # time-stamp-start: "timestamp='"
2352
+ # time-stamp-format: "%:y-%02m-%02d"
2353
+ # time-stamp-end: "'"
2354
+ # End:
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/autosetup-find-tclsh ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # Looks for a suitable tclsh or jimsh in the PATH
3
+ # If not found, builds a bootstrap jimsh in current dir from source
4
+ # Prefer $autosetup_tclsh if is set in the environment (unless ./jimsh0 works)
5
+ # If an argument is given, use that as the test instead of autosetup-test-tclsh
6
+ d="`dirname "$0"`"
7
+ for tclsh in ./jimsh0 $autosetup_tclsh jimsh tclsh tclsh8.5 tclsh8.6 tclsh8.7; do
8
+ { $tclsh "$d/${1-autosetup-test-tclsh}"; } 2>/dev/null && exit 0
9
+ done
10
+ echo 1>&2 "No installed jimsh or tclsh, building local bootstrap jimsh0"
11
+ for cc in ${CC_FOR_BUILD:-cc} gcc; do
12
+ { $cc -o jimsh0 "$d/jimsh0.c"; } >/dev/null 2>&1 || continue
13
+ ./jimsh0 "$d/${1-autosetup-test-tclsh}" && exit 0
14
+ done
15
+ echo 1>&2 "No working C compiler found. Tried ${CC_FOR_BUILD:-cc} and gcc."
16
+ echo false
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/autosetup-test-tclsh ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A small Tcl script to verify that the chosen
2
+ # interpreter works. Sometimes we might e.g. pick up
3
+ # an interpreter for a different arch.
4
+ # Outputs the full path to the interpreter
5
+
6
+ if {[catch {info version} version] == 0} {
7
+ # This is Jim Tcl
8
+ if {$version >= 0.72} {
9
+ # Ensure that regexp works
10
+ regexp (a.*?) a
11
+ puts [info nameofexecutable]
12
+ exit 0
13
+ }
14
+ } elseif {[catch {info tclversion} version] == 0} {
15
+ if {$version >= 8.5 && ![string match 8.5a* [info patchlevel]]} {
16
+ puts [info nameofexecutable]
17
+ exit 0
18
+ }
19
+ }
20
+ exit 1
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/cc-db.tcl ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
2
+ # All rights reserved
3
+
4
+ # @synopsis:
5
+ #
6
+ # The 'cc-db' module provides a knowledge-base of system idiosyncrasies.
7
+ # In general, this module can always be included.
8
+
9
+ use cc
10
+
11
+ options {}
12
+
13
+ # openbsd needs sys/types.h to detect some system headers
14
+ cc-include-needs sys/socket.h sys/types.h
15
+ cc-include-needs netinet/in.h sys/types.h
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/cc-lib.tcl ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2011 WorkWare Systems http://www.workware.net.au/
2
+ # All rights reserved
3
+
4
+ # @synopsis:
5
+ #
6
+ # Provides a library of common tests on top of the 'cc' module.
7
+
8
+ use cc
9
+
10
+ # @cc-check-lfs
11
+ #
12
+ # The equivalent of the 'AC_SYS_LARGEFILE' macro.
13
+ #
14
+ # defines 'HAVE_LFS' if LFS is available,
15
+ # and defines '_FILE_OFFSET_BITS=64' if necessary
16
+ #
17
+ # Returns 1 if 'LFS' is available or 0 otherwise
18
+ #
19
+ proc cc-check-lfs {} {
20
+ cc-check-includes sys/types.h
21
+ msg-checking "Checking if -D_FILE_OFFSET_BITS=64 is needed..."
22
+ set lfs 1
23
+ if {[msg-quiet cc-with {-includes sys/types.h} {cc-check-sizeof off_t}] == 8} {
24
+ msg-result no
25
+ } elseif {[msg-quiet cc-with {-includes sys/types.h -cflags -D_FILE_OFFSET_BITS=64} {cc-check-sizeof off_t}] == 8} {
26
+ define _FILE_OFFSET_BITS 64
27
+ msg-result yes
28
+ } else {
29
+ set lfs 0
30
+ msg-result none
31
+ }
32
+ define-feature lfs $lfs
33
+ return $lfs
34
+ }
35
+
36
+ # @cc-check-endian
37
+ #
38
+ # The equivalent of the 'AC_C_BIGENDIAN' macro.
39
+ #
40
+ # defines 'HAVE_BIG_ENDIAN' if endian is known to be big,
41
+ # or 'HAVE_LITTLE_ENDIAN' if endian is known to be little.
42
+ #
43
+ # Returns 1 if determined, or 0 if not.
44
+ #
45
+ proc cc-check-endian {} {
46
+ cc-check-includes sys/types.h sys/param.h
47
+ set rc 0
48
+ msg-checking "Checking endian..."
49
+ cc-with {-includes {sys/types.h sys/param.h}} {
50
+ if {[cctest -code {
51
+ #if !defined(BIG_ENDIAN) || !defined(BYTE_ORDER)
52
+ #error unknown
53
+ #elif BYTE_ORDER != BIG_ENDIAN
54
+ #error little
55
+ #endif
56
+ }]} {
57
+ define-feature big-endian
58
+ msg-result "big"
59
+ set rc 1
60
+ } elseif {[cctest -code {
61
+ #if !defined(LITTLE_ENDIAN) || !defined(BYTE_ORDER)
62
+ #error unknown
63
+ #elif BYTE_ORDER != LITTLE_ENDIAN
64
+ #error big
65
+ #endif
66
+ }]} {
67
+ define-feature little-endian
68
+ msg-result "little"
69
+ set rc 1
70
+ } else {
71
+ msg-result "unknown"
72
+ }
73
+ }
74
+ return $rc
75
+ }
76
+
77
+ # @cc-check-flags flag ?...?
78
+ #
79
+ # Checks whether the given C/C++ compiler flags can be used. Defines feature
80
+ # names prefixed with 'HAVE_CFLAG' and 'HAVE_CXXFLAG' respectively, and
81
+ # appends working flags to '-cflags' and 'AS_CFLAGS' or 'AS_CXXFLAGS'.
82
+ proc cc-check-flags {args} {
83
+ set result 1
84
+ array set opts [cc-get-settings]
85
+ switch -exact -- $opts(-lang) {
86
+ c++ {
87
+ set lang C++
88
+ set prefix CXXFLAG
89
+ }
90
+ c {
91
+ set lang C
92
+ set prefix CFLAG
93
+ }
94
+ default {
95
+ autosetup-error "cc-check-flags failed with unknown language: $opts(-lang)"
96
+ }
97
+ }
98
+ foreach flag $args {
99
+ msg-checking "Checking whether the $lang compiler accepts $flag..."
100
+ if {[cctest -cflags $flag]} {
101
+ msg-result yes
102
+ define-feature $prefix$flag
103
+ cc-with [list -cflags [list $flag]]
104
+ define-append AS_${prefix}S $flag
105
+ } else {
106
+ msg-result no
107
+ set result 0
108
+ }
109
+ }
110
+ return $result
111
+ }
112
+
113
+ # @cc-check-standards ver ?...?
114
+ #
115
+ # Checks whether the C/C++ compiler accepts one of the specified '-std=$ver'
116
+ # options, and appends the first working one to '-cflags' and 'AS_CFLAGS' or
117
+ # 'AS_CXXFLAGS'.
118
+ proc cc-check-standards {args} {
119
+ array set opts [cc-get-settings]
120
+ foreach std $args {
121
+ if {[cc-check-flags -std=$std]} {
122
+ return $std
123
+ }
124
+ }
125
+ return ""
126
+ }
127
+
128
+ # Checks whether $keyword is usable as alignof
129
+ proc cctest_alignof {keyword} {
130
+ msg-checking "Checking for $keyword..."
131
+ if {[cctest -code "int x = ${keyword}(char), y = ${keyword}('x');"]} then {
132
+ msg-result ok
133
+ define-feature $keyword
134
+ } else {
135
+ msg-result "not found"
136
+ }
137
+ }
138
+
139
+ # @cc-check-c11
140
+ #
141
+ # Checks for several C11/C++11 extensions and their alternatives. Currently
142
+ # checks for '_Static_assert', '_Alignof', '__alignof__', '__alignof'.
143
+ proc cc-check-c11 {} {
144
+ msg-checking "Checking for _Static_assert..."
145
+ if {[cctest -code {
146
+ _Static_assert(1, "static assertions are available");
147
+ }]} then {
148
+ msg-result ok
149
+ define-feature _Static_assert
150
+ } else {
151
+ msg-result "not found"
152
+ }
153
+
154
+ cctest_alignof _Alignof
155
+ cctest_alignof __alignof__
156
+ cctest_alignof __alignof
157
+ }
158
+
159
+ # @cc-check-alloca
160
+ #
161
+ # The equivalent of the 'AC_FUNC_ALLOCA' macro.
162
+ #
163
+ # Checks for the existence of 'alloca'
164
+ # defines 'HAVE_ALLOCA' and returns 1 if it exists.
165
+ proc cc-check-alloca {} {
166
+ cc-check-some-feature alloca {
167
+ cctest -includes alloca.h -code { alloca (2 * sizeof (int)); }
168
+ }
169
+ }
170
+
171
+ # @cc-signal-return-type
172
+ #
173
+ # The equivalent of the 'AC_TYPE_SIGNAL' macro.
174
+ #
175
+ # defines 'RETSIGTYPE' to 'int' or 'void'.
176
+ proc cc-signal-return-type {} {
177
+ msg-checking "Checking return type of signal handlers..."
178
+ cc-with {-includes {sys/types.h signal.h}} {
179
+ if {[cctest -code {return *(signal (0, 0)) (0) == 1;}]} {
180
+ set type int
181
+ } else {
182
+ set type void
183
+ }
184
+ define RETSIGTYPE $type
185
+ msg-result $type
186
+ }
187
+ }
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/cc-shared.tcl ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
2
+ # All rights reserved
3
+
4
+ # @synopsis:
5
+ #
6
+ # The 'cc-shared' module provides support for shared libraries and shared objects.
7
+ # It defines the following variables:
8
+ #
9
+ ## SH_CFLAGS Flags to use compiling sources destined for a shared library
10
+ ## SH_LDFLAGS Flags to use linking (creating) a shared library
11
+ ## SH_SOPREFIX Prefix to use to set the soname when creating a shared library
12
+ ## SH_SOFULLPATH Set to 1 if the shared library soname should include the full install path
13
+ ## SH_SOEXT Extension for shared libs
14
+ ## SH_SOEXTVER Format for versioned shared libs - %s = version
15
+ ## SHOBJ_CFLAGS Flags to use compiling sources destined for a shared object
16
+ ## SHOBJ_LDFLAGS Flags to use linking a shared object, undefined symbols allowed
17
+ ## SHOBJ_LDFLAGS_R - as above, but all symbols must be resolved
18
+ ## SH_LINKRPATH Format for setting the rpath when linking an executable, %s = path
19
+ ## SH_LINKFLAGS Flags to use linking an executable which will load shared objects
20
+ ## LD_LIBRARY_PATH Environment variable which specifies path to shared libraries
21
+ ## STRIPLIBFLAGS Arguments to strip a dynamic library
22
+
23
+ options {}
24
+
25
+ # Defaults: gcc on unix
26
+ define SHOBJ_CFLAGS -fPIC
27
+ define SHOBJ_LDFLAGS -shared
28
+ define SH_CFLAGS -fPIC
29
+ define SH_LDFLAGS -shared
30
+ define SH_LINKFLAGS -rdynamic
31
+ define SH_LINKRPATH "-Wl,-rpath -Wl,%s"
32
+ define SH_SOEXT .so
33
+ define SH_SOEXTVER .so.%s
34
+ define SH_SOPREFIX -Wl,-soname,
35
+ define LD_LIBRARY_PATH LD_LIBRARY_PATH
36
+ define STRIPLIBFLAGS --strip-unneeded
37
+
38
+ # Note: This is a helpful reference for identifying the toolchain
39
+ # http://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers
40
+
41
+ switch -glob -- [get-define host] {
42
+ *-*-darwin* {
43
+ define SHOBJ_CFLAGS "-dynamic -fno-common"
44
+ define SHOBJ_LDFLAGS "-bundle -undefined dynamic_lookup"
45
+ define SHOBJ_LDFLAGS_R -bundle
46
+ define SH_CFLAGS -dynamic
47
+ define SH_LDFLAGS -dynamiclib
48
+ define SH_LINKFLAGS ""
49
+ define SH_SOEXT .dylib
50
+ define SH_SOEXTVER .%s.dylib
51
+ define SH_SOPREFIX -Wl,-install_name,
52
+ define SH_SOFULLPATH
53
+ define LD_LIBRARY_PATH DYLD_LIBRARY_PATH
54
+ define STRIPLIBFLAGS -x
55
+ }
56
+ *-*-ming* - *-*-cygwin - *-*-msys {
57
+ define SHOBJ_CFLAGS ""
58
+ define SHOBJ_LDFLAGS -shared
59
+ define SH_CFLAGS ""
60
+ define SH_LDFLAGS -shared
61
+ define SH_LINKRPATH ""
62
+ define SH_LINKFLAGS ""
63
+ define SH_SOEXT .dll
64
+ define SH_SOEXTVER .dll
65
+ define SH_SOPREFIX ""
66
+ define LD_LIBRARY_PATH PATH
67
+ }
68
+ sparc* {
69
+ if {[msg-quiet cc-check-decls __SUNPRO_C]} {
70
+ msg-result "Found sun stdio compiler"
71
+ # sun stdio compiler
72
+ # XXX: These haven't been fully tested.
73
+ define SHOBJ_CFLAGS -KPIC
74
+ define SHOBJ_LDFLAGS "-G"
75
+ define SH_CFLAGS -KPIC
76
+ define SH_LINKFLAGS -Wl,-export-dynamic
77
+ define SH_SOPREFIX -Wl,-h,
78
+ }
79
+ }
80
+ *-*-solaris* {
81
+ if {[msg-quiet cc-check-decls __SUNPRO_C]} {
82
+ msg-result "Found sun stdio compiler"
83
+ # sun stdio compiler
84
+ # XXX: These haven't been fully tested.
85
+ define SHOBJ_CFLAGS -KPIC
86
+ define SHOBJ_LDFLAGS "-G"
87
+ define SH_CFLAGS -KPIC
88
+ define SH_LINKFLAGS -Wl,-export-dynamic
89
+ define SH_SOPREFIX -Wl,-h,
90
+ }
91
+ }
92
+ *-*-hpux {
93
+ # XXX: These haven't been tested
94
+ define SHOBJ_CFLAGS "+O3 +z"
95
+ define SHOBJ_LDFLAGS -b
96
+ define SH_CFLAGS +z
97
+ define SH_LINKFLAGS -Wl,+s
98
+ define LD_LIBRARY_PATH SHLIB_PATH
99
+ }
100
+ *-*-haiku {
101
+ define SHOBJ_CFLAGS ""
102
+ define SHOBJ_LDFLAGS -shared
103
+ define SH_CFLAGS ""
104
+ define SH_LDFLAGS -shared
105
+ define SH_LINKFLAGS ""
106
+ define SH_SOPREFIX ""
107
+ define LD_LIBRARY_PATH LIBRARY_PATH
108
+ }
109
+ }
110
+
111
+ if {![is-defined SHOBJ_LDFLAGS_R]} {
112
+ define SHOBJ_LDFLAGS_R [get-define SHOBJ_LDFLAGS]
113
+ }
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/cc.tcl ADDED
@@ -0,0 +1,758 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
2
+ # All rights reserved
3
+
4
+ # @synopsis:
5
+ #
6
+ # The 'cc' module supports checking various 'features' of the C or C++
7
+ # compiler/linker environment. Common commands are 'cc-check-includes',
8
+ # 'cc-check-types', 'cc-check-functions', 'cc-with' and 'make-config-header'
9
+ #
10
+ # The following environment variables are used if set:
11
+ #
12
+ ## CC - C compiler
13
+ ## CXX - C++ compiler
14
+ ## CPP - C preprocessor
15
+ ## CCACHE - Set to "none" to disable automatic use of ccache
16
+ ## CPPFLAGS - Additional C preprocessor compiler flags (C and C++), before CFLAGS, CXXFLAGS
17
+ ## CFLAGS - Additional C compiler flags
18
+ ## CXXFLAGS - Additional C++ compiler flags
19
+ ## LDFLAGS - Additional compiler flags during linking
20
+ ## LINKFLAGS - ?How is this different from LDFLAGS?
21
+ ## LIBS - Additional libraries to use (for all tests)
22
+ ## CROSS - Tool prefix for cross compilation
23
+ #
24
+ # The following variables are defined from the corresponding
25
+ # environment variables if set.
26
+ #
27
+ ## CC_FOR_BUILD
28
+ ## LD
29
+
30
+ use system
31
+
32
+ options {}
33
+
34
+ # Checks for the existence of the given function by linking
35
+ #
36
+ proc cctest_function {function} {
37
+ cctest -link 1 -declare "extern void $function\(void);" -code "$function\();"
38
+ }
39
+
40
+ # Checks for the existence of the given type by compiling
41
+ proc cctest_type {type} {
42
+ cctest -code "$type _x;"
43
+ }
44
+
45
+ # Checks for the existence of the given type/structure member.
46
+ # e.g. "struct stat.st_mtime"
47
+ proc cctest_member {struct_member} {
48
+ # split at the first dot
49
+ regexp {^([^.]+)[.](.*)$} $struct_member -> struct member
50
+ cctest -code "static $struct _s; return sizeof(_s.$member);"
51
+ }
52
+
53
+ # Checks for the existence of the given define by compiling
54
+ #
55
+ proc cctest_define {name} {
56
+ cctest -code "#ifndef $name\n#error not defined\n#endif"
57
+ }
58
+
59
+ # Checks for the existence of the given name either as
60
+ # a macro (#define) or an rvalue (such as an enum)
61
+ #
62
+ proc cctest_decl {name} {
63
+ cctest -code "#ifndef $name\n(void)$name;\n#endif"
64
+ }
65
+
66
+ # @cc-check-sizeof type ...
67
+ #
68
+ # Checks the size of the given types (between 1 and 32, inclusive).
69
+ # Defines a variable with the size determined, or 'unknown' otherwise.
70
+ # e.g. for type 'long long', defines 'SIZEOF_LONG_LONG'.
71
+ # Returns the size of the last type.
72
+ #
73
+ proc cc-check-sizeof {args} {
74
+ foreach type $args {
75
+ msg-checking "Checking for sizeof $type..."
76
+ set size unknown
77
+ # Try the most common sizes first
78
+ foreach i {4 8 1 2 16 32} {
79
+ if {[cctest -code "static int _x\[sizeof($type) == $i ? 1 : -1\] = { 1 };"]} {
80
+ set size $i
81
+ break
82
+ }
83
+ }
84
+ msg-result $size
85
+ set define [feature-define-name $type SIZEOF_]
86
+ define $define $size
87
+ }
88
+ # Return the last result
89
+ get-define $define
90
+ }
91
+
92
+ # Checks for each feature in $list by using the given script.
93
+ #
94
+ # When the script is evaluated, $each is set to the feature
95
+ # being checked, and $extra is set to any additional cctest args.
96
+ #
97
+ # Returns 1 if all features were found, or 0 otherwise.
98
+ proc cc-check-some-feature {list script} {
99
+ set ret 1
100
+ foreach each $list {
101
+ if {![check-feature $each $script]} {
102
+ set ret 0
103
+ }
104
+ }
105
+ return $ret
106
+ }
107
+
108
+ # @cc-check-includes includes ...
109
+ #
110
+ # Checks that the given include files can be used.
111
+ proc cc-check-includes {args} {
112
+ cc-check-some-feature $args {
113
+ set with {}
114
+ if {[dict exists $::autosetup(cc-include-deps) $each]} {
115
+ set deps [dict keys [dict get $::autosetup(cc-include-deps) $each]]
116
+ msg-quiet cc-check-includes {*}$deps
117
+ foreach i $deps {
118
+ if {[have-feature $i]} {
119
+ lappend with $i
120
+ }
121
+ }
122
+ }
123
+ if {[llength $with]} {
124
+ cc-with [list -includes $with] {
125
+ cctest -includes $each
126
+ }
127
+ } else {
128
+ cctest -includes $each
129
+ }
130
+ }
131
+ }
132
+
133
+ # @cc-include-needs include required ...
134
+ #
135
+ # Ensures that when checking for '$include', a check is first
136
+ # made for each '$required' file, and if found, it is included with '#include'.
137
+ proc cc-include-needs {file args} {
138
+ foreach depfile $args {
139
+ dict set ::autosetup(cc-include-deps) $file $depfile 1
140
+ }
141
+ }
142
+
143
+ # @cc-check-types type ...
144
+ #
145
+ # Checks that the types exist.
146
+ proc cc-check-types {args} {
147
+ cc-check-some-feature $args {
148
+ cctest_type $each
149
+ }
150
+ }
151
+
152
+ # @cc-check-defines define ...
153
+ #
154
+ # Checks that the given preprocessor symbols are defined.
155
+ proc cc-check-defines {args} {
156
+ cc-check-some-feature $args {
157
+ cctest_define $each
158
+ }
159
+ }
160
+
161
+ # @cc-check-decls name ...
162
+ #
163
+ # Checks that each given name is either a preprocessor symbol or rvalue
164
+ # such as an enum. Note that the define used is 'HAVE_DECL_xxx'
165
+ # rather than 'HAVE_xxx'.
166
+ proc cc-check-decls {args} {
167
+ set ret 1
168
+ foreach name $args {
169
+ msg-checking "Checking for $name..."
170
+ set r [cctest_decl $name]
171
+ define-feature "decl $name" $r
172
+ if {$r} {
173
+ msg-result "ok"
174
+ } else {
175
+ msg-result "not found"
176
+ set ret 0
177
+ }
178
+ }
179
+ return $ret
180
+ }
181
+
182
+ # @cc-check-functions function ...
183
+ #
184
+ # Checks that the given functions exist (can be linked).
185
+ proc cc-check-functions {args} {
186
+ cc-check-some-feature $args {
187
+ cctest_function $each
188
+ }
189
+ }
190
+
191
+ # @cc-check-members type.member ...
192
+ #
193
+ # Checks that the given type/structure members exist.
194
+ # A structure member is of the form 'struct stat.st_mtime'.
195
+ proc cc-check-members {args} {
196
+ cc-check-some-feature $args {
197
+ cctest_member $each
198
+ }
199
+ }
200
+
201
+ # @cc-check-function-in-lib function libs ?otherlibs?
202
+ #
203
+ # Checks that the given function can be found in one of the libs.
204
+ #
205
+ # First checks for no library required, then checks each of the libraries
206
+ # in turn.
207
+ #
208
+ # If the function is found, the feature is defined and 'lib_$function' is defined
209
+ # to '-l$lib' where the function was found, or "" if no library required.
210
+ # In addition, '-l$lib' is prepended to the 'LIBS' define.
211
+ #
212
+ # If additional libraries may be needed for linking, they should be specified
213
+ # with '$extralibs' as '-lotherlib1 -lotherlib2'.
214
+ # These libraries are not automatically added to 'LIBS'.
215
+ #
216
+ # Returns 1 if found or 0 if not.
217
+ #
218
+ proc cc-check-function-in-lib {function libs {otherlibs {}}} {
219
+ msg-checking "Checking libs for $function..."
220
+ set found 0
221
+ cc-with [list -libs $otherlibs] {
222
+ if {[cctest_function $function]} {
223
+ msg-result "none needed"
224
+ define lib_$function ""
225
+ incr found
226
+ } else {
227
+ foreach lib $libs {
228
+ cc-with [list -libs -l$lib] {
229
+ if {[cctest_function $function]} {
230
+ msg-result -l$lib
231
+ define lib_$function -l$lib
232
+ # prepend to LIBS
233
+ define LIBS "-l$lib [get-define LIBS]"
234
+ incr found
235
+ break
236
+ }
237
+ }
238
+ }
239
+ }
240
+ }
241
+ define-feature $function $found
242
+ if {!$found} {
243
+ msg-result "no"
244
+ }
245
+ return $found
246
+ }
247
+
248
+ # @cc-check-tools tool ...
249
+ #
250
+ # Checks for existence of the given compiler tools, taking
251
+ # into account any cross compilation prefix.
252
+ #
253
+ # For example, when checking for 'ar', first 'AR' is checked on the command
254
+ # line and then in the environment. If not found, '${host}-ar' or
255
+ # simply 'ar' is assumed depending upon whether cross compiling.
256
+ # The path is searched for this executable, and if found 'AR' is defined
257
+ # to the executable name.
258
+ # Note that even when cross compiling, the simple 'ar' is used as a fallback,
259
+ # but a warning is generated. This is necessary for some toolchains.
260
+ #
261
+ # It is an error if the executable is not found.
262
+ #
263
+ proc cc-check-tools {args} {
264
+ foreach tool $args {
265
+ set TOOL [string toupper $tool]
266
+ set exe [get-env $TOOL [get-define cross]$tool]
267
+ if {[find-executable $exe]} {
268
+ define $TOOL $exe
269
+ continue
270
+ }
271
+ if {[find-executable $tool]} {
272
+ msg-result "Warning: Failed to find $exe, falling back to $tool which may be incorrect"
273
+ define $TOOL $tool
274
+ continue
275
+ }
276
+ user-error "Failed to find $exe"
277
+ }
278
+ }
279
+
280
+ # @cc-check-progs prog ...
281
+ #
282
+ # Checks for existence of the given executables on the path.
283
+ #
284
+ # For example, when checking for 'grep', the path is searched for
285
+ # the executable, 'grep', and if found 'GREP' is defined as 'grep'.
286
+ #
287
+ # If the executable is not found, the variable is defined as 'false'.
288
+ # Returns 1 if all programs were found, or 0 otherwise.
289
+ #
290
+ proc cc-check-progs {args} {
291
+ set failed 0
292
+ foreach prog $args {
293
+ set PROG [string toupper $prog]
294
+ msg-checking "Checking for $prog..."
295
+ if {![find-executable $prog]} {
296
+ msg-result no
297
+ define $PROG false
298
+ incr failed
299
+ } else {
300
+ msg-result ok
301
+ define $PROG $prog
302
+ }
303
+ }
304
+ expr {!$failed}
305
+ }
306
+
307
+ # @cc-path-progs prog ...
308
+ #
309
+ # Like cc-check-progs, but sets the define to the full path rather
310
+ # than just the program name.
311
+ #
312
+ proc cc-path-progs {args} {
313
+ set failed 0
314
+ foreach prog $args {
315
+ set PROG [string toupper $prog]
316
+ msg-checking "Checking for $prog..."
317
+ set path [find-executable-path $prog]
318
+ if {$path eq ""} {
319
+ msg-result no
320
+ define $PROG false
321
+ incr failed
322
+ } else {
323
+ msg-result $path
324
+ define $PROG $path
325
+ }
326
+ }
327
+ expr {!$failed}
328
+ }
329
+
330
+ # Adds the given settings to $::autosetup(ccsettings) and
331
+ # returns the old settings.
332
+ #
333
+ proc cc-add-settings {settings} {
334
+ if {[llength $settings] % 2} {
335
+ autosetup-error "settings list is missing a value: $settings"
336
+ }
337
+
338
+ set prev [cc-get-settings]
339
+ # workaround a bug in some versions of jimsh by forcing
340
+ # conversion of $prev to a list
341
+ llength $prev
342
+
343
+ array set new $prev
344
+
345
+ foreach {name value} $settings {
346
+ switch -exact -- $name {
347
+ -cflags - -includes {
348
+ # These are given as lists
349
+ lappend new($name) {*}[list-non-empty $value]
350
+ }
351
+ -declare {
352
+ lappend new($name) $value
353
+ }
354
+ -libs {
355
+ # Note that new libraries are added before previous libraries
356
+ set new($name) [list {*}[list-non-empty $value] {*}$new($name)]
357
+ }
358
+ -link - -lang - -nooutput {
359
+ set new($name) $value
360
+ }
361
+ -source - -sourcefile - -code {
362
+ # XXX: These probably are only valid directly from cctest
363
+ set new($name) $value
364
+ }
365
+ default {
366
+ autosetup-error "unknown cctest setting: $name"
367
+ }
368
+ }
369
+ }
370
+
371
+ cc-store-settings [array get new]
372
+
373
+ return $prev
374
+ }
375
+
376
+ proc cc-store-settings {new} {
377
+ set ::autosetup(ccsettings) $new
378
+ }
379
+
380
+ proc cc-get-settings {} {
381
+ return $::autosetup(ccsettings)
382
+ }
383
+
384
+ # Similar to cc-add-settings, but each given setting
385
+ # simply replaces the existing value.
386
+ #
387
+ # Returns the previous settings
388
+ proc cc-update-settings {args} {
389
+ set prev [cc-get-settings]
390
+ cc-store-settings [dict merge $prev $args]
391
+ return $prev
392
+ }
393
+
394
+ # @cc-with settings ?{ script }?
395
+ #
396
+ # Sets the given 'cctest' settings and then runs the tests in '$script'.
397
+ # Note that settings such as '-lang' replace the current setting, while
398
+ # those such as '-includes' are appended to the existing setting.
399
+ #
400
+ # If no script is given, the settings become the default for the remainder
401
+ # of the 'auto.def' file.
402
+ #
403
+ ## cc-with {-lang c++} {
404
+ ## # This will check with the C++ compiler
405
+ ## cc-check-types bool
406
+ ## cc-with {-includes signal.h} {
407
+ ## # This will check with the C++ compiler, signal.h and any existing includes.
408
+ ## ...
409
+ ## }
410
+ ## # back to just the C++ compiler
411
+ ## }
412
+ #
413
+ # The '-libs' setting is special in that newer values are added *before* earlier ones.
414
+ #
415
+ ## cc-with {-libs {-lc -lm}} {
416
+ ## cc-with {-libs -ldl} {
417
+ ## cctest -libs -lsocket ...
418
+ ## # libs will be in this order: -lsocket -ldl -lc -lm
419
+ ## }
420
+ ## }
421
+ #
422
+ # If you wish to invoke something like cc-check-flags but not have -cflags updated,
423
+ # use the following idiom:
424
+ #
425
+ ## cc-with {} {
426
+ ## cc-check-flags ...
427
+ ## }
428
+ proc cc-with {settings args} {
429
+ if {[llength $args] == 0} {
430
+ cc-add-settings $settings
431
+ } elseif {[llength $args] > 1} {
432
+ autosetup-error "usage: cc-with settings ?script?"
433
+ } else {
434
+ set save [cc-add-settings $settings]
435
+ set rc [catch {uplevel 1 [lindex $args 0]} result info]
436
+ cc-store-settings $save
437
+ if {$rc != 0} {
438
+ return -code [dict get $info -code] $result
439
+ }
440
+ return $result
441
+ }
442
+ }
443
+
444
+ # @cctest ?settings?
445
+ #
446
+ # Low level C/C++ compiler checker. Compiles and or links a small C program
447
+ # according to the arguments and returns 1 if OK, or 0 if not.
448
+ #
449
+ # Supported settings are:
450
+ #
451
+ ## -cflags cflags A list of flags to pass to the compiler
452
+ ## -includes list A list of includes, e.g. {stdlib.h stdio.h}
453
+ ## -declare code Code to declare before main()
454
+ ## -link 1 Don't just compile, link too
455
+ ## -lang c|c++ Use the C (default) or C++ compiler
456
+ ## -libs liblist List of libraries to link, e.g. {-ldl -lm}
457
+ ## -code code Code to compile in the body of main()
458
+ ## -source code Compile a complete program. Ignore -includes, -declare and -code
459
+ ## -sourcefile file Shorthand for -source [readfile [get-define srcdir]/$file]
460
+ ## -nooutput 1 Treat any compiler output (e.g. a warning) as an error
461
+ #
462
+ # Unless '-source' or '-sourcefile' is specified, the C program looks like:
463
+ #
464
+ ## #include <firstinclude> /* same for remaining includes in the list */
465
+ ## declare-code /* any code in -declare, verbatim */
466
+ ## int main(void) {
467
+ ## code /* any code in -code, verbatim */
468
+ ## return 0;
469
+ ## }
470
+ #
471
+ # And the command line looks like:
472
+ #
473
+ ## CC -cflags CFLAGS CPPFLAGS conftest.c -o conftest.o
474
+ ## CXX -cflags CXXFLAGS CPPFLAGS conftest.cpp -o conftest.o
475
+ #
476
+ # And if linking:
477
+ #
478
+ ## CC LDFLAGS -cflags CFLAGS conftest.c -o conftest -libs LIBS
479
+ ## CXX LDFLAGS -cflags CXXFLAGS conftest.c -o conftest -libs LIBS
480
+ #
481
+ # Any failures are recorded in 'config.log'
482
+ #
483
+ proc cctest {args} {
484
+ set tmp conftest__
485
+
486
+ # Easiest way to merge in the settings
487
+ cc-with $args {
488
+ array set opts [cc-get-settings]
489
+ }
490
+
491
+ if {[info exists opts(-sourcefile)]} {
492
+ set opts(-source) [readfile [get-define srcdir]/$opts(-sourcefile) "#error can't find $opts(-sourcefile)"]
493
+ }
494
+ if {[info exists opts(-source)]} {
495
+ set lines $opts(-source)
496
+ } else {
497
+ foreach i $opts(-includes) {
498
+ if {$opts(-code) ne "" && ![feature-checked $i]} {
499
+ # Compiling real code with an unchecked header file
500
+ # Quickly (and silently) check for it now
501
+
502
+ # Remove all -includes from settings before checking
503
+ set saveopts [cc-update-settings -includes {}]
504
+ msg-quiet cc-check-includes $i
505
+ cc-store-settings $saveopts
506
+ }
507
+ if {$opts(-code) eq "" || [have-feature $i]} {
508
+ lappend source "#include <$i>"
509
+ }
510
+ }
511
+ lappend source {*}$opts(-declare)
512
+ lappend source "int main(void) {"
513
+ lappend source $opts(-code)
514
+ lappend source "return 0;"
515
+ lappend source "}"
516
+
517
+ set lines [join $source \n]
518
+ }
519
+
520
+ # Build the command line
521
+ set cmdline {}
522
+ lappend cmdline {*}[get-define CCACHE]
523
+ switch -exact -- $opts(-lang) {
524
+ c++ {
525
+ set src conftest__.cpp
526
+ lappend cmdline {*}[get-define CXX]
527
+ set cflags [get-define CXXFLAGS]
528
+ }
529
+ c {
530
+ set src conftest__.c
531
+ lappend cmdline {*}[get-define CC]
532
+ set cflags [get-define CFLAGS]
533
+ }
534
+ default {
535
+ autosetup-error "cctest called with unknown language: $opts(-lang)"
536
+ }
537
+ }
538
+
539
+ if {$opts(-link)} {
540
+ lappend cmdline {*}[get-define LDFLAGS]
541
+ } else {
542
+ lappend cflags {*}[get-define CPPFLAGS]
543
+ set tmp conftest__.o
544
+ lappend cmdline -c
545
+ }
546
+ lappend cmdline {*}$opts(-cflags) {*}[get-define cc-default-debug ""] {*}$cflags
547
+ lappend cmdline $src -o $tmp
548
+ if {$opts(-link)} {
549
+ lappend cmdline {*}$opts(-libs) {*}[get-define LIBS]
550
+ }
551
+
552
+ # At this point we have the complete command line and the
553
+ # complete source to be compiled. Get the result from cache if
554
+ # we can
555
+ if {[info exists ::cc_cache($cmdline,$lines)]} {
556
+ msg-checking "(cached) "
557
+ set ok $::cc_cache($cmdline,$lines)
558
+ if {$::autosetup(debug)} {
559
+ configlog "From cache (ok=$ok): [join $cmdline]"
560
+ configlog "============"
561
+ configlog $lines
562
+ configlog "============"
563
+ }
564
+ return $ok
565
+ }
566
+
567
+ writefile $src $lines\n
568
+
569
+ set ok 1
570
+ set err [catch {exec-with-stderr {*}$cmdline} result errinfo]
571
+ if {$err || ($opts(-nooutput) && [string length $result])} {
572
+ configlog "Failed: [join $cmdline]"
573
+ configlog $result
574
+ configlog "============"
575
+ configlog "The failed code was:"
576
+ configlog $lines
577
+ configlog "============"
578
+ set ok 0
579
+ } elseif {$::autosetup(debug)} {
580
+ configlog "Compiled OK: [join $cmdline]"
581
+ configlog "============"
582
+ configlog $lines
583
+ configlog "============"
584
+ }
585
+ file delete $src
586
+ file delete $tmp
587
+
588
+ # cache it
589
+ set ::cc_cache($cmdline,$lines) $ok
590
+
591
+ return $ok
592
+ }
593
+
594
+ # @make-autoconf-h outfile ?auto-patterns=HAVE_*? ?bare-patterns=SIZEOF_*?
595
+ #
596
+ # Deprecated - see 'make-config-header'
597
+ proc make-autoconf-h {file {autopatterns {HAVE_*}} {barepatterns {SIZEOF_* HAVE_DECL_*}}} {
598
+ user-notice "*** make-autoconf-h is deprecated -- use make-config-header instead"
599
+ make-config-header $file -auto $autopatterns -bare $barepatterns
600
+ }
601
+
602
+ # @make-config-header outfile ?-auto patternlist? ?-bare patternlist? ?-none patternlist? ?-str patternlist? ...
603
+ #
604
+ # Examines all defined variables which match the given patterns
605
+ # and writes an include file, '$file', which defines each of these.
606
+ # Variables which match '-auto' are output as follows:
607
+ # - defines which have the value '0' are ignored.
608
+ # - defines which have integer values are defined as the integer value.
609
+ # - any other value is defined as a string, e.g. '"value"'
610
+ # Variables which match '-bare' are defined as-is.
611
+ # Variables which match '-str' are defined as a string, e.g. '"value"'
612
+ # Variables which match '-none' are omitted.
613
+ #
614
+ # Note that order is important. The first pattern that matches is selected.
615
+ # Default behaviour is:
616
+ #
617
+ ## -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_* -none *
618
+ #
619
+ # If the file would be unchanged, it is not written.
620
+ proc make-config-header {file args} {
621
+ set guard _[string toupper [regsub -all {[^a-zA-Z0-9]} [file tail $file] _]]
622
+ file mkdir [file dirname $file]
623
+ set lines {}
624
+ lappend lines "#ifndef $guard"
625
+ lappend lines "#define $guard"
626
+
627
+ # Add some defaults
628
+ lappend args -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_*
629
+
630
+ foreach n [lsort [dict keys [all-defines]]] {
631
+ set value [get-define $n]
632
+ set type [calc-define-output-type $n $args]
633
+ switch -exact -- $type {
634
+ -bare {
635
+ # Just output the value unchanged
636
+ }
637
+ -none {
638
+ continue
639
+ }
640
+ -str {
641
+ set value \"[string map [list \\ \\\\ \" \\\"] $value]\"
642
+ }
643
+ -auto {
644
+ # Automatically determine the type
645
+ if {$value eq "0"} {
646
+ lappend lines "/* #undef $n */"
647
+ continue
648
+ }
649
+ if {![string is integer -strict $value]} {
650
+ set value \"[string map [list \\ \\\\ \" \\\"] $value]\"
651
+ }
652
+ }
653
+ "" {
654
+ continue
655
+ }
656
+ default {
657
+ autosetup-error "Unknown type in make-config-header: $type"
658
+ }
659
+ }
660
+ lappend lines "#define $n $value"
661
+ }
662
+ lappend lines "#endif"
663
+ set buf [join $lines \n]
664
+ write-if-changed $file $buf {
665
+ msg-result "Created $file"
666
+ }
667
+ }
668
+
669
+ proc calc-define-output-type {name spec} {
670
+ foreach {type patterns} $spec {
671
+ foreach pattern $patterns {
672
+ if {[string match $pattern $name]} {
673
+ return $type
674
+ }
675
+ }
676
+ }
677
+ return ""
678
+ }
679
+
680
+ proc cc-init {} {
681
+ global autosetup
682
+
683
+ # Initialise some values from the environment or commandline or default settings
684
+ foreach i {LDFLAGS LIBS CPPFLAGS LINKFLAGS CFLAGS} {
685
+ lassign $i var default
686
+ define $var [get-env $var $default]
687
+ }
688
+
689
+ if {[env-is-set CC]} {
690
+ # Set by the user, so don't try anything else
691
+ set try [list [get-env CC ""]]
692
+ } else {
693
+ # Try some reasonable options
694
+ set try [list [get-define cross]cc [get-define cross]gcc]
695
+ }
696
+ define CC [find-an-executable {*}$try]
697
+ if {[get-define CC] eq ""} {
698
+ user-error "Could not find a C compiler. Tried: [join $try ", "]"
699
+ }
700
+
701
+ define CPP [get-env CPP "[get-define CC] -E"]
702
+
703
+ # XXX: Could avoid looking for a C++ compiler until requested
704
+ # If CXX isn't found, it is set to the empty string.
705
+ if {[env-is-set CXX]} {
706
+ define CXX [find-an-executable -required [get-env CXX ""]]
707
+ } else {
708
+ define CXX [find-an-executable [get-define cross]c++ [get-define cross]g++]
709
+ }
710
+
711
+ # CXXFLAGS default to CFLAGS if not specified
712
+ define CXXFLAGS [get-env CXXFLAGS [get-define CFLAGS]]
713
+
714
+ # May need a CC_FOR_BUILD, so look for one
715
+ define CC_FOR_BUILD [find-an-executable [get-env CC_FOR_BUILD ""] cc gcc false]
716
+
717
+ # These start empty and never come from the user or environment
718
+ define AS_CFLAGS ""
719
+ define AS_CPPFLAGS ""
720
+ define AS_CXXFLAGS ""
721
+
722
+ define CCACHE [find-an-executable [get-env CCACHE ccache]]
723
+
724
+ # If any of these are set in the environment, propagate them to the AUTOREMAKE commandline
725
+ foreach i {CC CXX CCACHE CPP CFLAGS CXXFLAGS CXXFLAGS LDFLAGS LIBS CROSS CPPFLAGS LINKFLAGS CC_FOR_BUILD LD} {
726
+ if {[env-is-set $i]} {
727
+ # Note: If the variable is set on the command line, get-env will return that value
728
+ # so the command line will continue to override the environment
729
+ define-append-argv AUTOREMAKE $i=[get-env $i ""]
730
+ }
731
+ }
732
+
733
+ # Initial cctest settings
734
+ cc-store-settings {-cflags {} -includes {} -declare {} -link 0 -lang c -libs {} -code {} -nooutput 0}
735
+ set autosetup(cc-include-deps) {}
736
+
737
+ msg-result "C compiler...[get-define CCACHE] [get-define CC] [get-define CFLAGS] [get-define CPPFLAGS]"
738
+ if {[get-define CXX] ne "false"} {
739
+ msg-result "C++ compiler...[get-define CCACHE] [get-define CXX] [get-define CXXFLAGS] [get-define CPPFLAGS]"
740
+ }
741
+ msg-result "Build C compiler...[get-define CC_FOR_BUILD]"
742
+
743
+ # On Darwin, we prefer to use -g0 to avoid creating .dSYM directories
744
+ # but some compilers may not support it, so test here.
745
+ switch -glob -- [get-define host] {
746
+ *-*-darwin* {
747
+ if {[cctest -cflags {-g0}]} {
748
+ define cc-default-debug -g0
749
+ }
750
+ }
751
+ }
752
+
753
+ if {![cc-check-includes stdlib.h]} {
754
+ user-error "Compiler does not work. See config.log"
755
+ }
756
+ }
757
+
758
+ cc-init
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/jimsh0.c ADDED
The diff for this file is too large to render. See raw diff
 
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/pkg-config.tcl ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2016 WorkWare Systems http://www.workware.net.au/
2
+ # All rights reserved
3
+
4
+ # @synopsis:
5
+ #
6
+ # The 'pkg-config' module allows package information to be found via 'pkg-config'.
7
+ #
8
+ # If not cross-compiling, the package path should be determined automatically
9
+ # by 'pkg-config'.
10
+ # If cross-compiling, the default package path is the compiler sysroot.
11
+ # If the C compiler doesn't support '-print-sysroot', the path can be supplied
12
+ # by the '--sysroot' option or by defining 'SYSROOT'.
13
+ #
14
+ # 'PKG_CONFIG' may be set to use an alternative to 'pkg-config'.
15
+
16
+ use cc
17
+
18
+ options {
19
+ sysroot:dir => "Override compiler sysroot for pkg-config search path"
20
+ }
21
+
22
+ # @pkg-config-init ?required?
23
+ #
24
+ # Initialises the 'pkg-config' system. Unless '$required' is set to 0,
25
+ # it is a fatal error if a usable 'pkg-config' is not found .
26
+ #
27
+ # This command will normally be called automatically as required,
28
+ # but it may be invoked explicitly if lack of 'pkg-config' is acceptable.
29
+ #
30
+ # Returns 1 if ok, or 0 if 'pkg-config' not found/usable (only if '$required' is 0).
31
+ #
32
+ proc pkg-config-init {{required 1}} {
33
+ if {[is-defined HAVE_PKG_CONFIG]} {
34
+ return [get-define HAVE_PKG_CONFIG]
35
+ }
36
+ set found 0
37
+
38
+ define PKG_CONFIG [get-env PKG_CONFIG pkg-config]
39
+ msg-checking "Checking for pkg-config..."
40
+
41
+ if {[catch {exec [get-define PKG_CONFIG] --version} version]} {
42
+ msg-result "[get-define PKG_CONFIG] (not found)"
43
+ if {$required} {
44
+ user-error "No usable pkg-config"
45
+ }
46
+ } else {
47
+ msg-result $version
48
+ define PKG_CONFIG_VERSION $version
49
+
50
+ set found 1
51
+
52
+ if {[opt-str sysroot o]} {
53
+ define SYSROOT [file-normalize $o]
54
+ msg-result "Using specified sysroot [get-define SYSROOT]"
55
+ } elseif {[get-define build] ne [get-define host]} {
56
+ if {[catch {exec-with-stderr {*}[get-define CC] -print-sysroot} result errinfo] == 0} {
57
+ # Use the compiler sysroot, if there is one
58
+ define SYSROOT $result
59
+ msg-result "Found compiler sysroot $result"
60
+ } else {
61
+ configlog "[get-define CC] -print-sysroot: $result"
62
+ set msg "pkg-config: Cross compiling, but no compiler sysroot and no --sysroot supplied"
63
+ if {$required} {
64
+ user-error $msg
65
+ } else {
66
+ msg-result $msg
67
+ }
68
+ set found 0
69
+ }
70
+ }
71
+ if {[is-defined SYSROOT]} {
72
+ set sysroot [get-define SYSROOT]
73
+
74
+ # XXX: It's possible that these should be set only when invoking pkg-config
75
+ global env
76
+ set env(PKG_CONFIG_DIR) ""
77
+ # Supposedly setting PKG_CONFIG_LIBDIR means that PKG_CONFIG_PATH is ignored,
78
+ # but it doesn't seem to work that way in practice
79
+ set env(PKG_CONFIG_PATH) ""
80
+ # Do we need to try /usr/local as well or instead?
81
+ set env(PKG_CONFIG_LIBDIR) $sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig
82
+ set env(PKG_CONFIG_SYSROOT_DIR) $sysroot
83
+ }
84
+ }
85
+ define HAVE_PKG_CONFIG $found
86
+ return $found
87
+ }
88
+
89
+ # @pkg-config module ?requirements?
90
+ #
91
+ # Use 'pkg-config' to find the given module meeting the given requirements.
92
+ # e.g.
93
+ #
94
+ ## pkg-config pango >= 1.37.0
95
+ #
96
+ # If found, returns 1 and sets 'HAVE_PKG_PANGO' to 1 along with:
97
+ #
98
+ ## PKG_PANGO_VERSION to the found version
99
+ ## PKG_PANGO_LIBS to the required libs (--libs-only-l)
100
+ ## PKG_PANGO_LDFLAGS to the required linker flags (--libs-only-L)
101
+ ## PKG_PANGO_CFLAGS to the required compiler flags (--cflags)
102
+ #
103
+ # If not found, returns 0.
104
+ #
105
+ proc pkg-config {module args} {
106
+ set ok [pkg-config-init]
107
+
108
+ msg-checking "Checking for $module $args..."
109
+
110
+ if {!$ok} {
111
+ msg-result "no pkg-config"
112
+ return 0
113
+ }
114
+
115
+ set pkgconfig [get-define PKG_CONFIG]
116
+
117
+ set ret [catch {exec $pkgconfig --modversion "$module $args"} version]
118
+ configlog "$pkgconfig --modversion $module $args: $version"
119
+ if {$ret} {
120
+ msg-result "not found"
121
+ return 0
122
+ }
123
+ # Sometimes --modversion succeeds but because of dependencies it isn't usable
124
+ # This seems to show up with --cflags
125
+ set ret [catch {exec $pkgconfig --cflags $module} cflags]
126
+ if {$ret} {
127
+ msg-result "unusable ($version - see config.log)"
128
+ configlog "$pkgconfig --cflags $module"
129
+ configlog $cflags
130
+ return 0
131
+ }
132
+ msg-result $version
133
+ set prefix [feature-define-name $module PKG_]
134
+ define HAVE_${prefix}
135
+ define ${prefix}_VERSION $version
136
+ define ${prefix}_CFLAGS $cflags
137
+ define ${prefix}_LIBS [exec $pkgconfig --libs-only-l $module]
138
+ define ${prefix}_LDFLAGS [exec $pkgconfig --libs-only-L $module]
139
+ return 1
140
+ }
141
+
142
+ # @pkg-config-get module setting
143
+ #
144
+ # Convenience access to the results of 'pkg-config'.
145
+ #
146
+ # For example, '[pkg-config-get pango CFLAGS]' returns
147
+ # the value of 'PKG_PANGO_CFLAGS', or '""' if not defined.
148
+ proc pkg-config-get {module name} {
149
+ set prefix [feature-define-name $module PKG_]
150
+ get-define ${prefix}_${name} ""
151
+ }
152
+
153
+ # @pkg-config-get-var module variable
154
+ #
155
+ # Return the value of the given variable from the given pkg-config module.
156
+ # The module must already have been successfully detected with pkg-config.
157
+ # e.g.
158
+ #
159
+ ## if {[pkg-config harfbuzz >= 2.5]} {
160
+ ## define harfbuzz_libdir [pkg-config-get-var harfbuzz libdir]
161
+ ## }
162
+ #
163
+ # Returns the empty string if the variable isn't defined.
164
+ proc pkg-config-get-var {module variable} {
165
+ set pkgconfig [get-define PKG_CONFIG]
166
+ set prefix [feature-define-name $module HAVE_PKG_]
167
+ exec $pkgconfig $module --variable $variable
168
+ }
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/proj.tcl ADDED
@@ -0,0 +1,1269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ########################################################################
2
+ # 2024 September 25
3
+ #
4
+ # The author disclaims copyright to this source code. In place of
5
+ # a legal notice, here is a blessing:
6
+ #
7
+ # * May you do good and not evil.
8
+ # * May you find forgiveness for yourself and forgive others.
9
+ # * May you share freely, never taking more than you give.
10
+ #
11
+ ########################################################################
12
+ # Routines for Steve Bennett's autosetup which are common to trees
13
+ # managed in and around the umbrella of the SQLite project.
14
+ #
15
+ # The intent is that these routines be relatively generic, independent
16
+ # of a given project.
17
+ #
18
+ # This file was initially derived from one used in the libfossil
19
+ # project, authored by the same person who ported it here, and this is
20
+ # noted here only as an indication that there are no licensing issues
21
+ # despite this code having a handful of near-twins running around a
22
+ # handful of third-party source trees.
23
+ #
24
+ ########################################################################
25
+ #
26
+ # Design notes:
27
+ #
28
+ # - Symbols with a suffix of _ are intended for internal use within
29
+ # this file, and are not part of the API which auto.def files should
30
+ # rely on.
31
+ #
32
+ # - By and large, autosetup prefers to update global state with the
33
+ # results of feature checks, e.g. whether the compiler supports flag
34
+ # --X. In this developer's opinion that (A) causes more confusion
35
+ # than it solves[^1] and (B) adds an unnecessary layer of "voodoo"
36
+ # between the autosetup user and its internals. This module, in
37
+ # contrast, instead injects the results of its own tests into
38
+ # well-defined variables and leaves the integration of those values
39
+ # to the caller's discretion.
40
+ #
41
+ # [1]: As an example: testing for the -rpath flag, using
42
+ # cc-check-flags, can break later checks which use
43
+ # [cc-check-function-in-lib ...] because the resulting -rpath flag
44
+ # implicitly becomes part of those tests. In the case of an rpath
45
+ # test, downstream tests may not like the $prefix/lib path added by
46
+ # the rpath test. To avoid such problems, we avoid (intentionally)
47
+ # updating global state via feature tests.
48
+ ########################################################################
49
+
50
+ # ----- @module proj.tcl -----
51
+ # @section Project Helper APIs
52
+
53
+ ########################################################################
54
+ # $proj_ is an internal-use-only array for storing whatever generic
55
+ # internal stuff we need stored.
56
+ array set proj_ {}
57
+ set proj_(isatty) [isatty? stdout]
58
+
59
+ ########################################################################
60
+ # @proj-warn msg
61
+ #
62
+ # Emits a warning message to stderr.
63
+ proc proj-warn {msg} {
64
+ show-notices
65
+ puts stderr "WARNING: $msg"
66
+ }
67
+ ########################################################################
68
+ # @proj-error msg
69
+ #
70
+ # Emits an error message to stderr and exits with non-0.
71
+ proc proj-fatal {msg} {
72
+ show-notices
73
+ puts stderr "ERROR: $msg"
74
+ exit 1
75
+ }
76
+
77
+ ########################################################################
78
+ # @proj-assert script
79
+ #
80
+ # Kind of like a C assert: if uplevel (eval) of [expr {$script}] is
81
+ # false, a fatal error is triggered. The error message, by default,
82
+ # includes the body of the failed assertion, but if $descr is set then
83
+ # that is used instead.
84
+ proc proj-assert {script {descr ""}} {
85
+ if {1 == [get-env proj-assert 0]} {
86
+ msg-result [proj-bold "asserting: $script"]
87
+ }
88
+ set x {expr }
89
+ append x \{ $script \}
90
+ if {![uplevel 1 $x]} {
91
+ if {"" eq $descr} {
92
+ set descr $script
93
+ }
94
+ proj-fatal "Assertion failed: $descr"
95
+ }
96
+ }
97
+
98
+ ########################################################################
99
+ # @proj-bold str
100
+ #
101
+ # If this function believes that the current console might support
102
+ # ANSI escape sequences then this returns $str wrapped in a sequence
103
+ # to bold that text, else it returns $str as-is.
104
+ proc proj-bold {str} {
105
+ if {$::autosetup(iswin) || !$::proj_(isatty)} {
106
+ return $str
107
+ }
108
+ return "\033\[1m${str}\033\[0m"
109
+ }
110
+
111
+ ########################################################################
112
+ # @proj-indented-notice ?-error? ?-notice? msg
113
+ #
114
+ # Takes a multi-line message and emits it with consistent indentation.
115
+ #
116
+ # If the -notice flag it used then it emits using [user-notice], which
117
+ # means its rendering will (A) go to stderr and (B) be delayed until
118
+ # the next time autosetup goes to output a message. If -notice
119
+ # is not used, it will send the message to stdout without delay.
120
+ #
121
+ # If the -error flag is provided then it renders the message
122
+ # immediately to stderr and then exits.
123
+ proc proj-indented-notice {args} {
124
+ set fErr ""
125
+ set outFunc "puts"
126
+ while {[llength $args] > 1} {
127
+ switch -exact -- [lindex $args 0] {
128
+ -error {
129
+ set args [lassign $args fErr]
130
+ }
131
+ -notice {
132
+ set args [lassign $args -]
133
+ set outFunc "user-notice"
134
+ }
135
+ default {
136
+ break
137
+ }
138
+ }
139
+ }
140
+ set lines [split [join $args] \n]
141
+ foreach line $lines {
142
+ $outFunc " [string trimleft $line]"
143
+ }
144
+ if {"" ne $fErr} {
145
+ show-notices
146
+ exit 1
147
+ }
148
+ }
149
+
150
+ ########################################################################
151
+ # @proj-is-cross-compiling
152
+ #
153
+ # Returns 1 if cross-compiling, else 0.
154
+ proc proj-is-cross-compiling {} {
155
+ return [expr {[get-define host] ne [get-define build]}]
156
+ }
157
+
158
+ ########################################################################
159
+ # proj-lshift_ shifts $count elements from the list named $listVar
160
+ # and returns them as a new list. On empty input, returns "".
161
+ #
162
+ # Modified slightly from: https://wiki.tcl-lang.org/page/lshift
163
+ proc proj-lshift_ {listVar {count 1}} {
164
+ upvar 1 $listVar l
165
+ if {![info exists l]} {
166
+ # make the error message show the real variable name
167
+ error "can't read \"$listVar\": no such variable"
168
+ }
169
+ if {![llength $l]} {
170
+ # error Empty
171
+ return ""
172
+ }
173
+ set r [lrange $l 0 [incr count -1]]
174
+ set l [lreplace $l [set l 0] $count]
175
+ return $r
176
+ }
177
+
178
+ ########################################################################
179
+ # Expects to receive string input, which it splits on newlines, strips
180
+ # out any lines which begin with an number of whitespace followed by a
181
+ # '#', and returns a value containing the [append]ed results of each
182
+ # remaining line with a \n between each.
183
+ proc proj-strip-hash-comments_ {val} {
184
+ set x {}
185
+ foreach line [split $val \n] {
186
+ if {![string match "#*" [string trimleft $line]]} {
187
+ append x $line \n
188
+ }
189
+ }
190
+ return $x
191
+ }
192
+
193
+ ########################################################################
194
+ # @proj-check-function-in-lib
195
+ #
196
+ # A proxy for cc-check-function-in-lib which does not make any global
197
+ # changes to the LIBS define. Returns the result of
198
+ # cc-check-function-in-lib (i.e. true or false). The resulting linker
199
+ # flags are stored in ${lib_${function}}.
200
+ proc proj-check-function-in-lib {function libs {otherlibs {}}} {
201
+ set found 0
202
+ define-push {LIBS} {
203
+ set found [cc-check-function-in-lib $function $libs $otherlibs]
204
+ }
205
+ return $found
206
+ }
207
+
208
+ ########################################################################
209
+ # @proj-search-for-header-dir ?-dirs LIST? ?-subdirs LIST? header
210
+ #
211
+ # Searches for $header in a combination of dirs and subdirs, specified
212
+ # by the -dirs {LIST} and -subdirs {LIST} flags (each of which have
213
+ # sane defaults). Returns either the first matching dir or an empty
214
+ # string. The return value does not contain the filename part.
215
+ proc proj-search-for-header-dir {header args} {
216
+ set subdirs {include}
217
+ set dirs {/usr /usr/local /mingw}
218
+ # Debatable:
219
+ # if {![proj-is-cross-compiling]} {
220
+ # lappend dirs [get-define prefix]
221
+ # }
222
+ while {[llength $args]} {
223
+ switch -exact -- [lindex $args 0] {
224
+ -dirs { set args [lassign $args - dirs] }
225
+ -subdirs { set args [lassign $args - subdirs] }
226
+ default {
227
+ proj-fatal "Unhandled argument: $args"
228
+ }
229
+ }
230
+ }
231
+ foreach dir $dirs {
232
+ foreach sub $subdirs {
233
+ if {[file exists $dir/$sub/$header]} {
234
+ return "$dir/$sub"
235
+ }
236
+ }
237
+ }
238
+ return ""
239
+ }
240
+
241
+ ########################################################################
242
+ # @proj-find-executable-path ?-v? binaryName
243
+ #
244
+ # Works similarly to autosetup's [find-executable-path $binName] but:
245
+ #
246
+ # - If the first arg is -v, it's verbose about searching, else it's quiet.
247
+ #
248
+ # Returns the full path to the result or an empty string.
249
+ proc proj-find-executable-path {args} {
250
+ set binName $args
251
+ set verbose 0
252
+ if {[lindex $args 0] eq "-v"} {
253
+ set verbose 1
254
+ set args [lassign $args - binName]
255
+ msg-checking "Looking for $binName ... "
256
+ }
257
+ set check [find-executable-path $binName]
258
+ if {$verbose} {
259
+ if {"" eq $check} {
260
+ msg-result "not found"
261
+ } else {
262
+ msg-result $check
263
+ }
264
+ }
265
+ return $check
266
+ }
267
+
268
+ ########################################################################
269
+ # @proj-bin-define binName ?defName?
270
+ #
271
+ # Uses [proj-find-executable-path $binName] to (verbosely) search for
272
+ # a binary, sets a define (see below) to the result, and returns the
273
+ # result (an empty string if not found).
274
+ #
275
+ # The define'd name is: if defName is empty then "BIN_X" is used,
276
+ # where X is the upper-case form of $binName with any '-' characters
277
+ # replaced with '_'.
278
+ proc proj-bin-define {binName {defName {}}} {
279
+ set check [proj-find-executable-path -v $binName]
280
+ if {"" eq $defName} {
281
+ set defName "BIN_[string toupper [string map {- _} $binName]]"
282
+ }
283
+ define $defName $check
284
+ return $check
285
+ }
286
+
287
+ ########################################################################
288
+ # @proj-first-bin-of bin...
289
+ #
290
+ # Looks for the first binary found of the names passed to this
291
+ # function. If a match is found, the full path to that binary is
292
+ # returned, else "" is returned.
293
+ #
294
+ # Despite using cc-path-progs to do the search, this function clears
295
+ # any define'd name that function stores for the result (because the
296
+ # caller has no sensible way of knowing which result it was unless
297
+ # they pass only a single argument).
298
+ proc proj-first-bin-of {args} {
299
+ set rc ""
300
+ foreach b $args {
301
+ set u [string toupper $b]
302
+ # Note that cc-path-progs defines $u to false if it finds no match.
303
+ if {[cc-path-progs $b]} {
304
+ set rc [get-define $u]
305
+ }
306
+ undefine $u
307
+ if {"" ne $rc} break
308
+ }
309
+ return $rc
310
+ }
311
+
312
+ ########################################################################
313
+ # @proj-opt-was-provided key
314
+ #
315
+ # Returns 1 if the user specifically provided the given configure
316
+ # flag, else 0. This can be used to distinguish between options which
317
+ # have a default value and those which were explicitly provided by the
318
+ # user, even if the latter is done in a way which uses the default
319
+ # value.
320
+ #
321
+ # For example, with a configure flag defined like:
322
+ #
323
+ # { foo-bar:=baz => {its help text} }
324
+ #
325
+ # This function will, when passed foo-bar, return 1 only if the user
326
+ # passes --foo-bar to configure, even if that invocation would resolve
327
+ # to the default value of baz. If the user does not explicitly pass in
328
+ # --foo-bar (with or without a value) then this returns 0.
329
+ #
330
+ # Note: unlike most functions which deal with configure --flags, this
331
+ # one does not validate that $key refers to a pre-defined flag. i.e.
332
+ # it accepts arbitrary keys, even those not defined via an [options]
333
+ # call. [proj-opt-set] manipulates the internal list of flags, such
334
+ # that new options set via that function will cause this function to
335
+ # return true. (That's an unintended and unavoidable side-effect, not
336
+ # specifically a feature which should be made use of.)
337
+ proc proj-opt-was-provided {key} {
338
+ dict exists $::autosetup(optset) $key
339
+ }
340
+
341
+ ########################################################################
342
+ # @proj-opt-set flag ?val?
343
+ #
344
+ # Force-set autosetup option $flag to $val. The value can be fetched
345
+ # later with [opt-val], [opt-bool], and friends.
346
+ #
347
+ # Returns $val.
348
+ proc proj-opt-set {flag {val 1}} {
349
+ global autosetup
350
+ if {$flag ni $::autosetup(options)} {
351
+ # We have to add this to autosetup(options) or else future calls
352
+ # to [opt-bool $flag] will fail validation of $flag.
353
+ lappend ::autosetup(options) $flag
354
+ }
355
+ dict set ::autosetup(optset) $flag $val
356
+ return $val
357
+ }
358
+
359
+ ########################################################################
360
+ # @proj-val-truthy val
361
+ #
362
+ # Returns 1 if $val appears to be a truthy value, else returns
363
+ # 0. Truthy values are any of {1 on true yes enabled}
364
+ proc proj-val-truthy {val} {
365
+ expr {$val in {1 on true yes enabled}}
366
+ }
367
+
368
+ ########################################################################
369
+ # @proj-opt-truthy flag
370
+ #
371
+ # Returns 1 if [opt-val $flag] appears to be a truthy value or
372
+ # [opt-bool $flag] is true. See proj-val-truthy.
373
+ proc proj-opt-truthy {flag} {
374
+ if {[proj-val-truthy [opt-val $flag]]} { return 1 }
375
+ set rc 0
376
+ catch {
377
+ # opt-bool will throw if $flag is not a known boolean flag
378
+ set rc [opt-bool $flag]
379
+ }
380
+ return $rc
381
+ }
382
+
383
+ ########################################################################
384
+ # @proj-if-opt-truthy boolFlag thenScript ?elseScript?
385
+ #
386
+ # If [proj-opt-truthy $flag] is true, eval $then, else eval $else.
387
+ proc proj-if-opt-truthy {boolFlag thenScript {elseScript {}}} {
388
+ if {[proj-opt-truthy $boolFlag]} {
389
+ uplevel 1 $thenScript
390
+ } else {
391
+ uplevel 1 $elseScript
392
+ }
393
+ }
394
+
395
+ ########################################################################
396
+ # @proj-define-for-opt flag def ?msg? ?iftrue? ?iffalse?
397
+ #
398
+ # If [proj-opt-truthy $flag] then [define $def $iftrue] else [define
399
+ # $def $iffalse]. If $msg is not empty, output [msg-checking $msg] and
400
+ # a [msg-results ...] which corresponds to the result. Returns 1 if
401
+ # the opt-truthy check passes, else 0.
402
+ proc proj-define-for-opt {flag def {msg ""} {iftrue 1} {iffalse 0}} {
403
+ if {"" ne $msg} {
404
+ msg-checking "$msg "
405
+ }
406
+ set rcMsg ""
407
+ set rc 0
408
+ if {[proj-opt-truthy $flag]} {
409
+ define $def $iftrue
410
+ set rc 1
411
+ } else {
412
+ define $def $iffalse
413
+ }
414
+ switch -- [proj-val-truthy [get-define $def]] {
415
+ 0 { set rcMsg no }
416
+ 1 { set rcMsg yes }
417
+ }
418
+ if {"" ne $msg} {
419
+ msg-result $rcMsg
420
+ }
421
+ return $rc
422
+ }
423
+
424
+ ########################################################################
425
+ # @proj-opt-define-bool ?-v? optName defName ?descr?
426
+ #
427
+ # Checks [proj-opt-truthy $optName] and calls [define $defName X]
428
+ # where X is 0 for false and 1 for true. descr is an optional
429
+ # [msg-checking] argument which defaults to $defName. Returns X.
430
+ #
431
+ # If args[0] is -v then the boolean semantics are inverted: if
432
+ # the option is set, it gets define'd to 0, else 1. Returns the
433
+ # define'd value.
434
+ proc proj-opt-define-bool {args} {
435
+ set invert 0
436
+ if {[lindex $args 0] eq "-v"} {
437
+ set invert 1
438
+ set args [lrange $args 1 end]
439
+ }
440
+ set optName [proj-lshift_ args]
441
+ set defName [proj-lshift_ args]
442
+ set descr [proj-lshift_ args]
443
+ if {"" eq $descr} {
444
+ set descr $defName
445
+ }
446
+ set rc 0
447
+ msg-checking "$descr ... "
448
+ if {[proj-opt-truthy $optName]} {
449
+ if {0 eq $invert} {
450
+ set rc 1
451
+ } else {
452
+ set rc 0
453
+ }
454
+ } elseif {0 ne $invert} {
455
+ set rc 1
456
+ }
457
+ msg-result $rc
458
+ define $defName $rc
459
+ return $rc
460
+ }
461
+
462
+ ########################################################################
463
+ # @proj-check-module-loader
464
+ #
465
+ # Check for module-loading APIs (libdl/libltdl)...
466
+ #
467
+ # Looks for libltdl or dlopen(), the latter either in -ldl or built in
468
+ # to libc (as it is on some platforms). Returns 1 if found, else
469
+ # 0. Either way, it `define`'s:
470
+ #
471
+ # - HAVE_LIBLTDL to 1 or 0 if libltdl is found/not found
472
+ # - HAVE_LIBDL to 1 or 0 if dlopen() is found/not found
473
+ # - LDFLAGS_MODULE_LOADER one of ("-lltdl", "-ldl", or ""), noting
474
+ # that -ldl may legally be empty on some platforms even if
475
+ # HAVE_LIBDL is true (indicating that dlopen() is available without
476
+ # extra link flags). LDFLAGS_MODULE_LOADER also gets "-rdynamic" appended
477
+ # to it because otherwise trying to open DLLs will result in undefined
478
+ # symbol errors.
479
+ #
480
+ # Note that if it finds LIBLTDL it does not look for LIBDL, so will
481
+ # report only that is has LIBLTDL.
482
+ proc proj-check-module-loader {} {
483
+ msg-checking "Looking for module-loader APIs... "
484
+ if {99 ne [get-define LDFLAGS_MODULE_LOADER 99]} {
485
+ if {1 eq [get-define HAVE_LIBLTDL 0]} {
486
+ msg-result "(cached) libltdl"
487
+ return 1
488
+ } elseif {1 eq [get-define HAVE_LIBDL 0]} {
489
+ msg-result "(cached) libdl"
490
+ return 1
491
+ }
492
+ # else: wha???
493
+ }
494
+ set HAVE_LIBLTDL 0
495
+ set HAVE_LIBDL 0
496
+ set LDFLAGS_MODULE_LOADER ""
497
+ set rc 0
498
+ puts "" ;# cosmetic kludge for cc-check-XXX
499
+ if {[cc-check-includes ltdl.h] && [cc-check-function-in-lib lt_dlopen ltdl]} {
500
+ set HAVE_LIBLTDL 1
501
+ set LDFLAGS_MODULE_LOADER "-lltdl -rdynamic"
502
+ msg-result " - Got libltdl."
503
+ set rc 1
504
+ } elseif {[cc-with {-includes dlfcn.h} {
505
+ cctest -link 1 -declare "extern char* dlerror(void);" -code "dlerror();"}]} {
506
+ msg-result " - This system can use dlopen() without -ldl."
507
+ set HAVE_LIBDL 1
508
+ set LDFLAGS_MODULE_LOADER ""
509
+ set rc 1
510
+ } elseif {[cc-check-includes dlfcn.h]} {
511
+ set HAVE_LIBDL 1
512
+ set rc 1
513
+ if {[cc-check-function-in-lib dlopen dl]} {
514
+ msg-result " - dlopen() needs libdl."
515
+ set LDFLAGS_MODULE_LOADER "-ldl -rdynamic"
516
+ } else {
517
+ msg-result " - dlopen() not found in libdl. Assuming dlopen() is built-in."
518
+ set LDFLAGS_MODULE_LOADER "-rdynamic"
519
+ }
520
+ }
521
+ define HAVE_LIBLTDL $HAVE_LIBLTDL
522
+ define HAVE_LIBDL $HAVE_LIBDL
523
+ define LDFLAGS_MODULE_LOADER $LDFLAGS_MODULE_LOADER
524
+ return $rc
525
+ }
526
+
527
+ ########################################################################
528
+ # @proj-no-check-module-loader
529
+ #
530
+ # Sets all flags which would be set by proj-check-module-loader to
531
+ # empty/falsy values, as if those checks had failed to find a module
532
+ # loader. Intended to be called in place of that function when
533
+ # a module loader is explicitly not desired.
534
+ proc proj-no-check-module-loader {} {
535
+ define HAVE_LIBDL 0
536
+ define HAVE_LIBLTDL 0
537
+ define LDFLAGS_MODULE_LOADER ""
538
+ }
539
+
540
+ ########################################################################
541
+ # @proj-file-conent ?-trim? filename
542
+ #
543
+ # Opens the given file, reads all of its content, and returns it. If
544
+ # the first arg is -trim, the contents of the file named by the second
545
+ # argument are trimmed before returning them.
546
+ proc proj-file-content {args} {
547
+ set trim 0
548
+ set fname $args
549
+ if {"-trim" eq [lindex $args 0]} {
550
+ set trim 1
551
+ lassign $args - fname
552
+ }
553
+ set fp [open $fname r]
554
+ set rc [read $fp]
555
+ close $fp
556
+ if {$trim} { return [string trim $rc] }
557
+ return $rc
558
+ }
559
+
560
+ ########################################################################
561
+ # @proj-file-conent filename
562
+ #
563
+ # Returns the contents of the given file as an array of lines, with
564
+ # the EOL stripped from each input line.
565
+ proc proj-file-content-list {fname} {
566
+ set fp [open $fname r]
567
+ set rc {}
568
+ while { [gets $fp line] >= 0 } {
569
+ lappend rc $line
570
+ }
571
+ close $fp
572
+ return $rc
573
+ }
574
+
575
+ ########################################################################
576
+ # @proj-check-compile-commands ?configFlag?
577
+ #
578
+ # Checks the compiler for compile_commands.json support. If passed an
579
+ # argument it is assumed to be the name of an autosetup boolean config
580
+ # which controls whether to run/skip this check.
581
+ #
582
+ # Returns 1 if supported, else 0. Defines MAKE_COMPILATION_DB to "yes"
583
+ # if supported, "no" if not.
584
+ #
585
+ # This test has a long history of false positive results because of
586
+ # compilers reacting differently to the -MJ flag.
587
+ proc proj-check-compile-commands {{configFlag {}}} {
588
+ msg-checking "compile_commands.json support... "
589
+ if {"" ne $configFlag && ![proj-opt-truthy $configFlag]} {
590
+ msg-result "explicitly disabled"
591
+ define MAKE_COMPILATION_DB no
592
+ return 0
593
+ } else {
594
+ if {[cctest -lang c -cflags {/dev/null -MJ} -source {}]} {
595
+ # This test reportedly incorrectly succeeds on one of
596
+ # Martin G.'s older systems. drh also reports a false
597
+ # positive on an unspecified older Mac system.
598
+ msg-result "compiler supports compile_commands.json"
599
+ define MAKE_COMPILATION_DB yes
600
+ return 1
601
+ } else {
602
+ msg-result "compiler does not support compile_commands.json"
603
+ define MAKE_COMPILATION_DB no
604
+ return 0
605
+ }
606
+ }
607
+ }
608
+
609
+ ########################################################################
610
+ # @proj-touch filename
611
+ #
612
+ # Runs the 'touch' external command on one or more files, ignoring any
613
+ # errors.
614
+ proc proj-touch {filename} {
615
+ catch { exec touch {*}$filename }
616
+ }
617
+
618
+ ########################################################################
619
+ # @proj-make-from-dot-in ?-touch? filename...
620
+ #
621
+ # Uses [make-template] to create makefile(-like) file(s) $filename
622
+ # from $filename.in but explicitly makes the output read-only, to
623
+ # avoid inadvertent editing (who, me?).
624
+ #
625
+ # If the first argument is -touch then the generated file is touched
626
+ # to update its timestamp. This can be used as a workaround for
627
+ # cases where (A) autosetup does not update the file because it was
628
+ # not really modified and (B) the file *really* needs to be updated to
629
+ # please the build process.
630
+ #
631
+ # Failures when running chmod or touch are silently ignored.
632
+ proc proj-make-from-dot-in {args} {
633
+ set filename $args
634
+ set touch 0
635
+ if {[lindex $args 0] eq "-touch"} {
636
+ set touch 1
637
+ set filename [lrange $args 1 end]
638
+ }
639
+ foreach f $filename {
640
+ set f [string trim $f]
641
+ catch { exec chmod u+w $f }
642
+ make-template $f.in $f
643
+ if {$touch} {
644
+ proj-touch $f
645
+ }
646
+ catch { exec chmod -w $f }
647
+ }
648
+ }
649
+
650
+ ########################################################################
651
+ # @proj-check-profile-flag ?flagname?
652
+ #
653
+ # Checks for the boolean configure option named by $flagname. If set,
654
+ # it checks if $CC seems to refer to gcc. If it does (or appears to)
655
+ # then it defines CC_PROFILE_FLAG to "-pg" and returns 1, else it
656
+ # defines CC_PROFILE_FLAG to "" and returns 0.
657
+ #
658
+ # Note that the resulting flag must be added to both CFLAGS and
659
+ # LDFLAGS in order for binaries to be able to generate "gmon.out". In
660
+ # order to avoid potential problems with escaping, space-containing
661
+ # tokens, and interfering with autosetup's use of these vars, this
662
+ # routine does not directly modify CFLAGS or LDFLAGS.
663
+ proc proj-check-profile-flag {{flagname profile}} {
664
+ #puts "flagname=$flagname ?[proj-opt-truthy $flagname]?"
665
+ if {[proj-opt-truthy $flagname]} {
666
+ set CC [get-define CC]
667
+ regsub {.*ccache *} $CC "" CC
668
+ # ^^^ if CC="ccache gcc" then [exec] treats "ccache gcc" as a
669
+ # single binary name and fails. So strip any leading ccache part
670
+ # for this purpose.
671
+ if { ![catch { exec $CC --version } msg]} {
672
+ if {[string first gcc $CC] != -1} {
673
+ define CC_PROFILE_FLAG "-pg"
674
+ return 1
675
+ }
676
+ }
677
+ }
678
+ define CC_PROFILE_FLAG ""
679
+ return 0
680
+ }
681
+
682
+ ########################################################################
683
+ # @proj-looks-like-windows ?key?
684
+ #
685
+ # Returns 1 if this appears to be a Windows environment (MinGw,
686
+ # Cygwin, MSys), else returns 0. The optional argument is the name of
687
+ # an autosetup define which contains platform name info, defaulting to
688
+ # "host" (meaning, somewhat counterintuitively, the target system, not
689
+ # the current host). The other legal value is "build" (the build
690
+ # machine, i.e. the local host). If $key == "build" then some
691
+ # additional checks may be performed which are not applicable when
692
+ # $key == "host".
693
+ proc proj-looks-like-windows {{key host}} {
694
+ global autosetup
695
+ switch -glob -- [get-define $key] {
696
+ *-*-ming* - *-*-cygwin - *-*-msys - *windows* {
697
+ return 1
698
+ }
699
+ }
700
+ if {$key eq "build"} {
701
+ # These apply only to the local OS, not a cross-compilation target,
702
+ # as the above check potentially can.
703
+ if {$::autosetup(iswin)} { return 1 }
704
+ if {[find-an-executable cygpath] ne "" || $::tcl_platform(os)=="Windows NT"} {
705
+ return 1
706
+ }
707
+ }
708
+ return 0
709
+ }
710
+
711
+ ########################################################################
712
+ # @proj-looks-like-mac ?key?
713
+ #
714
+ # Looks at either the 'host' (==compilation target platform) or
715
+ # 'build' (==the being-built-on platform) define value and returns if
716
+ # if that value seems to indicate that it represents a Mac platform,
717
+ # else returns 0.
718
+ proc proj-looks-like-mac {{key host}} {
719
+ switch -glob -- [get-define $key] {
720
+ *apple* {
721
+ return 1
722
+ }
723
+ default {
724
+ return 0
725
+ }
726
+ }
727
+ }
728
+
729
+ ########################################################################
730
+ # @proj-exe-extension
731
+ #
732
+ # Checks autosetup's "host" and "build" defines to see if the build
733
+ # host and target are Windows-esque (Cygwin, MinGW, MSys). If the
734
+ # build environment is then BUILD_EXEEXT is [define]'d to ".exe", else
735
+ # "". If the target, a.k.a. "host", is then TARGET_EXEEXT is
736
+ # [define]'d to ".exe", else "".
737
+ proc proj-exe-extension {} {
738
+ set rH ""
739
+ set rB ""
740
+ if {[proj-looks-like-windows host]} {
741
+ set rH ".exe"
742
+ }
743
+ if {[proj-looks-like-windows build]} {
744
+ set rB ".exe"
745
+ }
746
+ define BUILD_EXEEXT $rB
747
+ define TARGET_EXEEXT $rH
748
+ }
749
+
750
+ ########################################################################
751
+ # @proj-dll-extension
752
+ #
753
+ # Works like proj-exe-extension except that it defines BUILD_DLLEXT
754
+ # and TARGET_DLLEXT to one of (.so, ,dll, .dylib).
755
+ #
756
+ # Trivia: for .dylib files, the linker needs the -dynamiclib flag
757
+ # instead of -shared.
758
+ proc proj-dll-extension {} {
759
+ proc inner {key} {
760
+ switch -glob -- [get-define $key] {
761
+ *apple* {
762
+ return ".dylib"
763
+ }
764
+ *-*-ming* - *-*-cygwin - *-*-msys {
765
+ return ".dll"
766
+ }
767
+ default {
768
+ return ".so"
769
+ }
770
+ }
771
+ }
772
+ define BUILD_DLLEXT [inner build]
773
+ define TARGET_DLLEXT [inner host]
774
+ }
775
+
776
+ ########################################################################
777
+ # @proj-lib-extension
778
+ #
779
+ # Static-library counterpart of proj-dll-extension. Defines
780
+ # BUILD_LIBEXT and TARGET_LIBEXT to the conventional static library
781
+ # extension for the being-built-on resp. the target platform.
782
+ proc proj-lib-extension {} {
783
+ proc inner {key} {
784
+ switch -glob -- [get-define $key] {
785
+ *-*-ming* - *-*-cygwin - *-*-msys {
786
+ return ".lib"
787
+ }
788
+ default {
789
+ return ".a"
790
+ }
791
+ }
792
+ }
793
+ define BUILD_LIBEXT [inner build]
794
+ define TARGET_LIBEXT [inner host]
795
+ }
796
+
797
+ ########################################################################
798
+ # @proj-file-extensions
799
+ #
800
+ # Calls all of the proj-*-extension functions.
801
+ proc proj-file-extensions {} {
802
+ proj-exe-extension
803
+ proj-dll-extension
804
+ proj-lib-extension
805
+ }
806
+
807
+ ########################################################################
808
+ # @proj-affirm-files-exist ?-v? filename...
809
+ #
810
+ # Expects a list of file names. If any one of them does not exist in
811
+ # the filesystem, it fails fatally with an informative message.
812
+ # Returns the last file name it checks. If the first argument is -v
813
+ # then it emits msg-checking/msg-result messages for each file.
814
+ proc proj-affirm-files-exist {args} {
815
+ set rc ""
816
+ set verbose 0
817
+ if {[lindex $args 0] eq "-v"} {
818
+ set verbose 1
819
+ set args [lrange $args 1 end]
820
+ }
821
+ foreach f $args {
822
+ if {$verbose} { msg-checking "Looking for $f ... " }
823
+ if {![file exists $f]} {
824
+ user-error "not found: $f"
825
+ }
826
+ if {$verbose} { msg-result "" }
827
+ set rc $f
828
+ }
829
+ return rc
830
+ }
831
+
832
+ ########################################################################
833
+ # @proj-check-emsdk
834
+ #
835
+ # Emscripten is used for doing in-tree builds of web-based WASM stuff,
836
+ # as opposed to WASI-based WASM or WASM binaries we import from other
837
+ # places. This is only set up for Unix-style OSes and is untested
838
+ # anywhere but Linux. Requires that the --with-emsdk flag be
839
+ # registered with autosetup.
840
+ #
841
+ # It looks for the SDK in the location specified by --with-emsdk.
842
+ # Values of "" or "auto" mean to check for the environment var EMSDK
843
+ # (which gets set by the emsdk_env.sh script from the SDK) or that
844
+ # same var passed to configure.
845
+ #
846
+ # If the given directory is found, it expects to find emsdk_env.sh in
847
+ # that directory, as well as the emcc compiler somewhere under there.
848
+ #
849
+ # If the --with-emsdk flag is explicitly provided and the SDK is not
850
+ # found then a fatal error is generated, otherwise failure to find the
851
+ # SDK is not fatal.
852
+ #
853
+ # Defines the following:
854
+ #
855
+ # - EMSDK_HOME = top dir of the emsdk or "".
856
+ # - EMSDK_ENV_SH = path to EMSDK_HOME/emsdk_env.sh or ""
857
+ # - BIN_EMCC = $EMSDK_HOME/upstream/emscripten/emcc or ""
858
+ # - HAVE_EMSDK = 0 or 1 (this function's return value)
859
+ #
860
+ # Returns 1 if EMSDK_ENV_SH is found, else 0. If EMSDK_HOME is not empty
861
+ # but BIN_EMCC is then emcc was not found in the EMSDK_HOME, in which
862
+ # case we have to rely on the fact that sourcing $EMSDK_ENV_SH from a
863
+ # shell will add emcc to the $PATH.
864
+ proc proj-check-emsdk {} {
865
+ set emsdkHome [opt-val with-emsdk]
866
+ define EMSDK_HOME ""
867
+ define EMSDK_ENV_SH ""
868
+ define BIN_EMCC ""
869
+ set hadValue [llength $emsdkHome]
870
+ msg-checking "Emscripten SDK? "
871
+ if {$emsdkHome in {"" "auto"}} {
872
+ # Check the environment. $EMSDK gets set by sourcing emsdk_env.sh.
873
+ set emsdkHome [get-env EMSDK ""]
874
+ }
875
+ set rc 0
876
+ if {$emsdkHome ne ""} {
877
+ define EMSDK_HOME $emsdkHome
878
+ set emsdkEnv "$emsdkHome/emsdk_env.sh"
879
+ if {[file exists $emsdkEnv]} {
880
+ msg-result "$emsdkHome"
881
+ define EMSDK_ENV_SH $emsdkEnv
882
+ set rc 1
883
+ set emcc "$emsdkHome/upstream/emscripten/emcc"
884
+ if {[file exists $emcc]} {
885
+ define BIN_EMCC $emcc
886
+ }
887
+ } else {
888
+ msg-result "emsdk_env.sh not found in $emsdkHome"
889
+ }
890
+ } else {
891
+ msg-result "not found"
892
+ }
893
+ if {$hadValue && 0 == $rc} {
894
+ # Fail if it was explicitly requested but not found
895
+ proj-fatal "Cannot find the Emscripten SDK"
896
+ }
897
+ define HAVE_EMSDK $rc
898
+ return $rc
899
+ }
900
+
901
+ ########################################################################
902
+ # @proj-check-rpath
903
+ #
904
+ # Tries various approaches to handling the -rpath link-time
905
+ # flag. Defines LDFLAGS_RPATH to that/those flag(s) or an empty
906
+ # string. Returns 1 if it finds an option, else 0.
907
+ #
908
+ # By default, the rpath is set to $prefix/lib. However, if either of
909
+ # --exec-prefix=... or --libdir=... are explicitly passed to
910
+ # configure then [get-define libdir] is used (noting that it derives
911
+ # from exec-prefix by default).
912
+ #
913
+ # Achtung: we have seen platforms which report that a given option
914
+ # checked here will work but then fails at build-time, and the current
915
+ # order of checks reflects that.
916
+ proc proj-check-rpath {} {
917
+ set rc 1
918
+ if {[proj-opt-was-provided libdir]
919
+ || [proj-opt-was-provided exec-prefix]} {
920
+ set lp "[get-define libdir]"
921
+ } else {
922
+ set lp "[get-define prefix]/lib"
923
+ }
924
+ # If we _don't_ use cc-with {} here (to avoid updating the global
925
+ # CFLAGS or LIBS or whatever it is that cc-check-flags updates) then
926
+ # downstream tests may fail because the resulting rpath gets
927
+ # implicitly injected into them.
928
+ cc-with {} {
929
+ if {[cc-check-flags "-rpath $lp"]} {
930
+ define LDFLAGS_RPATH "-rpath $lp"
931
+ } elseif {[cc-check-flags "-Wl,-rpath,$lp"]} {
932
+ define LDFLAGS_RPATH "-Wl,-rpath,$lp"
933
+ } elseif {[cc-check-flags "-Wl,-rpath -Wl,$lp"]} {
934
+ define LDFLAGS_RPATH "-Wl,-rpath -Wl,$lp"
935
+ } elseif {[cc-check-flags -Wl,-R$lp]} {
936
+ define LDFLAGS_RPATH "-Wl,-R$lp"
937
+ } else {
938
+ define LDFLAGS_RPATH ""
939
+ set rc 0
940
+ }
941
+ }
942
+ return $rc
943
+ }
944
+
945
+ ########################################################################
946
+ # @proj-check-soname ?libname?
947
+ #
948
+ # Checks whether CC supports the -Wl,soname,lib... flag. If so, it
949
+ # returns 1 and defines LDFLAGS_SONAME_PREFIX to the flag's prefix, to
950
+ # which the client would need to append "libwhatever.N". If not, it
951
+ # returns 0 and defines LDFLAGS_SONAME_PREFIX to an empty string.
952
+ #
953
+ # The libname argument is only for purposes of running the flag
954
+ # compatibility test, and is not included in the resulting
955
+ # LDFLAGS_SONAME_PREFIX. It is provided so that clients may
956
+ # potentially avoid some end-user confusion by using their own lib's
957
+ # name here (which shows up in the "checking..." output).
958
+ proc proj-check-soname {{libname "libfoo.so.0"}} {
959
+ cc-with {} {
960
+ if {[cc-check-flags "-Wl,-soname,${libname}"]} {
961
+ define LDFLAGS_SONAME_PREFIX "-Wl,-soname,"
962
+ return 1
963
+ } else {
964
+ define LDFLAGS_SONAME_PREFIX ""
965
+ return 0
966
+ }
967
+ }
968
+ }
969
+
970
+ ########################################################################
971
+ # Internal helper for proj-dump-defs-json. Expects to be passed a
972
+ # [define] name and the variadic $args which are passed to
973
+ # proj-dump-defs-json. If it finds a pattern match for the given
974
+ # $name in the various $args, it returns the type flag for that $name,
975
+ # e.g. "-str" or "-bare", else returns an empty string.
976
+ proc proj-defs-type_ {name spec} {
977
+ foreach {type patterns} $spec {
978
+ foreach pattern $patterns {
979
+ if {[string match $pattern $name]} {
980
+ return $type
981
+ }
982
+ }
983
+ }
984
+ return ""
985
+ }
986
+
987
+ ########################################################################
988
+ # Internal helper for proj-defs-format_: returns a JSON-ish quoted
989
+ # form of the given string-type values. It only performs the most
990
+ # basic of escaping. The input must not contain any control
991
+ # characters.
992
+ proc proj-quote-str_ {value} {
993
+ return \"[string map [list \\ \\\\ \" \\\"] $value]\"
994
+ }
995
+
996
+ ########################################################################
997
+ # An internal impl detail of proj-dump-defs-json. Requires a data
998
+ # type specifier, as used by make-config-header, and a value. Returns
999
+ # the formatted value or the value $::proj_(defs-skip) if the caller
1000
+ # should skip emitting that value.
1001
+ set proj_(defs-skip) "-proj-defs-format_ sentinel"
1002
+ proc proj-defs-format_ {type value} {
1003
+ switch -exact -- $type {
1004
+ -bare {
1005
+ # Just output the value unchanged
1006
+ }
1007
+ -none {
1008
+ set value $::proj_(defs-skip)
1009
+ }
1010
+ -str {
1011
+ set value [proj-quote-str_ $value]
1012
+ }
1013
+ -auto {
1014
+ # Automatically determine the type
1015
+ if {![string is integer -strict $value]} {
1016
+ set value [proj-quote-str_ $value]
1017
+ }
1018
+ }
1019
+ -array {
1020
+ set ar {}
1021
+ foreach v $value {
1022
+ set v [proj-defs-format_ -auto $v]
1023
+ if {$::proj_(defs-skip) ne $v} {
1024
+ lappend ar $v
1025
+ }
1026
+ }
1027
+ set value "\[ [join $ar {, }] \]"
1028
+ }
1029
+ "" {
1030
+ set value $::proj_(defs-skip)
1031
+ }
1032
+ default {
1033
+ proj-fatal "Unknown type in proj-dump-defs-json: $type"
1034
+ }
1035
+ }
1036
+ return $value
1037
+ }
1038
+
1039
+ ########################################################################
1040
+ # This function works almost identically to autosetup's
1041
+ # make-config-header but emits its output in JSON form. It is not a
1042
+ # fully-functional JSON emitter, and will emit broken JSON for
1043
+ # complicated outputs, but should be sufficient for purposes of
1044
+ # emitting most configure vars (numbers and simple strings).
1045
+ #
1046
+ # In addition to the formatting flags supported by make-config-header,
1047
+ # it also supports:
1048
+ #
1049
+ # -array {patterns...}
1050
+ #
1051
+ # Any defines matching the given patterns will be treated as a list of
1052
+ # values, each of which will be formatted as if it were in an -auto {...}
1053
+ # set, and the define will be emitted to JSON in the form:
1054
+ #
1055
+ # "ITS_NAME": [ "value1", ...valueN ]
1056
+ #
1057
+ # Achtung: if a given -array pattern contains values which themselves
1058
+ # contains spaces...
1059
+ #
1060
+ # define-append foo {"-DFOO=bar baz" -DBAR="baz barre"}
1061
+ #
1062
+ # will lead to:
1063
+ #
1064
+ # ["-DFOO=bar baz", "-DBAR=\"baz", "barre\""]
1065
+ #
1066
+ # Neither is especially satisfactory (and the second is useless), and
1067
+ # handling of such values is subject to change if any such values ever
1068
+ # _really_ need to be processed by our source trees.
1069
+ proc proj-dump-defs-json {file args} {
1070
+ file mkdir [file dirname $file]
1071
+ set lines {}
1072
+ lappend args -bare {SIZEOF_* HAVE_DECL_*} -auto HAVE_*
1073
+ foreach n [lsort [dict keys [all-defines]]] {
1074
+ set type [proj-defs-type_ $n $args]
1075
+ set value [proj-defs-format_ $type [get-define $n]]
1076
+ if {$::proj_(defs-skip) ne $value} {
1077
+ lappend lines "\"$n\": ${value}"
1078
+ }
1079
+ }
1080
+ set buf {}
1081
+ lappend buf [join $lines ",\n"]
1082
+ write-if-changed $file $buf {
1083
+ msg-result "Created $file"
1084
+ }
1085
+ }
1086
+
1087
+ ########################################################################
1088
+ # @proj-xfer-option-aliases map
1089
+ #
1090
+ # Expects a list of pairs of configure flags which have been
1091
+ # registered with autosetup, in this form:
1092
+ #
1093
+ # { alias1 => canonical1
1094
+ # aliasN => canonicalN ... }
1095
+ #
1096
+ # The names must not have their leading -- part and must be in the
1097
+ # form which autosetup will expect for passing to [opt-val NAME] and
1098
+ # friends.
1099
+ #
1100
+ # Comment lines are permitted in the input.
1101
+ #
1102
+ # For each pair of ALIAS and CANONICAL, if --ALIAS is provided but
1103
+ # --CANONICAL is not, the value of the former is copied to the
1104
+ # latter. If --ALIAS is not provided, this is a no-op. If both have
1105
+ # explicitly been provided a fatal usage error is triggered.
1106
+ #
1107
+ # Motivation: autosetup enables "hidden aliases" in [options] lists,
1108
+ # and elides the aliases from --help output but does no further
1109
+ # handling of them. For example, when --alias is a hidden alias of
1110
+ # --canonical and a user passes --alias=X, [opt-val canonical] returns
1111
+ # no value. i.e. the script must check both [opt-val alias] and
1112
+ # [opt-val canonical]. The intent here is that this function be
1113
+ # passed such mappings immediately after [options] is called, to carry
1114
+ # over any values from hidden aliases into their canonical names, such
1115
+ # that [opt-value canonical] will return X if --alias=X is passed to
1116
+ # configure.
1117
+ proc proj-xfer-options-aliases {mapping} {
1118
+ foreach {hidden - canonical} [proj-strip-hash-comments_ $mapping] {
1119
+ if {[proj-opt-was-provided $hidden]} {
1120
+ if {[proj-opt-was-provided $canonical]} {
1121
+ proj-fatal "both --$canonical and its alias --$hidden were used. Use only one or the other."
1122
+ } else {
1123
+ proj-opt-set $canonical [opt-val $hidden]
1124
+ }
1125
+ }
1126
+ }
1127
+ }
1128
+
1129
+ ########################################################################
1130
+ # Arguable/debatable...
1131
+ #
1132
+ # When _not_ cross-compiling and CC_FOR_BUILD is _not_ explcitely
1133
+ # specified, force CC_FOR_BUILD to be the same as CC, so that:
1134
+ #
1135
+ # ./configure CC=clang
1136
+ #
1137
+ # will use CC_FOR_BUILD=clang, instead of cc, for building in-tree
1138
+ # tools. This is based off of an email discussion and is thought to
1139
+ # be likely to cause less confusion than seeing 'cc' invocations
1140
+ # will when the user passes CC=clang.
1141
+ #
1142
+ # Sidebar: if we do this before the cc package is installed, it gets
1143
+ # reverted by that package. Ergo, the cc package init will tell the
1144
+ # user "Build C compiler...cc" shortly before we tell them otherwise.
1145
+ proc proj-redefine-cc-for-build {} {
1146
+ if {![proj-is-cross-compiling]
1147
+ && [get-define CC] ne [get-define CC_FOR_BUILD]
1148
+ && "nope" eq [get-env CC_FOR_BUILD "nope"]} {
1149
+ user-notice "Re-defining CC_FOR_BUILD to CC=[get-define CC]. To avoid this, explicitly pass CC_FOR_BUILD=..."
1150
+ define CC_FOR_BUILD [get-define CC]
1151
+ }
1152
+ }
1153
+
1154
+ ########################################################################
1155
+ # @proj-which-linenoise headerFile
1156
+ #
1157
+ # Attempts to determine whether the given linenoise header file is of
1158
+ # the "antirez" or "msteveb" flavor. It returns 2 for msteveb, else 1
1159
+ # (it does not validate that the header otherwise contains the
1160
+ # linenoise API).
1161
+ proc proj-which-linenoise {dotH} {
1162
+ set srcHeader [proj-file-content $dotH]
1163
+ if {[string match *userdata* $srcHeader]} {
1164
+ return 2
1165
+ } else {
1166
+ return 1
1167
+ }
1168
+ }
1169
+
1170
+ ########################################################################
1171
+ # @proj-remap-autoconf-dir-vars
1172
+ #
1173
+ # "Re-map" the autoconf-conventional --XYZdir flags into something
1174
+ # which is more easily overridable from a make invocation.
1175
+ #
1176
+ # Based off of notes in <https://sqlite.org/forum/forumpost/00d12a41f7>.
1177
+ #
1178
+ # Consider:
1179
+ #
1180
+ # $ ./configure --prefix=/foo
1181
+ # $ make install prefix=/blah
1182
+ #
1183
+ # In that make invocation, $(libdir) would, at make-time, normally be
1184
+ # hard-coded to /foo/lib, rather than /blah/lib. That happens because
1185
+ # the autosetup exports conventional $prefix-based values for the
1186
+ # numerous autoconfig-compatible XYZdir vars at configure-time. What
1187
+ # we would normally want, however, is that --libdir derives from the
1188
+ # make-time $(prefix). The distinction between configure-time and
1189
+ # make-time is the significant factor there.
1190
+ #
1191
+ # This function attempts to reconcile those vars in such a way that
1192
+ # they will derive, at make-time, from $(prefix) in a conventional
1193
+ # manner unless they are explicitly overridden at configure-time, in
1194
+ # which case those overrides takes precedence.
1195
+ #
1196
+ # Each --XYZdir flag which is explicitly passed to configure is
1197
+ # exported as-is, as are those which default to some top-level system
1198
+ # directory, e.g. /etc or /var. All which derive from either $prefix
1199
+ # or $exec_prefix are exported in the form of a Makefile var
1200
+ # reference, e.g. libdir=${exec_prefix}/lib. Ergo, if
1201
+ # --exec-prefix=FOO is passed to configure, libdir will still derive,
1202
+ # at make-time, from whatever exec_prefix is passed to make, and will
1203
+ # use FOO if exec_prefix is not overridden at make-time. Without this
1204
+ # post-processing, libdir would be cemented in as FOO/lib at
1205
+ # configure-time, so could be tedious to override properly via a make
1206
+ # invocation.
1207
+ proc proj-remap-autoconf-dir-vars {} {
1208
+ set prefix [get-define prefix]
1209
+ set exec_prefix [get-define exec_prefix $prefix]
1210
+ # Note that the ${...} here refers to make-side var derefs, not
1211
+ # TCL-side vars. They must be formulated such that they are legal
1212
+ # for use in (A) makefiles, (B) pkgconfig files, and (C) TCL's
1213
+ # [subst] command. i.e. they must use the form ${X}.
1214
+ foreach {flag makeVar makeDeref} {
1215
+ exec-prefix exec_prefix ${prefix}
1216
+ datadir datadir ${prefix}/share
1217
+ mandir mandir ${datadir}/man
1218
+ includedir includedir ${prefix}/include
1219
+ bindir bindir ${exec_prefix}/bin
1220
+ libdir libdir ${exec_prefix}/lib
1221
+ sbindir sbindir ${exec_prefix}/sbin
1222
+ sysconfdir sysconfdir /etc
1223
+ sharedstatedir sharedstatedir ${prefix}/com
1224
+ localstatedir localstatedir /var
1225
+ runstatedir runstatedir /run
1226
+ infodir infodir ${datadir}/info
1227
+ libexecdir libexecdir ${exec_prefix}/libexec
1228
+ } {
1229
+ if {[proj-opt-was-provided $flag]} {
1230
+ define $makeVar [join [opt-val $flag]]
1231
+ } else {
1232
+ define $makeVar [join $makeDeref]
1233
+ }
1234
+ # Maintenance reminder: the [join] call is to avoid {braces}
1235
+ # around the output when someone passes in,
1236
+ # e.g. --libdir=\${prefix}/foo/bar. The Debian package build
1237
+ # script does that.
1238
+ }
1239
+ }
1240
+
1241
+ ########################################################################
1242
+ # @proj-env-file flag ?default?
1243
+ #
1244
+ # If a file named .env-$flag exists, this function returns a
1245
+ # trimmed copy of its contents, else it returns $dflt. The intended
1246
+ # usage is that things like developer-specific CFLAGS preferences can
1247
+ # be stored in .env-CFLAGS.
1248
+ proc proj-env-file {flag {dflt ""}} {
1249
+ set fn ".env-${flag}"
1250
+ if {[file readable $fn]} {
1251
+ return [proj-file-content -trim $fn]
1252
+ }
1253
+ return $dflt
1254
+ }
1255
+
1256
+ ########################################################################
1257
+ # @proj-get-env var ?default?
1258
+ #
1259
+ # Extracts the value of "environment" variable $var from the first of
1260
+ # the following places where it's defined:
1261
+ #
1262
+ # - Passed to configure as $var=...
1263
+ # - Exists as an environment variable
1264
+ # - A file named .env-$var (see [proj-env-file])
1265
+ #
1266
+ # If none of those are set, $dflt is returned.
1267
+ proc proj-get-env {var {dflt ""}} {
1268
+ return [get-env $var [proj-env-file $var $dflt]]
1269
+ }
local-test-sqlite3-delta-02/afc-sqlite3/autosetup/system.tcl ADDED
@@ -0,0 +1,420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2010 WorkWare Systems http://www.workware.net.au/
2
+ # All rights reserved
3
+
4
+ # @synopsis:
5
+ #
6
+ # This module supports common system interrogation and options
7
+ # such as '--host', '--build', '--prefix', and setting 'srcdir', 'builddir', and 'EXEEXT'.
8
+ #
9
+ # It also support the "feature" naming convention, where searching
10
+ # for a feature such as 'sys/type.h' defines 'HAVE_SYS_TYPES_H'.
11
+ #
12
+ # It defines the following variables, based on '--prefix' unless overridden by the user:
13
+ #
14
+ ## datadir
15
+ ## sysconfdir
16
+ ## sharedstatedir
17
+ ## localstatedir
18
+ ## infodir
19
+ ## mandir
20
+ ## includedir
21
+ #
22
+ # If '--prefix' is not supplied, it defaults to '/usr/local' unless 'options-defaults { prefix ... }' is used *before*
23
+ # including the 'system' module.
24
+
25
+ if {[is-defined defaultprefix]} {
26
+ user-notice "Note: defaultprefix is deprecated. Use options-defaults to set default options"
27
+ options-defaults [list prefix [get-define defaultprefix]]
28
+ }
29
+
30
+ options {
31
+ host:host-alias => {a complete or partial cpu-vendor-opsys for the system where
32
+ the application will run (defaults to the same value as --build)}
33
+ build:build-alias => {a complete or partial cpu-vendor-opsys for the system
34
+ where the application will be built (defaults to the
35
+ result of running config.guess)}
36
+ prefix:dir=/usr/local => {the target directory for the build (default: '@default@')}
37
+
38
+ # These (hidden) options are supported for autoconf/automake compatibility
39
+ exec-prefix:
40
+ bindir:
41
+ sbindir:
42
+ includedir:
43
+ mandir:
44
+ infodir:
45
+ libexecdir:
46
+ datadir:
47
+ libdir:
48
+ sysconfdir:
49
+ sharedstatedir:
50
+ localstatedir:
51
+ runstatedir:
52
+ maintainer-mode=0
53
+ dependency-tracking=0
54
+ silent-rules=0
55
+ program-prefix:
56
+ program-suffix:
57
+ program-transform-name:
58
+ x-includes:
59
+ x-libraries:
60
+ }
61
+
62
+ # @check-feature name { script }
63
+ #
64
+ # defines feature '$name' to the return value of '$script',
65
+ # which should be 1 if found or 0 if not found.
66
+ #
67
+ # e.g. the following will define 'HAVE_CONST' to 0 or 1.
68
+ #
69
+ ## check-feature const {
70
+ ## cctest -code {const int _x = 0;}
71
+ ## }
72
+ proc check-feature {name code} {
73
+ msg-checking "Checking for $name..."
74
+ set r [uplevel 1 $code]
75
+ define-feature $name $r
76
+ if {$r} {
77
+ msg-result "ok"
78
+ } else {
79
+ msg-result "not found"
80
+ }
81
+ return $r
82
+ }
83
+
84
+ # @have-feature name ?default=0?
85
+ #
86
+ # Returns the value of feature '$name' if defined, or '$default' if not.
87
+ #
88
+ # See 'feature-define-name' for how the "feature" name
89
+ # is translated into the "define" name.
90
+ #
91
+ proc have-feature {name {default 0}} {
92
+ get-define [feature-define-name $name] $default
93
+ }
94
+
95
+ # @define-feature name ?value=1?
96
+ #
97
+ # Sets the feature 'define' to '$value'.
98
+ #
99
+ # See 'feature-define-name' for how the "feature" name
100
+ # is translated into the "define" name.
101
+ #
102
+ proc define-feature {name {value 1}} {
103
+ define [feature-define-name $name] $value
104
+ }
105
+
106
+ # @feature-checked name
107
+ #
108
+ # Returns 1 if feature '$name' has been checked, whether true or not.
109
+ #
110
+ proc feature-checked {name} {
111
+ is-defined [feature-define-name $name]
112
+ }
113
+
114
+ # @feature-define-name name ?prefix=HAVE_?
115
+ #
116
+ # Converts a "feature" name to the corresponding "define",
117
+ # e.g. 'sys/stat.h' becomes 'HAVE_SYS_STAT_H'.
118
+ #
119
+ # Converts '*' to 'P' and all non-alphanumeric to underscore.
120
+ #
121
+ proc feature-define-name {name {prefix HAVE_}} {
122
+ string toupper $prefix[regsub -all {[^a-zA-Z0-9]} [regsub -all {[*]} $name p] _]
123
+ }
124
+
125
+ # @write-if-changed filename contents ?script?
126
+ #
127
+ # If '$filename' doesn't exist, or it's contents are different to '$contents',
128
+ # the file is written and '$script' is evaluated.
129
+ #
130
+ # Otherwise a "file is unchanged" message is displayed.
131
+ proc write-if-changed {file buf {script {}}} {
132
+ set old [readfile $file ""]
133
+ if {$old eq $buf && [file exists $file]} {
134
+ msg-result "$file is unchanged"
135
+ } else {
136
+ writefile $file $buf\n
137
+ uplevel 1 $script
138
+ }
139
+ }
140
+
141
+
142
+ # @include-file infile mapping
143
+ #
144
+ # The core of make-template, called recursively for each @include
145
+ # directive found within that template so that this proc's result
146
+ # is the fully-expanded template.
147
+ #
148
+ # The mapping parameter is how we expand @varname@ within the template.
149
+ # We do that inline within this step only for @include directives which
150
+ # can have variables in the filename arg. A separate substitution pass
151
+ # happens when this recursive function returns, expanding the rest of
152
+ # the variables.
153
+ #
154
+ proc include-file {infile mapping} {
155
+ # A stack of true/false conditions, one for each nested conditional
156
+ # starting with "true"
157
+ set condstack {1}
158
+ set result {}
159
+ set linenum 0
160
+ foreach line [split [readfile $infile] \n] {
161
+ incr linenum
162
+ if {[regexp {^@(if|else|endif)(\s*)(.*)} $line -> condtype condspace condargs]} {
163
+ if {$condtype eq "if"} {
164
+ if {[string length $condspace] == 0} {
165
+ autosetup-error "$infile:$linenum: Invalid expression: $line"
166
+ }
167
+ if {[llength $condargs] == 1} {
168
+ # ABC => [get-define ABC] ni {0 ""}
169
+ # !ABC => [get-define ABC] in {0 ""}
170
+ lassign $condargs condvar
171
+ if {[regexp {^!(.*)} $condvar -> condvar]} {
172
+ set op in
173
+ } else {
174
+ set op ni
175
+ }
176
+ set condexpr "\[[list get-define $condvar]\] $op {0 {}}"
177
+ } else {
178
+ # Translate alphanumeric ABC into [get-define ABC] and leave the
179
+ # rest of the expression untouched
180
+ regsub -all {([A-Z][[:alnum:]_]*)} $condargs {[get-define \1]} condexpr
181
+ }
182
+ if {[catch [list expr $condexpr] condval]} {
183
+ dputs $condval
184
+ autosetup-error "$infile:$linenum: Invalid expression: $line"
185
+ }
186
+ dputs "@$condtype: $condexpr => $condval"
187
+ }
188
+ if {$condtype ne "if"} {
189
+ if {[llength $condstack] <= 1} {
190
+ autosetup-error "$infile:$linenum: Error: @$condtype missing @if"
191
+ } elseif {[string length $condargs] && [string index $condargs 0] ne "#"} {
192
+ autosetup-error "$infile:$linenum: Error: Extra arguments after @$condtype"
193
+ }
194
+ }
195
+ switch -exact $condtype {
196
+ if {
197
+ # push condval
198
+ lappend condstack $condval
199
+ }
200
+ else {
201
+ # Toggle the last entry
202
+ set condval [lpop condstack]
203
+ set condval [expr {!$condval}]
204
+ lappend condstack $condval
205
+ }
206
+ endif {
207
+ if {[llength $condstack] == 0} {
208
+ user-notice "$infile:$linenum: Error: @endif missing @if"
209
+ }
210
+ lpop condstack
211
+ }
212
+ }
213
+ continue
214
+ }
215
+ # Only continue if the stack contains all "true"
216
+ if {"0" in $condstack} {
217
+ continue
218
+ }
219
+ if {[regexp {^@include\s+(.*)} $line -> filearg]} {
220
+ set incfile [string map $mapping $filearg]
221
+ if {[file exists $incfile]} {
222
+ lappend ::autosetup(deps) [file-normalize $incfile]
223
+ lappend result {*}[include-file $incfile $mapping]
224
+ } else {
225
+ user-error "$infile:$linenum: Include file $incfile is missing"
226
+ }
227
+ continue
228
+ }
229
+ if {[regexp {^@define\s+(\w+)\s+(.*)} $line -> var val]} {
230
+ define $var $val
231
+ continue
232
+ }
233
+ lappend result $line
234
+ }
235
+ return $result
236
+ }
237
+
238
+
239
+ # @make-template template ?outfile?
240
+ #
241
+ # Reads the input file '<srcdir>/$template' and writes the output file '$outfile'
242
+ # (unless unchanged).
243
+ # If '$outfile' is blank/omitted, '$template' should end with '.in' which
244
+ # is removed to create the output file name.
245
+ #
246
+ # Each pattern of the form '@define@' is replaced with the corresponding
247
+ # "define", if it exists, or left unchanged if not.
248
+ #
249
+ # The special value '@srcdir@' is substituted with the relative
250
+ # path to the source directory from the directory where the output
251
+ # file is created, while the special value '@top_srcdir@' is substituted
252
+ # with the relative path to the top level source directory.
253
+ #
254
+ # Conditional sections may be specified as follows:
255
+ ## @if NAME eq "value"
256
+ ## lines
257
+ ## @else
258
+ ## lines
259
+ ## @endif
260
+ #
261
+ # Where 'NAME' is a defined variable name and '@else' is optional.
262
+ # Note that variables names *must* start with an uppercase letter.
263
+ # If the expression does not match, all lines through '@endif' are ignored.
264
+ #
265
+ # The alternative forms may also be used:
266
+ ## @if NAME (true if the variable is defined, but not empty and not "0")
267
+ ## @if !NAME (opposite of the form above)
268
+ ## @if <general-tcl-expression>
269
+ #
270
+ # In the general Tcl expression, any words beginning with an uppercase letter
271
+ # are translated into [get-define NAME]
272
+ #
273
+ # Expressions may be nested
274
+ #
275
+ proc make-template {template {out {}}} {
276
+ set infile [file join $::autosetup(srcdir) $template]
277
+
278
+ if {![file exists $infile]} {
279
+ user-error "Template $template is missing"
280
+ }
281
+
282
+ # Define this as late as possible
283
+ define AUTODEPS $::autosetup(deps)
284
+
285
+ if {$out eq ""} {
286
+ if {[file ext $template] ne ".in"} {
287
+ autosetup-error "make_template $template has no target file and can't guess"
288
+ }
289
+ set out [file rootname $template]
290
+ }
291
+
292
+ set outdir [file dirname $out]
293
+
294
+ # Make sure the directory exists
295
+ file mkdir $outdir
296
+
297
+ # Set up srcdir and top_srcdir to be relative to the target dir
298
+ define srcdir [relative-path [file join $::autosetup(srcdir) $outdir] $outdir]
299
+ define top_srcdir [relative-path $::autosetup(srcdir) $outdir]
300
+
301
+ # Build map from global defines to their values so they can be
302
+ # substituted into @include file names.
303
+ proc build-define-mapping {} {
304
+ set mapping {}
305
+ foreach {n v} [array get ::define] {
306
+ lappend mapping @$n@ $v
307
+ }
308
+ return $mapping
309
+ }
310
+ set mapping [build-define-mapping]
311
+
312
+ set result [include-file $infile $mapping]
313
+
314
+ # Rebuild the define mapping in case we ran across @define
315
+ # directives in the template or a file it @included, then
316
+ # apply that mapping to the expanded template.
317
+ set mapping [build-define-mapping]
318
+ write-if-changed $out [string map $mapping [join $result \n]] {
319
+ msg-result "Created [relative-path $out] from [relative-path $template]"
320
+ }
321
+ }
322
+
323
+ proc system-init {} {
324
+ global autosetup
325
+
326
+ # build/host tuples and cross-compilation prefix
327
+ opt-str build build ""
328
+ define build_alias $build
329
+ if {$build eq ""} {
330
+ define build [config_guess]
331
+ } else {
332
+ define build [config_sub $build]
333
+ }
334
+
335
+ opt-str host host ""
336
+ define host_alias $host
337
+ if {$host eq ""} {
338
+ define host [get-define build]
339
+ set cross ""
340
+ } else {
341
+ define host [config_sub $host]
342
+ set cross $host-
343
+ }
344
+ define cross [get-env CROSS $cross]
345
+
346
+ # build/host _cpu, _vendor and _os
347
+ foreach type {build host} {
348
+ set v [get-define $type]
349
+ if {![regexp {^([^-]+)-([^-]+)-(.*)$} $v -> cpu vendor os]} {
350
+ user-error "Invalid canonical $type: $v"
351
+ }
352
+ define ${type}_cpu $cpu
353
+ define ${type}_vendor $vendor
354
+ define ${type}_os $os
355
+ }
356
+
357
+ opt-str prefix prefix /usr/local
358
+
359
+ # These are for compatibility with autoconf
360
+ define target [get-define host]
361
+ define prefix $prefix
362
+ define builddir $autosetup(builddir)
363
+ define srcdir $autosetup(srcdir)
364
+ define top_srcdir $autosetup(srcdir)
365
+ define abs_top_srcdir [file-normalize $autosetup(srcdir)]
366
+ define abs_top_builddir [file-normalize $autosetup(builddir)]
367
+
368
+ # autoconf supports all of these
369
+ define exec_prefix [opt-str exec-prefix exec_prefix $prefix]
370
+ foreach {name defpath} {
371
+ bindir /bin
372
+ sbindir /sbin
373
+ libexecdir /libexec
374
+ libdir /lib
375
+ } {
376
+ define $name [opt-str $name o $exec_prefix$defpath]
377
+ }
378
+ foreach {name defpath} {
379
+ datadir /share
380
+ sharedstatedir /com
381
+ infodir /share/info
382
+ mandir /share/man
383
+ includedir /include
384
+ } {
385
+ define $name [opt-str $name o $prefix$defpath]
386
+ }
387
+ if {$prefix ne {/usr}} {
388
+ opt-str sysconfdir sysconfdir $prefix/etc
389
+ } else {
390
+ opt-str sysconfdir sysconfdir /etc
391
+ }
392
+ define sysconfdir $sysconfdir
393
+
394
+ define localstatedir [opt-str localstatedir o /var]
395
+ define runstatedir [opt-str runstatedir o /run]
396
+
397
+ define SHELL [get-env SHELL [find-an-executable sh bash ksh]]
398
+
399
+ # These could be used to generate Makefiles following some automake conventions
400
+ define AM_SILENT_RULES [opt-bool silent-rules]
401
+ define AM_MAINTAINER_MODE [opt-bool maintainer-mode]
402
+ define AM_DEPENDENCY_TRACKING [opt-bool dependency-tracking]
403
+
404
+ # Windows vs. non-Windows
405
+ switch -glob -- [get-define host] {
406
+ *-*-ming* - *-*-cygwin - *-*-msys {
407
+ define-feature windows
408
+ define EXEEXT .exe
409
+ }
410
+ default {
411
+ define EXEEXT ""
412
+ }
413
+ }
414
+
415
+ # Display
416
+ msg-result "Host System...[get-define host]"
417
+ msg-result "Build System...[get-define build]"
418
+ }
419
+
420
+ system-init
local-test-sqlite3-delta-02/afc-sqlite3/contrib/sqlitecon.tcl ADDED
@@ -0,0 +1,679 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A Tk console widget for SQLite. Invoke sqlitecon::create with a window name,
2
+ # a prompt string, a title to set a new top-level window, and the SQLite
3
+ # database handle. For example:
4
+ #
5
+ # sqlitecon::create .sqlcon {sql:- } {SQL Console} db
6
+ #
7
+ # A toplevel window is created that allows you to type in SQL commands to
8
+ # be processed on the spot.
9
+ #
10
+ # A limited set of dot-commands are supported:
11
+ #
12
+ # .table
13
+ # .schema ?TABLE?
14
+ # .mode list|column|multicolumn|line
15
+ # .exit
16
+ #
17
+ # In addition, a new SQL function named "edit()" is created. This function
18
+ # takes a single text argument and returns a text result. Whenever the
19
+ # the function is called, it pops up a new toplevel window containing a
20
+ # text editor screen initialized to the argument. When the "OK" button
21
+ # is pressed, whatever revised text is in the text editor is returned as
22
+ # the result of the edit() function. This allows text fields of SQL tables
23
+ # to be edited quickly and easily as follows:
24
+ #
25
+ # UPDATE table1 SET dscr = edit(dscr) WHERE rowid=15;
26
+ #
27
+
28
+
29
+ # Create a namespace to work in
30
+ #
31
+ namespace eval ::sqlitecon {
32
+ # do nothing
33
+ }
34
+
35
+ # Create a console widget named $w. The prompt string is $prompt.
36
+ # The title at the top of the window is $title. The database connection
37
+ # object is $db
38
+ #
39
+ proc sqlitecon::create {w prompt title db} {
40
+ upvar #0 $w.t v
41
+ if {[winfo exists $w]} {destroy $w}
42
+ if {[info exists v]} {unset v}
43
+ toplevel $w
44
+ wm title $w $title
45
+ wm iconname $w $title
46
+ frame $w.mb -bd 2 -relief raised
47
+ pack $w.mb -side top -fill x
48
+ menubutton $w.mb.file -text File -menu $w.mb.file.m
49
+ menubutton $w.mb.edit -text Edit -menu $w.mb.edit.m
50
+ pack $w.mb.file $w.mb.edit -side left -padx 8 -pady 1
51
+ set m [menu $w.mb.file.m -tearoff 0]
52
+ $m add command -label {Close} -command "destroy $w"
53
+ sqlitecon::create_child $w $prompt $w.mb.edit.m
54
+ set v(db) $db
55
+ $db function edit ::sqlitecon::_edit
56
+ }
57
+
58
+ # This routine creates a console as a child window within a larger
59
+ # window. It also creates an edit menu named "$editmenu" if $editmenu!="".
60
+ # The calling function is responsible for posting the edit menu.
61
+ #
62
+ proc sqlitecon::create_child {w prompt editmenu} {
63
+ upvar #0 $w.t v
64
+ if {$editmenu!=""} {
65
+ set m [menu $editmenu -tearoff 0]
66
+ $m add command -label Cut -command "sqlitecon::Cut $w.t"
67
+ $m add command -label Copy -command "sqlitecon::Copy $w.t"
68
+ $m add command -label Paste -command "sqlitecon::Paste $w.t"
69
+ $m add command -label {Clear Screen} -command "sqlitecon::Clear $w.t"
70
+ $m add separator
71
+ $m add command -label {Save As...} -command "sqlitecon::SaveFile $w.t"
72
+ catch {$editmenu config -postcommand "sqlitecon::EnableEditMenu $w"}
73
+ }
74
+ scrollbar $w.sb -orient vertical -command "$w.t yview"
75
+ pack $w.sb -side right -fill y
76
+ text $w.t -font fixed -yscrollcommand "$w.sb set"
77
+ pack $w.t -side right -fill both -expand 1
78
+ bindtags $w.t Sqlitecon
79
+ set v(editmenu) $editmenu
80
+ set v(history) 0
81
+ set v(historycnt) 0
82
+ set v(current) -1
83
+ set v(prompt) $prompt
84
+ set v(prior) {}
85
+ set v(plength) [string length $v(prompt)]
86
+ set v(x) 0
87
+ set v(y) 0
88
+ set v(mode) column
89
+ set v(header) on
90
+ $w.t mark set insert end
91
+ $w.t tag config ok -foreground blue
92
+ $w.t tag config err -foreground red
93
+ $w.t insert end $v(prompt)
94
+ $w.t mark set out 1.0
95
+ after idle "focus $w.t"
96
+ }
97
+
98
+ bind Sqlitecon <1> {sqlitecon::Button1 %W %x %y}
99
+ bind Sqlitecon <B1-Motion> {sqlitecon::B1Motion %W %x %y}
100
+ bind Sqlitecon <B1-Leave> {sqlitecon::B1Leave %W %x %y}
101
+ bind Sqlitecon <B1-Enter> {sqlitecon::cancelMotor %W}
102
+ bind Sqlitecon <ButtonRelease-1> {sqlitecon::cancelMotor %W}
103
+ bind Sqlitecon <KeyPress> {sqlitecon::Insert %W %A}
104
+ bind Sqlitecon <Left> {sqlitecon::Left %W}
105
+ bind Sqlitecon <Control-b> {sqlitecon::Left %W}
106
+ bind Sqlitecon <Right> {sqlitecon::Right %W}
107
+ bind Sqlitecon <Control-f> {sqlitecon::Right %W}
108
+ bind Sqlitecon <BackSpace> {sqlitecon::Backspace %W}
109
+ bind Sqlitecon <Control-h> {sqlitecon::Backspace %W}
110
+ bind Sqlitecon <Delete> {sqlitecon::Delete %W}
111
+ bind Sqlitecon <Control-d> {sqlitecon::Delete %W}
112
+ bind Sqlitecon <Home> {sqlitecon::Home %W}
113
+ bind Sqlitecon <Control-a> {sqlitecon::Home %W}
114
+ bind Sqlitecon <End> {sqlitecon::End %W}
115
+ bind Sqlitecon <Control-e> {sqlitecon::End %W}
116
+ bind Sqlitecon <Return> {sqlitecon::Enter %W}
117
+ bind Sqlitecon <KP_Enter> {sqlitecon::Enter %W}
118
+ bind Sqlitecon <Up> {sqlitecon::Prior %W}
119
+ bind Sqlitecon <Control-p> {sqlitecon::Prior %W}
120
+ bind Sqlitecon <Down> {sqlitecon::Next %W}
121
+ bind Sqlitecon <Control-n> {sqlitecon::Next %W}
122
+ bind Sqlitecon <Control-k> {sqlitecon::EraseEOL %W}
123
+ bind Sqlitecon <<Cut>> {sqlitecon::Cut %W}
124
+ bind Sqlitecon <<Copy>> {sqlitecon::Copy %W}
125
+ bind Sqlitecon <<Paste>> {sqlitecon::Paste %W}
126
+ bind Sqlitecon <<Clear>> {sqlitecon::Clear %W}
127
+
128
+ # Insert a single character at the insertion cursor
129
+ #
130
+ proc sqlitecon::Insert {w a} {
131
+ $w insert insert $a
132
+ $w yview insert
133
+ }
134
+
135
+ # Move the cursor one character to the left
136
+ #
137
+ proc sqlitecon::Left {w} {
138
+ upvar #0 $w v
139
+ scan [$w index insert] %d.%d row col
140
+ if {$col>$v(plength)} {
141
+ $w mark set insert "insert -1c"
142
+ }
143
+ }
144
+
145
+ # Erase the character to the left of the cursor
146
+ #
147
+ proc sqlitecon::Backspace {w} {
148
+ upvar #0 $w v
149
+ scan [$w index insert] %d.%d row col
150
+ if {$col>$v(plength)} {
151
+ $w delete {insert -1c}
152
+ }
153
+ }
154
+
155
+ # Erase to the end of the line
156
+ #
157
+ proc sqlitecon::EraseEOL {w} {
158
+ upvar #0 $w v
159
+ scan [$w index insert] %d.%d row col
160
+ if {$col>=$v(plength)} {
161
+ $w delete insert {insert lineend}
162
+ }
163
+ }
164
+
165
+ # Move the cursor one character to the right
166
+ #
167
+ proc sqlitecon::Right {w} {
168
+ $w mark set insert "insert +1c"
169
+ }
170
+
171
+ # Erase the character to the right of the cursor
172
+ #
173
+ proc sqlitecon::Delete w {
174
+ $w delete insert
175
+ }
176
+
177
+ # Move the cursor to the beginning of the current line
178
+ #
179
+ proc sqlitecon::Home w {
180
+ upvar #0 $w v
181
+ scan [$w index insert] %d.%d row col
182
+ $w mark set insert $row.$v(plength)
183
+ }
184
+
185
+ # Move the cursor to the end of the current line
186
+ #
187
+ proc sqlitecon::End w {
188
+ $w mark set insert {insert lineend}
189
+ }
190
+
191
+ # Add a line to the history
192
+ #
193
+ proc sqlitecon::addHistory {w line} {
194
+ upvar #0 $w v
195
+ if {$v(historycnt)>0} {
196
+ set last [lindex $v(history) [expr $v(historycnt)-1]]
197
+ if {[string compare $last $line]} {
198
+ lappend v(history) $line
199
+ incr v(historycnt)
200
+ }
201
+ } else {
202
+ set v(history) [list $line]
203
+ set v(historycnt) 1
204
+ }
205
+ set v(current) $v(historycnt)
206
+ }
207
+
208
+ # Called when "Enter" is pressed. Do something with the line
209
+ # of text that was entered.
210
+ #
211
+ proc sqlitecon::Enter w {
212
+ upvar #0 $w v
213
+ scan [$w index insert] %d.%d row col
214
+ set start $row.$v(plength)
215
+ set line [$w get $start "$start lineend"]
216
+ $w insert end \n
217
+ $w mark set out end
218
+ if {$v(prior)==""} {
219
+ set cmd $line
220
+ } else {
221
+ set cmd $v(prior)\n$line
222
+ }
223
+ if {[string index $cmd 0]=="." || [$v(db) complete $cmd]} {
224
+ regsub -all {\n} [string trim $cmd] { } cmd2
225
+ addHistory $w $cmd2
226
+ set rc [catch {DoCommand $w $cmd} res]
227
+ if {![winfo exists $w]} return
228
+ if {$rc} {
229
+ $w insert end $res\n err
230
+ } elseif {[string length $res]>0} {
231
+ $w insert end $res\n ok
232
+ }
233
+ set v(prior) {}
234
+ $w insert end $v(prompt)
235
+ } else {
236
+ set v(prior) $cmd
237
+ regsub -all {[^ ]} $v(prompt) . x
238
+ $w insert end $x
239
+ }
240
+ $w mark set insert end
241
+ $w mark set out {insert linestart}
242
+ $w yview insert
243
+ }
244
+
245
+ # Execute a single SQL command. Pay special attention to control
246
+ # directives that begin with "."
247
+ #
248
+ # The return value is the text output from the command, properly
249
+ # formatted.
250
+ #
251
+ proc sqlitecon::DoCommand {w cmd} {
252
+ upvar #0 $w v
253
+ set mode $v(mode)
254
+ set header $v(header)
255
+ if {[regexp {^(\.[a-z]+)} $cmd all word]} {
256
+ if {$word==".mode"} {
257
+ regexp {^.[a-z]+ +([a-z]+)} $cmd all v(mode)
258
+ return {}
259
+ } elseif {$word==".exit"} {
260
+ destroy [winfo toplevel $w]
261
+ return {}
262
+ } elseif {$word==".header"} {
263
+ regexp {^.[a-z]+ +([a-z]+)} $cmd all v(header)
264
+ return {}
265
+ } elseif {$word==".tables"} {
266
+ set mode multicolumn
267
+ set cmd {SELECT name FROM sqlite_master WHERE type='table'
268
+ UNION ALL
269
+ SELECT name FROM sqlite_temp_master WHERE type='table'}
270
+ $v(db) eval {PRAGMA database_list} {
271
+ if {$name!="temp" && $name!="main"} {
272
+ append cmd "UNION ALL SELECT name FROM $name.sqlite_master\
273
+ WHERE type='table'"
274
+ }
275
+ }
276
+ append cmd { ORDER BY 1}
277
+ } elseif {$word==".fullschema"} {
278
+ set pattern %
279
+ regexp {^.[a-z]+ +([^ ]+)} $cmd all pattern
280
+ set mode list
281
+ set header 0
282
+ set cmd "SELECT sql FROM sqlite_master WHERE tbl_name LIKE '$pattern'
283
+ AND sql NOT NULL UNION ALL SELECT sql FROM sqlite_temp_master
284
+ WHERE tbl_name LIKE '$pattern' AND sql NOT NULL"
285
+ $v(db) eval {PRAGMA database_list} {
286
+ if {$name!="temp" && $name!="main"} {
287
+ append cmd " UNION ALL SELECT sql FROM $name.sqlite_master\
288
+ WHERE tbl_name LIKE '$pattern' AND sql NOT NULL"
289
+ }
290
+ }
291
+ } elseif {$word==".schema"} {
292
+ set pattern %
293
+ regexp {^.[a-z]+ +([^ ]+)} $cmd all pattern
294
+ set mode list
295
+ set header 0
296
+ set cmd "SELECT sql FROM sqlite_master WHERE name LIKE '$pattern'
297
+ AND sql NOT NULL UNION ALL SELECT sql FROM sqlite_temp_master
298
+ WHERE name LIKE '$pattern' AND sql NOT NULL"
299
+ $v(db) eval {PRAGMA database_list} {
300
+ if {$name!="temp" && $name!="main"} {
301
+ append cmd " UNION ALL SELECT sql FROM $name.sqlite_master\
302
+ WHERE name LIKE '$pattern' AND sql NOT NULL"
303
+ }
304
+ }
305
+ } else {
306
+ return \
307
+ ".exit\n.mode line|list|column\n.schema ?TABLENAME?\n.tables"
308
+ }
309
+ }
310
+ set res {}
311
+ if {$mode=="list"} {
312
+ $v(db) eval $cmd x {
313
+ set sep {}
314
+ foreach col $x(*) {
315
+ append res $sep$x($col)
316
+ set sep |
317
+ }
318
+ append res \n
319
+ }
320
+ if {[info exists x(*)] && $header} {
321
+ set sep {}
322
+ set hdr {}
323
+ foreach col $x(*) {
324
+ append hdr $sep$col
325
+ set sep |
326
+ }
327
+ set res $hdr\n$res
328
+ }
329
+ } elseif {[string range $mode 0 2]=="col"} {
330
+ set y {}
331
+ $v(db) eval $cmd x {
332
+ foreach col $x(*) {
333
+ if {![info exists cw($col)] || $cw($col)<[string length $x($col)]} {
334
+ set cw($col) [string length $x($col)]
335
+ }
336
+ lappend y $x($col)
337
+ }
338
+ }
339
+ if {[info exists x(*)] && $header} {
340
+ set hdr {}
341
+ set ln {}
342
+ set dash ---------------------------------------------------------------
343
+ append dash ------------------------------------------------------------
344
+ foreach col $x(*) {
345
+ if {![info exists cw($col)] || $cw($col)<[string length $col]} {
346
+ set cw($col) [string length $col]
347
+ }
348
+ lappend hdr $col
349
+ lappend ln [string range $dash 1 $cw($col)]
350
+ }
351
+ set y [concat $hdr $ln $y]
352
+ }
353
+ if {[info exists x(*)]} {
354
+ set format {}
355
+ set arglist {}
356
+ set arglist2 {}
357
+ set i 0
358
+ foreach col $x(*) {
359
+ lappend arglist x$i
360
+ append arglist2 " \$x$i"
361
+ incr i
362
+ append format " %-$cw($col)s"
363
+ }
364
+ set format [string trimleft $format]\n
365
+ if {[llength $arglist]>0} {
366
+ foreach $arglist $y "append res \[format [list $format] $arglist2\]"
367
+ }
368
+ }
369
+ } elseif {$mode=="multicolumn"} {
370
+ set y [$v(db) eval $cmd]
371
+ set max 0
372
+ foreach e $y {
373
+ if {$max<[string length $e]} {set max [string length $e]}
374
+ }
375
+ set ncol [expr {int(80/($max+2))}]
376
+ if {$ncol<1} {set ncol 1}
377
+ set nelem [llength $y]
378
+ set nrow [expr {($nelem+$ncol-1)/$ncol}]
379
+ set format "%-${max}s"
380
+ for {set i 0} {$i<$nrow} {incr i} {
381
+ set j $i
382
+ while 1 {
383
+ append res [format $format [lindex $y $j]]
384
+ incr j $nrow
385
+ if {$j>=$nelem} break
386
+ append res { }
387
+ }
388
+ append res \n
389
+ }
390
+ } else {
391
+ $v(db) eval $cmd x {
392
+ foreach col $x(*) {append res "$col = $x($col)\n"}
393
+ append res \n
394
+ }
395
+ }
396
+ return [string trimright $res]
397
+ }
398
+
399
+ # Change the line to the previous line
400
+ #
401
+ proc sqlitecon::Prior w {
402
+ upvar #0 $w v
403
+ if {$v(current)<=0} return
404
+ incr v(current) -1
405
+ set line [lindex $v(history) $v(current)]
406
+ sqlitecon::SetLine $w $line
407
+ }
408
+
409
+ # Change the line to the next line
410
+ #
411
+ proc sqlitecon::Next w {
412
+ upvar #0 $w v
413
+ if {$v(current)>=$v(historycnt)} return
414
+ incr v(current) 1
415
+ set line [lindex $v(history) $v(current)]
416
+ sqlitecon::SetLine $w $line
417
+ }
418
+
419
+ # Change the contents of the entry line
420
+ #
421
+ proc sqlitecon::SetLine {w line} {
422
+ upvar #0 $w v
423
+ scan [$w index insert] %d.%d row col
424
+ set start $row.$v(plength)
425
+ $w delete $start end
426
+ $w insert end $line
427
+ $w mark set insert end
428
+ $w yview insert
429
+ }
430
+
431
+ # Called when the mouse button is pressed at position $x,$y on
432
+ # the console widget.
433
+ #
434
+ proc sqlitecon::Button1 {w x y} {
435
+ global tkPriv
436
+ upvar #0 $w v
437
+ set v(mouseMoved) 0
438
+ set v(pressX) $x
439
+ set p [sqlitecon::nearestBoundry $w $x $y]
440
+ scan [$w index insert] %d.%d ix iy
441
+ scan $p %d.%d px py
442
+ if {$px==$ix} {
443
+ $w mark set insert $p
444
+ }
445
+ $w mark set anchor $p
446
+ focus $w
447
+ }
448
+
449
+ # Find the boundry between characters that is nearest
450
+ # to $x,$y
451
+ #
452
+ proc sqlitecon::nearestBoundry {w x y} {
453
+ set p [$w index @$x,$y]
454
+ set bb [$w bbox $p]
455
+ if {![string compare $bb ""]} {return $p}
456
+ if {($x-[lindex $bb 0])<([lindex $bb 2]/2)} {return $p}
457
+ $w index "$p + 1 char"
458
+ }
459
+
460
+ # This routine extends the selection to the point specified by $x,$y
461
+ #
462
+ proc sqlitecon::SelectTo {w x y} {
463
+ upvar #0 $w v
464
+ set cur [sqlitecon::nearestBoundry $w $x $y]
465
+ if {[catch {$w index anchor}]} {
466
+ $w mark set anchor $cur
467
+ }
468
+ set anchor [$w index anchor]
469
+ if {[$w compare $cur != $anchor] || (abs($v(pressX) - $x) >= 3)} {
470
+ if {$v(mouseMoved)==0} {
471
+ $w tag remove sel 0.0 end
472
+ }
473
+ set v(mouseMoved) 1
474
+ }
475
+ if {[$w compare $cur < anchor]} {
476
+ set first $cur
477
+ set last anchor
478
+ } else {
479
+ set first anchor
480
+ set last $cur
481
+ }
482
+ if {$v(mouseMoved)} {
483
+ $w tag remove sel 0.0 $first
484
+ $w tag add sel $first $last
485
+ $w tag remove sel $last end
486
+ update idletasks
487
+ }
488
+ }
489
+
490
+ # Called whenever the mouse moves while button-1 is held down.
491
+ #
492
+ proc sqlitecon::B1Motion {w x y} {
493
+ upvar #0 $w v
494
+ set v(y) $y
495
+ set v(x) $x
496
+ sqlitecon::SelectTo $w $x $y
497
+ }
498
+
499
+ # Called whenever the mouse leaves the boundries of the widget
500
+ # while button 1 is held down.
501
+ #
502
+ proc sqlitecon::B1Leave {w x y} {
503
+ upvar #0 $w v
504
+ set v(y) $y
505
+ set v(x) $x
506
+ sqlitecon::motor $w
507
+ }
508
+
509
+ # This routine is called to automatically scroll the window when
510
+ # the mouse drags offscreen.
511
+ #
512
+ proc sqlitecon::motor w {
513
+ upvar #0 $w v
514
+ if {![winfo exists $w]} return
515
+ if {$v(y)>=[winfo height $w]} {
516
+ $w yview scroll 1 units
517
+ } elseif {$v(y)<0} {
518
+ $w yview scroll -1 units
519
+ } else {
520
+ return
521
+ }
522
+ sqlitecon::SelectTo $w $v(x) $v(y)
523
+ set v(timer) [after 50 sqlitecon::motor $w]
524
+ }
525
+
526
+ # This routine cancels the scrolling motor if it is active
527
+ #
528
+ proc sqlitecon::cancelMotor w {
529
+ upvar #0 $w v
530
+ catch {after cancel $v(timer)}
531
+ catch {unset v(timer)}
532
+ }
533
+
534
+ # Do a Copy operation on the stuff currently selected.
535
+ #
536
+ proc sqlitecon::Copy w {
537
+ if {![catch {set text [$w get sel.first sel.last]}]} {
538
+ clipboard clear -displayof $w
539
+ clipboard append -displayof $w $text
540
+ }
541
+ }
542
+
543
+ # Return 1 if the selection exists and is contained
544
+ # entirely on the input line. Return 2 if the selection
545
+ # exists but is not entirely on the input line. Return 0
546
+ # if the selection does not exist.
547
+ #
548
+ proc sqlitecon::canCut w {
549
+ set r [catch {
550
+ scan [$w index sel.first] %d.%d s1x s1y
551
+ scan [$w index sel.last] %d.%d s2x s2y
552
+ scan [$w index insert] %d.%d ix iy
553
+ }]
554
+ if {$r==1} {return 0}
555
+ if {$s1x==$ix && $s2x==$ix} {return 1}
556
+ return 2
557
+ }
558
+
559
+ # Do a Cut operation if possible. Cuts are only allowed
560
+ # if the current selection is entirely contained on the
561
+ # current input line.
562
+ #
563
+ proc sqlitecon::Cut w {
564
+ if {[sqlitecon::canCut $w]==1} {
565
+ sqlitecon::Copy $w
566
+ $w delete sel.first sel.last
567
+ }
568
+ }
569
+
570
+ # Do a paste opeation.
571
+ #
572
+ proc sqlitecon::Paste w {
573
+ if {[sqlitecon::canCut $w]==1} {
574
+ $w delete sel.first sel.last
575
+ }
576
+ if {[catch {selection get -displayof $w -selection CLIPBOARD} topaste]
577
+ && [catch {selection get -displayof $w -selection PRIMARY} topaste]} {
578
+ return
579
+ }
580
+ if {[info exists ::$w]} {
581
+ set prior 0
582
+ foreach line [split $topaste \n] {
583
+ if {$prior} {
584
+ sqlitecon::Enter $w
585
+ update
586
+ }
587
+ set prior 1
588
+ $w insert insert $line
589
+ }
590
+ } else {
591
+ $w insert insert $topaste
592
+ }
593
+ }
594
+
595
+ # Enable or disable entries in the Edit menu
596
+ #
597
+ proc sqlitecon::EnableEditMenu w {
598
+ upvar #0 $w.t v
599
+ set m $v(editmenu)
600
+ if {$m=="" || ![winfo exists $m]} return
601
+ switch [sqlitecon::canCut $w.t] {
602
+ 0 {
603
+ $m entryconf Copy -state disabled
604
+ $m entryconf Cut -state disabled
605
+ }
606
+ 1 {
607
+ $m entryconf Copy -state normal
608
+ $m entryconf Cut -state normal
609
+ }
610
+ 2 {
611
+ $m entryconf Copy -state normal
612
+ $m entryconf Cut -state disabled
613
+ }
614
+ }
615
+ }
616
+
617
+ # Prompt the user for the name of a writable file. Then write the
618
+ # entire contents of the console screen to that file.
619
+ #
620
+ proc sqlitecon::SaveFile w {
621
+ set types {
622
+ {{Text Files} {.txt}}
623
+ {{All Files} *}
624
+ }
625
+ set f [tk_getSaveFile -filetypes $types -title "Write Screen To..."]
626
+ if {$f!=""} {
627
+ if {[catch {open $f w} fd]} {
628
+ tk_messageBox -type ok -icon error -message $fd
629
+ } else {
630
+ puts $fd [string trimright [$w get 1.0 end] \n]
631
+ close $fd
632
+ }
633
+ }
634
+ }
635
+
636
+ # Erase everything from the console above the insertion line.
637
+ #
638
+ proc sqlitecon::Clear w {
639
+ $w delete 1.0 {insert linestart}
640
+ }
641
+
642
+ # An in-line editor for SQL
643
+ #
644
+ proc sqlitecon::_edit {origtxt {title {}}} {
645
+ for {set i 0} {[winfo exists .ed$i]} {incr i} continue
646
+ set w .ed$i
647
+ toplevel $w
648
+ wm protocol $w WM_DELETE_WINDOW "$w.b.can invoke"
649
+ wm title $w {Inline SQL Editor}
650
+ frame $w.b
651
+ pack $w.b -side bottom -fill x
652
+ button $w.b.can -text Cancel -width 6 -command [list set ::$w 0]
653
+ button $w.b.ok -text OK -width 6 -command [list set ::$w 1]
654
+ button $w.b.cut -text Cut -width 6 -command [list ::sqlitecon::Cut $w.t]
655
+ button $w.b.copy -text Copy -width 6 -command [list ::sqlitecon::Copy $w.t]
656
+ button $w.b.paste -text Paste -width 6 -command [list ::sqlitecon::Paste $w.t]
657
+ set ::$w {}
658
+ pack $w.b.cut $w.b.copy $w.b.paste $w.b.can $w.b.ok\
659
+ -side left -padx 5 -pady 5 -expand 1
660
+ if {$title!=""} {
661
+ label $w.title -text $title
662
+ pack $w.title -side top -padx 5 -pady 5
663
+ }
664
+ text $w.t -bg white -fg black -yscrollcommand [list $w.sb set]
665
+ pack $w.t -side left -fill both -expand 1
666
+ scrollbar $w.sb -orient vertical -command [list $w.t yview]
667
+ pack $w.sb -side left -fill y
668
+ $w.t insert end $origtxt
669
+
670
+ vwait ::$w
671
+
672
+ if {[set ::$w]} {
673
+ set txt [string trimright [$w.t get 1.0 end]]
674
+ } else {
675
+ set txt $origtxt
676
+ }
677
+ destroy $w
678
+ return $txt
679
+ }
local-test-sqlite3-delta-02/afc-sqlite3/doc/F2FS.txt ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ SQLite's OS layer contains the following definitions used in F2FS related
3
+ calls:
4
+
5
+ #define F2FS_IOCTL_MAGIC 0xf5
6
+ #define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1)
7
+ #define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)
8
+ #define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3)
9
+ #define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5)
10
+ #define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, u32)
11
+ #define F2FS_FEATURE_ATOMIC_WRITE 0x0004
12
+
13
+ After opening a database file on Linux (including Android), SQLite determines
14
+ whether or not a file supports F2FS atomic commits as follows:
15
+
16
+ u32 flags = 0;
17
+ rc = ioctl(fd, F2FS_IOC_GET_FEATURES, &flags);
18
+ if( rc==0 && (flags & F2FS_FEATURE_ATOMIC_WRITE) ){
19
+ /* File supports F2FS atomic commits */
20
+ }else{
21
+ /* File does NOT support F2FS atomic commits */
22
+ }
23
+
24
+ where "fd" is the file-descriptor open on the database file.
25
+
26
+ Usually, when writing to a database file that supports atomic commits, SQLite
27
+ accumulates the entire transaction in heap memory, deferring all writes to the
28
+ db file until the transaction is committed.
29
+
30
+ When it is time to commit a transaction on a file that supports atomic
31
+ commits, SQLite does:
32
+
33
+ /* Take an F_WRLCK lock on the database file. This prevents any other
34
+ ** SQLite clients from reading or writing the file until the lock
35
+ ** is released. */
36
+ rc = fcntl(fd, F_SETLK, ...);
37
+ if( rc!=0 ) goto failed;
38
+
39
+ rc = ioctl(fd, F2FS_IOC_START_ATOMIC_WRITE);
40
+ if( rc!=0 ) goto fallback_to_legacy_journal_commit;
41
+
42
+ foreach (dirty page){
43
+ rc = write(fd, ...dirty page...);
44
+ if( rc!=0 ){
45
+ ioctl(fd, F2FS_IOC_ABORT_VOLATILE_WRITE);
46
+ goto fallback_to_legacy_journal_commit;
47
+ }
48
+ }
49
+
50
+ rc = ioctl(fd, F2FS_IOC_COMMIT_ATOMIC_WRITE);
51
+ if( rc!=0 ){
52
+ ioctl(fd, F2FS_IOC_ABORT_VOLATILE_WRITE);
53
+ goto fallback_to_legacy_journal_commit;
54
+ }
55
+
56
+ /* If we get there, the transaction has been successfully
57
+ ** committed to persistent storage. The following call
58
+ ** relinquishes the F_WRLCK lock. */
59
+ fcntl(fd, F_SETLK, ...);
60
+
61
+ Assumptions:
62
+
63
+ 1. After either of the F2FS_IOC_ABORT_VOLATILE_WRITE calls return,
64
+ the database file is in the state that it was in before
65
+ F2FS_IOC_START_ATOMIC_WRITE was invoked. Even if the ioctl()
66
+ fails - we're ignoring the return code.
67
+
68
+ This is true regardless of the type of error that occurred in
69
+ ioctl() or write().
70
+
71
+ 2. If the system fails before the F2FS_IOC_COMMIT_ATOMIC_WRITE is
72
+ completed, then following a reboot the database file is in the
73
+ state that it was in before F2FS_IOC_START_ATOMIC_WRITE was invoked.
74
+ Or, if the write was commited right before the system failed, in a
75
+ state indicating that all write() calls were successfully committed
76
+ to persistent storage before the failure occurred.
77
+
78
+ 3. If the process crashes before the F2FS_IOC_COMMIT_ATOMIC_WRITE is
79
+ completed then the file is automatically restored to the state that
80
+ it was in before F2FS_IOC_START_ATOMIC_WRITE was called. This occurs
81
+ before the posix advisory lock is automatically dropped - there is
82
+ no chance that another client will be able to read the file in a
83
+ half-committed state before the rollback operation occurs.
84
+
85
+
86
+
87
+
local-test-sqlite3-delta-02/afc-sqlite3/doc/compile-for-unix.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Notes On Compiling SQLite On All Kinds Of Unix
2
+
3
+ Here are step-by-step instructions on how to build SQLite from
4
+ canonical source on any modern machine that isn't Windows. These
5
+ notes are tested (on 2024-10-11) on Ubuntu and on MacOS, but they
6
+ are general and should work on most any modern unix platform.
7
+
8
+ 1. Install a C-compiler. GCC or Clang both work fine. If you are
9
+ reading this document, you've probably already done that.
10
+
11
+ 2. *(Optional):* Install TCL development libraries. In this note,
12
+ we'll do a private install in the $HOME/local directory,
13
+ but you can make adjustments to install TCL wherever you like.
14
+ This document assumes you are working with TCL version 9.0.
15
+ <ol type="a">
16
+ <li>Get the TCL source archive, perhaps from
17
+ <https://www.tcl.tk/software/tcltk/download.html>
18
+ or <https://sqlite.org/tmp/tcl9.0.0.tar.gz>.
19
+ <li>Untar the source archive. CD into the "unix/" subfolder
20
+ of the source tree.
21
+ <li>Run: `mkdir $HOME/local`
22
+ <li>Run: `./configure --prefix=$HOME/local`
23
+ <li>Run: `make install`
24
+ </ol>
25
+ <p>
26
+ As of 2024-10-25, TCL is not longer required for many
27
+ common build targets, such as "sqlite3.c" or the "sqlite3"
28
+ command-line tool. So you can skip this step if that is all
29
+ you want to build. TCL is still required to run "make test"
30
+ and similar, or to build the TCL extension, of course.
31
+
32
+ 4. Download the SQLite source tree and unpack it. CD into the
33
+ toplevel directory of the source tree.
34
+
35
+ 5. Run: `./configure --enable-all --with-tclsh=$HOME/local/bin/tclsh9.0`
36
+
37
+ You do not need to use --with-tclsh if the tclsh you want to use is the
38
+ first one on your PATH or if you are building without TCL.
39
+
40
+ 6. Run the "`Makefile`" makefile with an appropriate target.
41
+ Examples:
42
+ <ul>
43
+ <li> `make sqlite3.c`
44
+ <li> `make sqlite3`
45
+ <li> `make sqldiff`
46
+ <li> `make sqlite3_rsync`
47
+ </ul>
48
+ <p>None of the targets above require TCL. TCL is only needed
49
+ for the following targets:
50
+ <ul>
51
+ <li> `make tclextension-install`
52
+ <li> `make devtest`
53
+ <li> `make releasetest`
54
+ <li> `make sqlite3_analyzer`
55
+ </ul>
56
+
57
+ It is not required that you run the "tclextension-install" target prior to
58
+ running tests. However, the tests will run more smoothly if you do.
59
+ The version of SQLite used for the TCL extension does *not* need to
60
+ correspond to the version of SQLite under test. So you can install the
61
+ SQLite TCL extension once, and then use it to test many different versions
62
+ of SQLite.
63
+
64
+
65
+ 7. For a debugging build of the CLI, where the ".treetrace" and ".wheretrace"
66
+ commands work, add the the --with-debug argument to configure.
local-test-sqlite3-delta-02/afc-sqlite3/doc/compile-for-windows.md ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Notes On Compiling SQLite On Windows 11
2
+
3
+ Here are step-by-step instructions on how to build SQLite from
4
+ canonical source on a new Windows 11 PC, as of 2024-10-09:
5
+
6
+ 1. Install Microsoft Visual Studio. The free "community edition"
7
+ will work fine. Do a standard install for C++ development.
8
+ SQLite only needs the
9
+ "cl" compiler and the "nmake" build tool.
10
+
11
+ 2. Under the "Start" menu, find "All Apps" then go to "Visual Studio 20XX"
12
+ and find "x64 Native Tools Command Prompt for VS 20XX". Pin that
13
+ application to your task bar, as you will use it a lot. Bring up
14
+ an instance of this command prompt and do all of the subsequent steps
15
+ in that "x64 Native Tools" command prompt. (Or use "x86" if you want
16
+ a 32-bit build.) The subsequent steps will not work in a vanilla
17
+ DOS prompt. Nor will they work in PowerShell.
18
+
19
+ 3. *(Optional):* Install TCL development libraries.
20
+ This note assumes that you will
21
+ install the TCL development libraries in the "`c:\Tcl`" directory.
22
+ Make adjustments
23
+ if you want TCL installed somewhere else. SQLite needs both the
24
+ "tclsh90.exe" command-line tool as part of the build process, and
25
+ the "tcl90.lib" and "tclstub.lib" libraries in order to run tests.
26
+ This document assumes you are working with TCL version 9.0.
27
+ See versions of this document from prior to 2024-10-10 for
28
+ instructions on how to build using TCL version 8.6.
29
+ <ol type="a">
30
+ <li>Get the TCL source archive, perhaps from
31
+ <https://www.tcl.tk/software/tcltk/download.html>
32
+ or <https://sqlite.org/tmp/tcl9.0.0.tar.gz>.
33
+ <li>Untar or unzip the source archive. CD into the "win/" subfolder
34
+ of the source tree.
35
+ <li>Run: `nmake /f makefile.vc release`
36
+ <li>Run: `nmake /f makefile.vc INSTALLDIR=c:\Tcl install`
37
+ <li><i>Optional:</i> CD to `c:\Tcl\bin` and make a copy of
38
+ `tclsh90.exe` over into just `tclsh.exe`.
39
+ <li><i>Optional:</i>
40
+ Add `c:\Tcl\bin` to your %PATH%. To do this, go to Settings
41
+ and search for "path". Select "edit environment variables for
42
+ your account" and modify your default PATH accordingly.
43
+ You will need to close and reopen your command prompts after
44
+ making this change.
45
+ </ol>
46
+
47
+ As of 2024-10-25, TCL is not longer required for many
48
+ common build targets, such as "sqlite3.c" or the "sqlite3.exe"
49
+ command-line tool. So you can skip this step if that is all
50
+ you want to build. TCL is still required to run "make test"
51
+ and similar, or to build the TCL extension, of course.
52
+
53
+ 4. Download the SQLite source tree and unpack it. CD into the
54
+ toplevel directory of the source tree.
55
+
56
+ 5. Run the "`Makefile.msc`" makefile with an appropriate target.
57
+ Examples:
58
+ <ul>
59
+ <li> `nmake /f makefile.msc`
60
+ <li> `nmake /f makefile.msc sqlite3.c`
61
+ <li> `nmake /f makefile.msc sqlite3.exe`
62
+ <li> `nmake /f makefile.msc sqldiff.exe`
63
+ <li> `nmake /f makefile.msc sqlite3_rsync.exe`
64
+ </ul>
65
+ <p>No TCL is required for the nmake targets above. But for the ones
66
+ that follow, you will need a TCL installation, as described in step 3
67
+ above. If you install TCL in some directory other than C:\\Tcl, then
68
+ you will also need to add the "TCLDIR=<i>&lt;dir&gt;</i>" option on the
69
+ nmake command line to tell nmake where your TCL is installed.
70
+ <ul>
71
+ <li> `nmake /f makefile.msc tclextension-install`
72
+ <li> `nmake /f makefile.msc devtest`
73
+ <li> `nmake /f makefile.msc releasetest`
74
+ <li> `nmake /f makefile.msc sqlite3_analyzer.exe`
75
+ </ul>
76
+
77
+ It is not required that you run the "tclextension-install" target prior to
78
+ running tests. However, the tests will run more smoothly if you do.
79
+ The version of SQLite used for the TCL extension does *not* need to
80
+ correspond to the version of SQLite under test. So you can install the
81
+ SQLite TCL extension once, and then use it to test many different versions
82
+ of SQLite.
83
+
84
+
85
+ 7. For a debugging build of the CLI, where the ".treetrace" and ".wheretrace"
86
+ commands work, add the DEBUG=3 argument to nmake. Like this:
87
+ <ul>
88
+ <li> `nmake /f makefile.msc DEBUG=3 clean sqlite3.exe`
89
+ </ul>
90
+
91
+
92
+ ## 32-bit Builds
93
+
94
+ Doing a 32-bit build is just like doing a 64-bit build with the
95
+ following minor changes:
96
+
97
+ 1. Use the "x86 Native Tools Command Prompt" instead of
98
+ "x64 Native Tools Command Prompt". "**x86**" instead of "**x64**".
99
+
100
+ 2. Use a different installation directory for TCL.
101
+ The recommended directory is `c:\tcl32`. Thus you end up
102
+ with two TCL builds:
103
+ <ul>
104
+ <li> `c:\tcl` &larr; 64-bit (the default)
105
+ <li> `c:\tcl32` &larr; 32-bit
106
+ </ul>
107
+
108
+ 3. Ensure that `c:\tcl32\bin` comes before `c:\tcl\bin` on
109
+ your PATH environment variable. You can achieve this using
110
+ a command like:
111
+ <ul>
112
+ <li> `set PATH=c:\tcl32\bin;%PATH%`
113
+ </ul>
114
+
115
+ ## Building a DLL
116
+
117
+ The command the developers use for building the deliverable DLL on the
118
+ [download page](https://sqlite.org/download.html) is as follows:
119
+
120
+ > ~~~~
121
+ nmake /f Makefile.msc sqlite3.dll USE_NATIVE_LIBPATHS=1 "OPTS=-DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_SESSION=1 -DSQLITE_ENABLE_PREUPDATE_HOOK=1 -DSQLITE_ENABLE_SERIALIZE=1 -DSQLITE_ENABLE_MATH_FUNCTIONS=1"
122
+ ~~~~
123
+
124
+ That command generates both the sqlite3.dll and sqlite3.def files. The same
125
+ command works for both 32-bit and 64-bit builds.
126
+
127
+ ## Statically Linking The TCL Library
128
+
129
+ Some utility programs associated with SQLite need to be linked
130
+ with TCL in order to function. The [sqlite3_analyzer.exe program](https://sqlite.org/sqlanalyze.html)
131
+ is an example. You can build as described above, and then
132
+ enter:
133
+
134
+ > ~~~~
135
+ nmake /f Makefile.msc sqlite3_analyzer.exe
136
+ ~~~~
137
+
138
+ And you will end up with a working executable. However, that executable
139
+ will depend on having the "tcl98.dll" library somewhere on your %PATH%.
140
+ Use the following steps to build an executable that has the TCL library
141
+ statically linked so that it does not depend on separate DLL:
142
+
143
+ 1. Use the appropriate "Command Prompt" window - either x86 or
144
+ x64, depending on whether you want a 32-bit or 64-bit executable.
145
+
146
+ 2. Untar the TCL source tarball into a fresh directory. CD into
147
+ the "win/" subfolder.
148
+
149
+ 3. Run: `nmake /f makefile.vc OPTS=static shell`
150
+
151
+ 4. CD into the "Release*" subfolder that is created (note the
152
+ wildcard - the full name of the directory might vary). There
153
+ you will find the "tcl90s.lib" file. Copy this file into the
154
+ same directory that you put the "tcl90.lib" on your initial
155
+ installation. (In this document, that directory is
156
+ "`C:\Tcl32\lib`" for 32-bit builds and
157
+ "`C:\Tcl\lib`" for 64-bit builds.)
158
+
159
+ 5. CD into your SQLite source code directory and build the desired
160
+ utility program, but add the following extra argument to the
161
+ nmake command line:
162
+ <blockquote><pre>
163
+ STATICALLY_LINK_TCL=1
164
+ </pre></blockquote>
165
+ <p>So, for example, to build a statically linked version of
166
+ sqlite3_analyzer.exe, you might type:
167
+ <blockquote><pre>
168
+ nmake /f Makefile.msc STATICALLY_LINK_TCL=1 sqlite3_analyzer.exe
169
+ </pre></blockquote>
170
+
171
+ 6. After your executable is built, you can verify that it does not
172
+ depend on the TCL DLL by running:
173
+ <blockquote><pre>
174
+ dumpbin /dependents sqlite3_analyzer.exe
175
+ </pre></blockquote>
local-test-sqlite3-delta-02/afc-sqlite3/doc/json-enhancements.md ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # JSON Functions Enhancements (2022)
2
+
3
+ This document summaries enhancements to the SQLite JSON support added in
4
+ early 2022.
5
+
6
+ ## 1.0 Change summary:
7
+
8
+ 1. New **->** and **->>** operators that work like MySQL and PostgreSQL (PG).
9
+ 2. JSON functions are built-in rather than being an extension. They
10
+ are included by default, but can be omitted using the
11
+ -DSQLITE_OMIT_JSON compile-time option.
12
+
13
+
14
+ ## 2.0 New operators **->** and **->>**
15
+
16
+ The SQLite language adds two new binary operators **->** and **->>**.
17
+ Both operators are similar to json_extract(). The left operand is
18
+ JSON and the right operand is a JSON path expression (possibly abbreviated
19
+ for compatibility with PG - see below). So they are similar to a
20
+ two-argument call to json_extract().
21
+
22
+ The difference between -> and ->> (and json_extract()) is as follows:
23
+
24
+ * The -> operator always returns JSON.
25
+
26
+ * The ->> operator converts the answer into a primitive SQL datatype
27
+ such as TEXT, INTEGER, REAL, or NULL. If a JSON object or array
28
+ is selected, that object or array is rendered as text. If a JSON
29
+ value is selected, that value is converted into its corresponding
30
+ SQL type
31
+
32
+ * The json_extract() interface returns JSON when a JSON object or
33
+ array is selected, or a primitive SQL datatype when a JSON value
34
+ is selected. This is different from MySQL, in which json_extract()
35
+ always returns JSON, but the difference is retained because it has
36
+ worked that way for 6 years and changing it now would likely break
37
+ a lot of legacy code.
38
+
39
+ In MySQL and PG, the ->> operator always returns TEXT (or NULL) and never
40
+ INTEGER or REAL. This is due to limitations in the type handling capabilities
41
+ of those systems. In MySQL and PG, the result type a function or operator
42
+ may only depend on the type of its arguments, never the value of its arguments.
43
+ But the underlying JSON type depends on the value of the JSON path
44
+ expression, not the type of the JSON path expression (which is always TEXT).
45
+ Hence, the result type of ->> in MySQL and PG is unable to vary according
46
+ to the type of the JSON value being extracted.
47
+
48
+ The type system in SQLite is more general. Functions in SQLite are able
49
+ to return different datatypes depending on the value of their arguments.
50
+ So the ->> operator in SQLite is able to return TEXT, INTEGER, REAL, or NULL
51
+ depending on the JSON type of the value being extracted. This means that
52
+ the behavior of the ->> is slightly different in SQLite versus MySQL and PG
53
+ in that it will sometimes return INTEGER and REAL values, depending on its
54
+ inputs. It is possible to implement the ->> operator in SQLite so that it
55
+ always operates exactly like MySQL and PG and always returns TEXT or NULL,
56
+ but I have been unable to think of any situations where returning the
57
+ actual JSON value this would cause problems, so I'm including the enhanced
58
+ functionality in SQLite.
59
+
60
+ The table below attempts to summarize the differences between the
61
+ -> and ->> operators and the json_extract() function, for SQLite, MySQL,
62
+ and PG. JSON values are shown using their SQL text representation but
63
+ in a bold font.
64
+
65
+
66
+ <table border=1 cellpadding=5 cellspacing=0>
67
+ <tr><th>JSON<th>PATH<th>-&gt; operator<br>(all)<th>-&gt;&gt; operator<br>(MySQL/PG)
68
+ <th>-&gt;&gt; operator<br>(SQLite)<th>json_extract()<br>(SQLite)
69
+ <tr><td> **'{"a":123}'** <td>'$.a'<td> **'123'** <td> '123' <td> 123 <td> 123
70
+ <tr><td> **'{"a":4.5}'** <td>'$.a'<td> **'4.5'** <td> '4.5' <td> 4.5 <td> 4.5
71
+ <tr><td> **'{"a":"xyz"}'** <td>'$.a'<td> **'"xyz"'** <td> 'xyz' <td> 'xyz' <td> 'xyz'
72
+ <tr><td> **'{"a":null}'** <td>'$.a'<td> **'null'** <td> NULL <td> NULL <td> NULL
73
+ <tr><td> **'{"a":[6,7,8]}'** <td>'$.a'<td> **'[6,7,8]'** <td> '[6,7,8]' <td> '[6,7,8]' <td> **'[6,7,8]'**
74
+ <tr><td> **'{"a":{"x":9}}'** <td>'$.a'<td> **'{"x":9}'** <td> '{"x":9}' <td> '{"x":9}' <td> **'{"x":9}'**
75
+ <tr><td> **'{"b":999}'** <td>'$.a'<td> NULL <td> NULL <td> NULL <td> NULL
76
+ </table>
77
+
78
+ Important points about the table above:
79
+
80
+ * The -> operator always returns either JSON or NULL.
81
+
82
+ * The ->> operator never returns JSON. It always returns TEXT or NULL, or in the
83
+ case of SQLite, INTEGER or REAL.
84
+
85
+ * The MySQL json_extract() function works exactly the same
86
+ as the MySQL -> operator.
87
+
88
+ * The SQLite json_extract() operator works like -> for JSON objects and
89
+ arrays, and like ->> for JSON values.
90
+
91
+ * The -> operator works the same for all systems.
92
+
93
+ * The only difference in ->> between SQLite and other systems is that
94
+ when the JSON value is numeric, SQLite returns a numeric SQL value,
95
+ whereas the other systems return a text representation of the numeric
96
+ value.
97
+
98
+ ### 2.1 Abbreviated JSON path expressions for PG compatibility
99
+
100
+ The table above always shows the full JSON path expression: '$.a'. But
101
+ PG does not accept this syntax. PG only allows a single JSON object label
102
+ name or a single integer array index. In order to provide compatibility
103
+ with PG, The -> and ->> operators in SQLite are extended to also support
104
+ a JSON object label or an integer array index for the right-hand side
105
+ operand, in addition to a full JSON path expression.
106
+
107
+ Thus, a -> or ->> operator that works on MySQL will work in
108
+ SQLite. And a -> or ->> operator that works in PG will work in SQLite.
109
+ But because SQLite supports the union of the disjoint capabilities of
110
+ MySQL and PG, there will always be -> and ->> operators that work in
111
+ SQLite that do not work in one of MySQL and PG. This is an unavoidable
112
+ consequence of the different syntax for -> and ->> in MySQL and PG.
113
+
114
+ In the following table, assume that "value1" is a JSON object and
115
+ "value2" is a JSON array.
116
+
117
+ <table border=1 cellpadding=5 cellspacing=0>
118
+ <tr><th>SQL expression <th>Works in MySQL?<th>Works in PG?<th>Works in SQLite
119
+ <tr><td>value1-&gt;'$.a' <td> yes <td> no <td> yes
120
+ <tr><td>value1-&gt;'a' <td> no <td> yes <td> yes
121
+ <tr><td>value2-&gt;'$[2]' <td> yes <td> no <td> yes
122
+ <tr><td>value2-&gt;2 <td> no <td> yes <td> yes
123
+ </table>
124
+
125
+ The abbreviated JSON path expressions only work for the -> and ->> operators
126
+ in SQLite. The json_extract() function, and all other built-in SQLite
127
+ JSON functions, continue to require complete JSON path expressions for their
128
+ PATH arguments.
129
+
130
+ ## 3.0 JSON moved into the core
131
+
132
+ The JSON interface is now moved into the SQLite core.
133
+
134
+ When originally written in 2015, the JSON functions were an extension
135
+ that could be optionally included at compile-time, or loaded at run-time.
136
+ The implementation was in a source file named ext/misc/json1.c in the
137
+ source tree. JSON functions were only compiled in if the
138
+ -DSQLITE_ENABLE_JSON1 compile-time option was used.
139
+
140
+ After these enhancements, the JSON functions are now built-ins.
141
+ The source file that implements the JSON functions is moved to src/json.c.
142
+ No special compile-time options are needed to load JSON into the build.
143
+ Instead, there is a new -DSQLITE_OMIT_JSON compile-time option to leave
144
+ them out.
local-test-sqlite3-delta-02/afc-sqlite3/doc/jsonb.md ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # The JSONB Format
2
+
3
+ This document describes SQLite's JSONB binary encoding of
4
+ JSON.
5
+
6
+ ## 1.0 What Is JSONB?
7
+
8
+ Beginning with version 3.45.0 (circa 2024-01-01), SQLite supports an
9
+ alternative binary encoding of JSON which we call "JSONB". JSONB is
10
+ a binary format that stored as a BLOB.
11
+
12
+ The advantage of JSONB over ordinary text RFC 8259 JSON is that JSONB
13
+ is both slightly smaller (by between 5% and 10% in most cases) and
14
+ can be processed in less than half the number of CPU cycles. The built-in
15
+ [JSON SQL functions] of SQLite can accept either ordinary text JSON
16
+ or the binary JSONB encoding for any of their JSON inputs.
17
+
18
+ The "JSONB" name is inspired by [PostgreSQL](https://postgresql.org), but the
19
+ on-disk format for SQLite's JSONB is not the same as PostgreSQL's.
20
+ The two formats have the same name, but they have wildly different internal
21
+ representations and are not in any way binary compatible.
22
+
23
+ The central idea behind this JSONB specification is that each element
24
+ begins with a header that includes the size and type of that element.
25
+ The header takes the place of punctuation such as double-quotes,
26
+ curly-brackes, square-brackets, commas, and colons. Since the size
27
+ and type of each element is contained in its header, the element can
28
+ be read faster since it is no longer necessary to carefully scan forward
29
+ looking for the closing delimiter. The payload of JSONB is the same
30
+ as for corresponding text JSON. The same payload bytes occur in the
31
+ same order. The only real difference between JSONB and ordinary text
32
+ JSON is that JSONB includes a binary header on
33
+ each element and omits delimiter and separator punctuation.
34
+
35
+ ### 1.1 Internal Use Only
36
+
37
+ The details of the JSONB are not intended to be visible to application
38
+ developers. Application developers should look at JSONB as an opaque BLOB
39
+ used internally by SQLite. Nevertheless, we want the format to be backwards
40
+ compatible across all future versions of SQLite. To that end, the format
41
+ is documented by this file in the source tree. But this file should be
42
+ used only by SQLite core developers, not by developers of applications
43
+ that only use SQLite.
44
+
45
+ ## 2.0 The Purpose Of This Document
46
+
47
+ JSONB is not intended as an external format to be used by
48
+ applications. JSONB is designed for internal use by SQLite only.
49
+ Programmers do not need to understand the JSONB format in order to
50
+ use it effectively.
51
+ Applications should access JSONB only through the [JSON SQL functions],
52
+ not by looking at individual bytes of the BLOB.
53
+
54
+ However, JSONB is intended to be portable and backwards compatible
55
+ for all future versions of SQLite. In other words, you should not have
56
+ to export and reimport your SQLite database files when you upgrade to
57
+ a newer SQLite version. For that reason, the JSONB format needs to
58
+ be well-defined.
59
+
60
+ This document is therefore similar in purpose to the
61
+ [SQLite database file format] document that describes the on-disk
62
+ format of an SQLite database file. Applications are not expected
63
+ to directly read and write the bits and bytes of SQLite database files.
64
+ The SQLite database file format is carefully documented so that it
65
+ can be stable and enduring. In the same way, the JSONB representation
66
+ of JSON is documented here so that it too can be stable and enduring,
67
+ not so that applications can read or writes individual bytes.
68
+
69
+ ## 3.0 Encoding
70
+
71
+ JSONB is a direct translation of the underlying text JSON. The difference
72
+ is that JSONB uses a binary encoding that is faster to parse compared to
73
+ the detailed syntax of text JSON.
74
+
75
+ Each JSON element is encoded as a header and a payload. The header
76
+ determines type of element (string, numeric, boolean, null, object, or
77
+ array) and the size of the payload. The header can be between 1 and
78
+ 9 bytes in size. The payload can be any size from zero bytes up to the
79
+ maximum allowed BLOB size.
80
+
81
+ ### 3.1 Payload Size
82
+
83
+ The upper four bits of the first byte of the header determine size of the
84
+ header and possibly also the size of the payload.
85
+ If the upper four bits have a value between 0 and 11, then the header is
86
+ exactly one byte in size and the payload size is determined by those
87
+ upper four bits. If the upper four bits have a value between 12 and 15,
88
+ that means that the total header size is 2, 3, 5, or 9 bytes and the
89
+ payload size is unsigned big-endian integer that is contained in the
90
+ subsequent bytes. The size integer is the one byte that following the
91
+ initial header byte if the upper four bits
92
+ are 12, two bytes if the upper bits are 13, four bytes if the upper bits
93
+ are 14, and eight bytes if the upper bits are 15. The current design
94
+ of SQLite does not support BLOB values larger than 2GiB, so the eight-byte
95
+ variant of the payload size integer will never be used by the current code.
96
+ The eight-byte payload size integer is included in the specification
97
+ to allow for future expansion.
98
+
99
+ The header for an element does *not* need to be in its simplest
100
+ form. For example, consider the JSON numeric value "`1`".
101
+ That element can be encode in five different ways:
102
+
103
+ * `0x13 0x31`
104
+ * `0xc3 0x01 0x31`
105
+ * `0xd3 0x00 0x01 0x31`
106
+ * `0xe3 0x00 0x00 0x00 0x01 0x31`
107
+ * `0xf3 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x31`
108
+
109
+ The shortest encoding is preferred, of course, and usually happens with
110
+ primitive elements such as numbers. However the total size of an array
111
+ or object might not be known exactly when the header of the element is
112
+ first generated. It is convenient to reserve space for the largest
113
+ possible header and then go back and fill in the correct payload size
114
+ at the end. This technique can result in array or object headers that
115
+ are larger than absolutely necessary.
116
+
117
+ ### 3.2 Element Type
118
+
119
+ The least-significant four bits of the first byte of the header (the first
120
+ byte masked against 0x0f) determine element type. The following codes are
121
+ used:
122
+
123
+ <ol>
124
+ <li type="0"><p><b>NULL</b> &rarr;
125
+ The element is a JSON "null". The payload size for a true JSON NULL must
126
+ must be zero. Future versions of SQLite might extend the JSONB format
127
+ with elements that have a zero element type but a non-zero size. In that
128
+ way, legacy versions of SQLite will interpret the element as a NULL
129
+ for backwards compatibility while newer versions will interpret the
130
+ element in some other way.
131
+
132
+ <li value="1"><p><b>TRUE</b> &rarr;
133
+ The element is a JSON "true". The payload size must be zero for a actual
134
+ "true" value. Elements with type 1 and a non-zero payload size are
135
+ reserved for future expansion. Legacy implementations that see an element
136
+ type of 1 with a non-zero payload size should continue to interpret that
137
+ element as "true" for compatibility.
138
+
139
+ <li value="2"><p><b>FALSE</b> &rarr;
140
+ The element is a JSON "false". The payload size must be zero for a actual
141
+ "false" value. Elements with type 2 and a non-zero payload size are
142
+ reserved for future expansion. Legacy implementations that see an element
143
+ type of 2 with a non-zero payload size should continue to interpret that
144
+ element as "false" for compatibility.
145
+
146
+ <li value="3"><p><b>INT</b> &rarr;
147
+ The element is a JSON integer value in the canonical
148
+ RFC 8259 format, without extensions. The payload is the ASCII
149
+ text representation of that numeric value.
150
+
151
+ <li value="4"><p><b>INT5</b> &rarr;
152
+ The element is a JSON integer value that is not in the
153
+ canonical format. The payload is the ASCII
154
+ text representation of that numeric value. Because the payload is in a
155
+ non-standard format, it will need to be translated when the JSONB is
156
+ converted into RFC 8259 text JSON.
157
+
158
+ <li value="5"><p><b>FLOAT</b> &rarr;
159
+ The element is a JSON floating-point value in the canonical
160
+ RFC 8259 format, without extensions. The payload is the ASCII
161
+ text representation of that numeric value.
162
+
163
+ <li value="6"><p><b>FLOAT5</b> &rarr;
164
+ The element is a JSON floating-point value that is not in the
165
+ canonical format. The payload is the ASCII
166
+ text representation of that numeric value. Because the payload is in a
167
+ non-standard format, it will need to be translated when the JSONB is
168
+ converted into RFC 8259 text JSON.
169
+
170
+ <li value="7"><p><b>TEXT</b> &rarr;
171
+ The element is a JSON string value that does not contain
172
+ any escapes nor any characters that need to be escaped for either SQL or
173
+ JSON. The payload is the UTF8 text representation of the string value.
174
+ The payload does <i>not</i> include string delimiters.
175
+
176
+ <li value="8"><p><b>TEXTJ</b> &rarr;
177
+ The element is a JSON string value that contains
178
+ RFC 8259 character escapes (such as "<tt>\n</tt>" or "<tt>\u0020</tt>").
179
+ Those escapes will need to be translated into actual UTF8 if this element
180
+ is [json_extract|extracted] into SQL.
181
+ The payload is the UTF8 text representation of the escaped string value.
182
+ The payload does <i>not</i> include string delimiters.
183
+
184
+ <li value="9"><p><b>TEXT5</b> &rarr;
185
+ The element is a JSON string value that contains
186
+ character escapes, including some character escapes that part of JSON5
187
+ and which are not found in the canonical RFC 8259 spec.
188
+ Those escapes will need to be translated into standard JSON prior to
189
+ rendering the JSON as text, or into their actual UTF8 characters if this
190
+ element is [json_extract|extracted] into SQL.
191
+ The payload is the UTF8 text representation of the escaped string value.
192
+ The payload does <i>not</i> include string delimiters.
193
+
194
+ <li value="10"><p><b>TEXTRAW</b> &rarr;
195
+ The element is a JSON string value that contains
196
+ UTF8 characters that need to be escaped if this string is rendered into
197
+ standard JSON text.
198
+ The payload does <i>not</i> include string delimiters.
199
+
200
+ <li value="11"><p><b>ARRAY</b> &rarr;
201
+ The element is a JSON array. The payload contains
202
+ JSONB elements that comprise values contained within the array.
203
+
204
+ <li value="12"><p><b>OBJECT</b> &rarr;
205
+ The element is a JSON object. The payload contains
206
+ pairs of JSONB elements that comprise entries for the JSON object.
207
+ The first element in each pair must be a string (types 7 through 10).
208
+ The second element of each pair may be any types, including nested
209
+ arrays or objects.
210
+
211
+ <li value="13"><p><b>RESERVED-13</b> &rarr;
212
+ Reserved for future expansion. Legacy implements that encounter this
213
+ element type should raise an error.
214
+
215
+ <li value="14"><p><b>RESERVED-14</b> &rarr;
216
+ Reserved for future expansion. Legacy implements that encounter this
217
+ element type should raise an error.
218
+
219
+ <li value="15"><p><b>RESERVED-15</b> &rarr;
220
+ Reserved for future expansion. Legacy implements that encounter this
221
+ element type should raise an error.
222
+ </ol>
223
+
224
+ Element types outside the range of 0 to 12 are reserved for future
225
+ expansion. The current implement raises an error if see an element type
226
+ other than those listed above. However, future versions of SQLite might
227
+ use of the three remaining element types to implement indexing or similar
228
+ optimizations, to speed up lookup against large JSON arrays and/or objects.
229
+
230
+ ### 3.3 Design Rationale For Element Types
231
+
232
+ A key goal of JSONB is that it should be quick to translate
233
+ to and from text JSON and/or be constructed from SQL values.
234
+ When converting from text into JSONB, we do not want the
235
+ converter subroutine to burn CPU cycles converting elements
236
+ values into some standard format which might never be used.
237
+ Format conversion is "lazy" - it is deferred until actually
238
+ needed. This has implications for the JSONB format design:
239
+
240
+ 1. Numeric values are stored as text, not a numbers. The values are
241
+ a direct copy of the text JSON values from which they are derived.
242
+
243
+ 2. There are multiple element types depending on the details of value
244
+ formats. For example, INT is used for pure RFC-8259 integer
245
+ literals and INT5 exists for JSON5 extensions such as hexadecimal
246
+ notation. FLOAT is used for pure RFC-8259 floating point literals
247
+ and FLOAT5 is used for JSON5 extensions. There are four different
248
+ representations of strings, depending on where the string came from
249
+ and how special characters within the string are escaped.
250
+
251
+ A second goal of JSONB is that it should be capable of serving as the
252
+ "parse tree" for JSON when a JSON value is being processed by the
253
+ various [JSON SQL functions] built into SQLite. Before JSONB was
254
+ developed, operations such [json_replace()] and [json_patch()]
255
+ and similar worked in three stages:
256
+
257
+
258
+ 1. Translate the text JSON into a internal format that is
259
+ easier to scan and edit.
260
+ 2. Perform the requested operation on the JSON.
261
+ 3. Translate the internal format back into text.
262
+
263
+ JSONB seeks to serve as the internal format directly - bypassing
264
+ the first and third stages of that process. Since most of the CPU
265
+ cycles are spent on the first and third stages, that suggests that
266
+ JSONB processing will be much faster than text JSON processing.
267
+
268
+ So when processing JSONB, only the second stage of the three-stage
269
+ process is required. But when processing text JSON, it is still necessary
270
+ to do stages one and three. If JSONB is to be used as the internal
271
+ binary representation, this is yet another reason to store numeric
272
+ values as text. Storing numbers as text minimizes the amount of
273
+ conversion work needed for stages one and three. This is also why
274
+ there are four different representations of text in JSONB. Different
275
+ text representations are used for text coming from different sources
276
+ (RFC-8259 JSON, JSON5, or SQL string values) and conversions only
277
+ happen if and when they are actually needed.
278
+
279
+ ### 3.4 Valid JSONB BLOBs
280
+
281
+ A valid JSONB BLOB consists of a single JSON element. The element must
282
+ exactly fill the BLOB. This one element is often a JSON object or array
283
+ and those usually contain additional elements as its payload, but the
284
+ element can be a primite value such a string, number, boolean, or null.
285
+
286
+ When the built-in JSON functions are attempting to determine if a BLOB
287
+ argument is a JSONB or just a random BLOB, they look at the header of
288
+ the outer element to see that it is well-formed and that the element
289
+ completely fills the BLOB. If these conditions are met, then the BLOB
290
+ is accepted as a JSONB value.
local-test-sqlite3-delta-02/afc-sqlite3/doc/lemon.html ADDED
@@ -0,0 +1,1282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html>
2
+ <head>
3
+ <title>The Lemon Parser Generator</title>
4
+ </head>
5
+ <body>
6
+ <a id="main"></a>
7
+ <h1 align='center'>The Lemon Parser Generator</h1>
8
+
9
+ <p>Lemon is an LALR(1) parser generator for C.
10
+ It does the same job as "bison" and "yacc".
11
+ But Lemon is not a bison or yacc clone. Lemon
12
+ uses a different grammar syntax which is designed to
13
+ reduce the number of coding errors. Lemon also uses a
14
+ parsing engine that is faster than yacc and
15
+ bison and which is both reentrant and threadsafe.
16
+ (Update: Since the previous sentence was written, bison
17
+ has also been updated so that it too can generate a
18
+ reentrant and threadsafe parser.)
19
+ Lemon also implements features that can be used
20
+ to eliminate resource leaks, making it suitable for use
21
+ in long-running programs such as graphical user interfaces
22
+ or embedded controllers.</p>
23
+
24
+ <p>This document is an introduction to the Lemon
25
+ parser generator.</p>
26
+
27
+ <a id="toc"></a>
28
+ <h2>1.0 Table of Contents</h2>
29
+ <ul>
30
+ <li><a href="#main">Introduction</a>
31
+ <li><a href="#toc">1.0 Table of Contents</a>
32
+ <li><a href="#secnot">2.0 Security Notes</a><br>
33
+ <li><a href="#optheory">3.0 Theory of Operation</a>
34
+ <ul>
35
+ <li><a href="#options">3.1 Command Line Options</a>
36
+ <li><a href="#interface">3.2 The Parser Interface</a>
37
+ <ul>
38
+ <li><a href="#onstack">3.2.1 Allocating The Parse Object On Stack</a>
39
+ <li><a href="#ifsum">3.2.2 Interface Summary</a>
40
+ </ul>
41
+ <li><a href="#yaccdiff">3.3 Differences With YACC and BISON</a>
42
+ <li><a href="#build">3.4 Building The "lemon" Or "lemon.exe" Executable</a>
43
+ </ul>
44
+ <li><a href="#syntax">4.0 Input File Syntax</a>
45
+ <ul>
46
+ <li><a href="#tnt">4.1 Terminals and Nonterminals</a>
47
+ <li><a href="#rules">4.2 Grammar Rules</a>
48
+ <li><a href="#precrules">4.3 Precedence Rules</a>
49
+ <li><a href="#special">4.4 Special Directives</a>
50
+ </ul>
51
+ <li><a href="#errors">5.0 Error Processing</a>
52
+ <li><a href="#history">6.0 History of Lemon</a>
53
+ <li><a href="#copyright">7.0 Copyright</a>
54
+ </ul>
55
+
56
+ <a id="secnot"></a>
57
+ <h2>2.0 Security Note</h2>
58
+
59
+ <p>The language parser code created by Lemon is very robust and
60
+ is well-suited for use in internet-facing applications that need to
61
+ safely process maliciously crafted inputs.</p>
62
+
63
+ <p>The "lemon.exe" command-line tool itself works great when given a valid
64
+ input grammar file and almost always gives helpful
65
+ error messages for malformed inputs. However, it is possible for
66
+ a malicious user to craft a grammar file that will cause
67
+ lemon.exe to crash.
68
+ We do not see this as a problem, as lemon.exe is not intended to be used
69
+ with hostile inputs.
70
+ To summarize:</p>
71
+
72
+ <ul>
73
+ <li>Parser code generated by lemon &rarr; Robust and secure
74
+ <li>The "lemon.exe" command line tool itself &rarr; Not so much
75
+ </ul>
76
+
77
+ <a id="optheory"></a>
78
+ <h2>3.0 Theory of Operation</h2>
79
+
80
+ <p>Lemon is computer program that translates a context free grammar (CFG)
81
+ for a particular language into C code that implements a parser for
82
+ that language.
83
+ The Lemon program has two inputs:</p>
84
+ <ul>
85
+ <li>The grammar specification.
86
+ <li>A parser template file.
87
+ </ul>
88
+ <p>Typically, only the grammar specification is supplied by the programmer.
89
+ Lemon comes with a default parser template
90
+ ("<a href="https://sqlite.org/src/file/tool/lempar.c">lempar.c</a>")
91
+ that works fine for most applications. But the user is free to substitute
92
+ a different parser template if desired.</p>
93
+
94
+ <p>Depending on command-line options, Lemon will generate up to
95
+ three output files.</p>
96
+ <ul>
97
+ <li>C code to implement a parser for the input grammar.
98
+ <li>A header file defining an integer ID for each terminal symbol
99
+ (or "token").
100
+ <li>An information file that describes the states of the generated parser
101
+ automaton.
102
+ </ul>
103
+ <p>By default, all three of these output files are generated.
104
+ The header file is suppressed if the "-m" command-line option is
105
+ used and the report file is omitted when "-q" is selected.</p>
106
+
107
+ <p>The grammar specification file uses a ".y" suffix, by convention.
108
+ In the examples used in this document, we'll assume the name of the
109
+ grammar file is "gram.y". A typical use of Lemon would be the
110
+ following command:</p>
111
+ <pre>
112
+ lemon gram.y
113
+ </pre>
114
+ <p>This command will generate three output files named "gram.c",
115
+ "gram.h" and "gram.out".
116
+ The first is C code to implement the parser. The second
117
+ is the header file that defines numerical values for all
118
+ terminal symbols, and the last is the report that explains
119
+ the states used by the parser automaton.</p>
120
+
121
+ <a id="options"></a>
122
+ <h3>3.1 Command Line Options</h3>
123
+
124
+ <p>The behavior of Lemon can be modified using command-line options.
125
+ You can obtain a list of the available command-line options together
126
+ with a brief explanation of what each does by typing</p>
127
+ <pre>
128
+ lemon "-?"
129
+ </pre>
130
+ <p>As of this writing, the following command-line options are supported:</p>
131
+ <ul>
132
+ <li><b>-b</b>
133
+ Show only the basis for each parser state in the report file.
134
+ <li><b>-c</b>
135
+ Do not compress the generated action tables. The parser will be a
136
+ little larger and slower, but it will detect syntax errors sooner.
137
+ <li><b>-d</b><i>directory</i>
138
+ Write all output files into <i>directory</i>. Normally, output files
139
+ are written into the directory that contains the input grammar file.
140
+ <li><b>-D<i>name</i></b>
141
+ Define C preprocessor macro <i>name</i>. This macro is usable by
142
+ "<tt><a href='#pifdef'>%ifdef</a></tt>",
143
+ "<tt><a href='#pifdef'>%ifndef</a></tt>", and
144
+ "<tt><a href="#pifdef">%if</a></tt> lines
145
+ in the grammar file.
146
+ <li><b>-E</b>
147
+ Run the "%if" preprocessor step only and print the revised grammar
148
+ file.
149
+ <li><b>-g</b>
150
+ Do not generate a parser. Instead write the input grammar to standard
151
+ output with all comments, actions, and other extraneous text removed.
152
+ <li><b>-l</b>
153
+ Omit "#line" directives in the generated parser C code.
154
+ <li><b>-m</b>
155
+ Cause the output C source code to be compatible with the "makeheaders"
156
+ program.
157
+ <li><b>-p</b>
158
+ Display all conflicts that are resolved by
159
+ <a href='#precrules'>precedence rules</a>.
160
+ <li><b>-q</b>
161
+ Suppress generation of the report file.
162
+ <li><b>-r</b>
163
+ Do not sort or renumber the parser states as part of optimization.
164
+ <li><b>-s</b>
165
+ Show parser statistics before exiting.
166
+ <li><b>-T<i>file</i></b>
167
+ Use <i>file</i> as the template for the generated C-code parser implementation.
168
+ <li><b>-x</b>
169
+ Print the Lemon version number.
170
+ </ul>
171
+
172
+ <a id="interface"></a>
173
+ <h3>3.2 The Parser Interface</h3>
174
+
175
+ <p>Lemon doesn't generate a complete, working program. It only generates
176
+ a few subroutines that implement a parser. This section describes
177
+ the interface to those subroutines. It is up to the programmer to
178
+ call these subroutines in an appropriate way in order to produce a
179
+ complete system.</p>
180
+
181
+ <p>Before a program begins using a Lemon-generated parser, the program
182
+ must first create the parser.
183
+ A new parser is created as follows:</p>
184
+ <pre>
185
+ void *pParser = ParseAlloc( malloc );
186
+ </pre>
187
+ <p>The ParseAlloc() routine allocates and initializes a new parser and
188
+ returns a pointer to it.
189
+ The actual data structure used to represent a parser is opaque &mdash;
190
+ its internal structure is not visible or usable by the calling routine.
191
+ For this reason, the ParseAlloc() routine returns a pointer to void
192
+ rather than a pointer to some particular structure.
193
+ The sole argument to the ParseAlloc() routine is a pointer to the
194
+ subroutine used to allocate memory. Typically this means malloc().</p>
195
+
196
+ <p>After a program is finished using a parser, it can reclaim all
197
+ memory allocated by that parser by calling</p>
198
+ <pre>
199
+ ParseFree(pParser, free);
200
+ </pre>
201
+ <p>The first argument is the same pointer returned by ParseAlloc(). The
202
+ second argument is a pointer to the function used to release bulk
203
+ memory back to the system.</p>
204
+
205
+ <p>After a parser has been allocated using ParseAlloc(), the programmer
206
+ must supply the parser with a sequence of tokens (terminal symbols) to
207
+ be parsed. This is accomplished by calling the following function
208
+ once for each token:<p>
209
+ <pre>
210
+ Parse(pParser, hTokenID, sTokenData, pArg);
211
+ </pre>
212
+ <p>The first argument to the Parse() routine is the pointer returned by
213
+ ParseAlloc().
214
+ The second argument is a small positive integer that tells the parser the
215
+ type of the next token in the data stream.
216
+ There is one token type for each terminal symbol in the grammar.
217
+ The gram.h file generated by Lemon contains #define statements that
218
+ map symbolic terminal symbol names into appropriate integer values.
219
+ A value of 0 for the second argument is a special flag to the
220
+ parser to indicate that the end of input has been reached.
221
+ The third argument is the value of the given token. By default,
222
+ the type of the third argument is "void*", but the grammar will
223
+ usually redefine this type to be some kind of structure.
224
+ Typically the second argument will be a broad category of tokens
225
+ such as "identifier" or "number" and the third argument will
226
+ be the name of the identifier or the value of the number.</p>
227
+
228
+ <p>The Parse() function may have either three or four arguments,
229
+ depending on the grammar. If the grammar specification file requests
230
+ it (via the <tt><a href='#extraarg'>%extra_argument</a></tt> directive),
231
+ the Parse() function will have a fourth parameter that can be
232
+ of any type chosen by the programmer. The parser doesn't do anything
233
+ with this argument except to pass it through to action routines.
234
+ This is a convenient mechanism for passing state information down
235
+ to the action routines without having to use global variables.</p>
236
+
237
+ <p>A typical use of a Lemon parser might look something like the
238
+ following:</p>
239
+ <pre>
240
+ 1 ParseTree *ParseFile(const char *zFilename){
241
+ 2 Tokenizer *pTokenizer;
242
+ 3 void *pParser;
243
+ 4 Token sToken;
244
+ 5 int hTokenId;
245
+ 6 ParserState sState;
246
+ 7
247
+ 8 pTokenizer = TokenizerCreate(zFilename);
248
+ 9 pParser = ParseAlloc( malloc );
249
+ 10 InitParserState(&amp;sState);
250
+ 11 while( GetNextToken(pTokenizer, &amp;hTokenId, &amp;sToken) ){
251
+ 12 Parse(pParser, hTokenId, sToken, &amp;sState);
252
+ 13 }
253
+ 14 Parse(pParser, 0, sToken, &amp;sState);
254
+ 15 ParseFree(pParser, free );
255
+ 16 TokenizerFree(pTokenizer);
256
+ 17 return sState.treeRoot;
257
+ 18 }
258
+ </pre>
259
+ <p>This example shows a user-written routine that parses a file of
260
+ text and returns a pointer to the parse tree.
261
+ (All error-handling code is omitted from this example to keep it
262
+ simple.)
263
+ We assume the existence of some kind of tokenizer which is created
264
+ using TokenizerCreate() on line 8 and deleted by TokenizerFree()
265
+ on line 16. The GetNextToken() function on line 11 retrieves the
266
+ next token from the input file and puts its type in the
267
+ integer variable hTokenId. The sToken variable is assumed to be
268
+ some kind of structure that contains details about each token,
269
+ such as its complete text, what line it occurs on, etc.</p>
270
+
271
+ <p>This example also assumes the existence of a structure of type
272
+ ParserState that holds state information about a particular parse.
273
+ An instance of such a structure is created on line 6 and initialized
274
+ on line 10. A pointer to this structure is passed into the Parse()
275
+ routine as the optional 4th argument.
276
+ The action routine specified by the grammar for the parser can use
277
+ the ParserState structure to hold whatever information is useful and
278
+ appropriate. In the example, we note that the treeRoot field of
279
+ the ParserState structure is left pointing to the root of the parse
280
+ tree.</p>
281
+
282
+ <p>The core of this example as it relates to Lemon is as follows:</p>
283
+ <pre>
284
+ ParseFile(){
285
+ pParser = ParseAlloc( malloc );
286
+ while( GetNextToken(pTokenizer,&amp;hTokenId, &amp;sToken) ){
287
+ Parse(pParser, hTokenId, sToken);
288
+ }
289
+ Parse(pParser, 0, sToken);
290
+ ParseFree(pParser, free );
291
+ }
292
+ </pre>
293
+ <p>Basically, what a program has to do to use a Lemon-generated parser
294
+ is first create the parser, then send it lots of tokens obtained by
295
+ tokenizing an input source. When the end of input is reached, the
296
+ Parse() routine should be called one last time with a token type
297
+ of 0. This step is necessary to inform the parser that the end of
298
+ input has been reached. Finally, we reclaim memory used by the
299
+ parser by calling ParseFree().</p>
300
+
301
+ <p>There is one other interface routine that should be mentioned
302
+ before we move on.
303
+ The ParseTrace() function can be used to generate debugging output
304
+ from the parser. A prototype for this routine is as follows:</p>
305
+ <pre>
306
+ ParseTrace(FILE *stream, char *zPrefix);
307
+ </pre>
308
+ <p>After this routine is called, a short (one-line) message is written
309
+ to the designated output stream every time the parser changes states
310
+ or calls an action routine. Each such message is prefaced using
311
+ the text given by zPrefix. This debugging output can be turned off
312
+ by calling ParseTrace() again with a first argument of NULL (0).</p>
313
+
314
+ <a id="onstack"></a>
315
+ <h4>3.2.1 Allocating The Parse Object On Stack</h4>
316
+
317
+ <p>If all calls to the Parse() interface are made from within
318
+ <a href="#pcode"><tt>%code</tt> directives</a>, then the parse
319
+ object can be allocated from the stack rather than from the heap.
320
+ These are the steps:
321
+
322
+ <ul>
323
+ <li> Declare a local variable of type "yyParser"
324
+ <li> Initialize the variable using ParseInit()
325
+ <li> Pass a pointer to the variable in calls to Parse()
326
+ <li> Deallocate substructure in the parse variable using ParseFinalize().
327
+ </ul>
328
+
329
+ <p>The following code illustrates how this is done:
330
+
331
+ <pre>
332
+ ParseFile(){
333
+ yyParser x;
334
+ ParseInit( &x );
335
+ while( GetNextToken(pTokenizer,&amp;hTokenId, &amp;sToken) ){
336
+ Parse(&x, hTokenId, sToken);
337
+ }
338
+ Parse(&x, 0, sToken);
339
+ ParseFinalize( &x );
340
+ }
341
+ </pre>
342
+
343
+ <a id="ifsum"></a>
344
+ <h4>3.2.2 Interface Summary</h4>
345
+
346
+ <p>Here is a quick overview of the C-language interface to a
347
+ Lemon-generated parser:</p>
348
+
349
+ <blockquote><pre>
350
+ void *ParseAlloc( (void*(*malloc)(size_t) );
351
+ void ParseFree(void *pParser, (void(*free)(void*) );
352
+ void Parse(void *pParser, int tokenCode, ParseTOKENTYPE token, ...);
353
+ void ParseTrace(FILE *stream, char *zPrefix);
354
+ </pre></blockquote>
355
+
356
+ <p>Notes:</p>
357
+ <ul>
358
+ <li> Use the <a href="#pname"><tt>%name</tt> directive</a> to change
359
+ the "Parse" prefix names of the procedures in the interface.
360
+ <li> Use the <a href="#token_type"><tt>%token_type</tt> directive</a>
361
+ to define the "ParseTOKENTYPE" type.
362
+ <li> Use the <a href="#extraarg"><tt>%extra_argument</tt> directive</a>
363
+ to specify the type and name of the 4th parameter to the
364
+ Parse() function.
365
+ </ul>
366
+
367
+ <a id="yaccdiff"></a>
368
+ <h3>3.3 Differences With YACC and BISON</h3>
369
+
370
+ <p>Programmers who have previously used the yacc or bison parser
371
+ generator will notice several important differences between yacc and/or
372
+ bison and Lemon.</p>
373
+ <ul>
374
+ <li>In yacc and bison, the parser calls the tokenizer. In Lemon,
375
+ the tokenizer calls the parser.
376
+ <li>Lemon uses no global variables. Yacc and bison use global variables
377
+ to pass information between the tokenizer and parser.
378
+ <li>Lemon allows multiple parsers to be running simultaneously. Yacc
379
+ and bison do not.
380
+ </ul>
381
+ <p>These differences may cause some initial confusion for programmers
382
+ with prior yacc and bison experience.
383
+ But after years of experience using Lemon, I firmly
384
+ believe that the Lemon way of doing things is better.</p>
385
+
386
+ <p><i>Updated as of 2016-02-16:</i>
387
+ The text above was written in the 1990s.
388
+ We are told that Bison has lately been enhanced to support the
389
+ tokenizer-calls-parser paradigm used by Lemon, eliminating the
390
+ need for global variables.</p>
391
+
392
+ <a id="build"><a>
393
+ <h3>3.4 Building The "lemon" or "lemon.exe" Executable</h3>
394
+
395
+ <p>The "lemon" or "lemon.exe" program is built from a single file
396
+ of C-code named
397
+ "<a href="https://sqlite.org/src/tool/lemon.c">lemon.c</a>".
398
+ The Lemon source code is generic C89 code that uses
399
+ no unusual or non-standard libraries. Any
400
+ reasonable C compiler should suffice to compile the lemon program.
401
+ A command-line like the following will usually work:</p>
402
+
403
+ <blockquote><pre>
404
+ cc -o lemon lemon.c
405
+ </pre></blockquote
406
+
407
+ <p>On Windows machines with Visual C++ installed, bring up a
408
+ "VS20<i>NN</i> x64 Native Tools Command Prompt" window and enter:
409
+
410
+ <blockquote><pre>
411
+ cl lemon.c
412
+ </pre></blockquote>
413
+
414
+ <p>Compiling Lemon really is that simple.
415
+ Additional compiler options such as
416
+ "-O2" or "-g" or "-Wall" can be added if desired, but they are not
417
+ necessary.</p>
418
+
419
+
420
+ <a id="syntax"></a>
421
+ <h2>4.0 Input File Syntax</h2>
422
+
423
+ <p>The main purpose of the grammar specification file for Lemon is
424
+ to define the grammar for the parser. But the input file also
425
+ specifies additional information Lemon requires to do its job.
426
+ Most of the work in using Lemon is in writing an appropriate
427
+ grammar file.</p>
428
+
429
+ <p>The grammar file for Lemon is, for the most part, a free format.
430
+ It does not have sections or divisions like yacc or bison. Any
431
+ declaration can occur at any point in the file. Lemon ignores
432
+ whitespace (except where it is needed to separate tokens), and it
433
+ honors the same commenting conventions as C and C++.</p>
434
+
435
+ <a id="tnt"></a>
436
+ <h3>4.1 Terminals and Nonterminals</h3>
437
+
438
+ <p>A terminal symbol (token) is any string of alphanumeric
439
+ and/or underscore characters
440
+ that begins with an uppercase letter.
441
+ A terminal can contain lowercase letters after the first character,
442
+ but the usual convention is to make terminals all uppercase.
443
+ A nonterminal, on the other hand, is any string of alphanumeric
444
+ and underscore characters than begins with a lowercase letter.
445
+ Again, the usual convention is to make nonterminals use all lowercase
446
+ letters.</p>
447
+
448
+ <p>In Lemon, terminal and nonterminal symbols do not need to
449
+ be declared or identified in a separate section of the grammar file.
450
+ Lemon is able to generate a list of all terminals and nonterminals
451
+ by examining the grammar rules, and it can always distinguish a
452
+ terminal from a nonterminal by checking the case of the first
453
+ character of the name.</p>
454
+
455
+ <p>Yacc and bison allow terminal symbols to have either alphanumeric
456
+ names or to be individual characters included in single quotes, like
457
+ this: ')' or '$'. Lemon does not allow this alternative form for
458
+ terminal symbols. With Lemon, all symbols, terminals and nonterminals,
459
+ must have alphanumeric names.</p>
460
+
461
+ <a id="rules"></a>
462
+ <h3>4.2 Grammar Rules</h3>
463
+
464
+ <p>The main component of a Lemon grammar file is a sequence of grammar
465
+ rules.
466
+ Each grammar rule consists of a nonterminal symbol followed by
467
+ the special symbol "::=" and then a list of terminals and/or nonterminals.
468
+ The rule is terminated by a period.
469
+ The list of terminals and nonterminals on the right-hand side of the
470
+ rule can be empty.
471
+ Rules can occur in any order, except that the left-hand side of the
472
+ first rule is assumed to be the start symbol for the grammar (unless
473
+ specified otherwise using the <tt><a href='#start_symbol'>%start_symbol</a></tt>
474
+ directive described below.)
475
+ A typical sequence of grammar rules might look something like this:</p>
476
+ <pre>
477
+ expr ::= expr PLUS expr.
478
+ expr ::= expr TIMES expr.
479
+ expr ::= LPAREN expr RPAREN.
480
+ expr ::= VALUE.
481
+ </pre>
482
+
483
+ <p>There is one non-terminal in this example, "expr", and five
484
+ terminal symbols or tokens: "PLUS", "TIMES", "LPAREN",
485
+ "RPAREN" and "VALUE".</p>
486
+
487
+ <p>Like yacc and bison, Lemon allows the grammar to specify a block
488
+ of C code that will be executed whenever a grammar rule is reduced
489
+ by the parser.
490
+ In Lemon, this action is specified by putting the C code (contained
491
+ within curly braces <tt>{...}</tt>) immediately after the
492
+ period that closes the rule.
493
+ For example:</p>
494
+ <pre>
495
+ expr ::= expr PLUS expr. { printf("Doing an addition...\n"); }
496
+ </pre>
497
+
498
+ <p>In order to be useful, grammar actions must normally be linked to
499
+ their associated grammar rules.
500
+ In yacc and bison, this is accomplished by embedding a "$$" in the
501
+ action to stand for the value of the left-hand side of the rule and
502
+ symbols "$1", "$2", and so forth to stand for the value of
503
+ the terminal or nonterminal at position 1, 2 and so forth on the
504
+ right-hand side of the rule.
505
+ This idea is very powerful, but it is also very error-prone. The
506
+ single most common source of errors in a yacc or bison grammar is
507
+ to miscount the number of symbols on the right-hand side of a grammar
508
+ rule and say "$7" when you really mean "$8".</p>
509
+
510
+ <p>Lemon avoids the need to count grammar symbols by assigning symbolic
511
+ names to each symbol in a grammar rule and then using those symbolic
512
+ names in the action.
513
+ In yacc or bison, one would write this:</p>
514
+ <pre>
515
+ expr -&gt; expr PLUS expr { $$ = $1 + $3; };
516
+ </pre>
517
+ <p>But in Lemon, the same rule becomes the following:</p>
518
+ <pre>
519
+ expr(A) ::= expr(B) PLUS expr(C). { A = B+C; }
520
+ </pre>
521
+ <p>In the Lemon rule, any symbol in parentheses after a grammar rule
522
+ symbol becomes a place holder for that symbol in the grammar rule.
523
+ This place holder can then be used in the associated C action to
524
+ stand for the value of that symbol.</p>
525
+
526
+ <p>The Lemon notation for linking a grammar rule with its reduce
527
+ action is superior to yacc/bison on several counts.
528
+ First, as mentioned above, the Lemon method avoids the need to
529
+ count grammar symbols.
530
+ Secondly, if a terminal or nonterminal in a Lemon grammar rule
531
+ includes a linking symbol in parentheses but that linking symbol
532
+ is not actually used in the reduce action, then an error message
533
+ is generated.
534
+ For example, the rule</p>
535
+ <pre>
536
+ expr(A) ::= expr(B) PLUS expr(C). { A = B; }
537
+ </pre>
538
+ <p>will generate an error because the linking symbol "C" is used
539
+ in the grammar rule but not in the reduce action.</p>
540
+
541
+ <p>The Lemon notation for linking grammar rules to reduce actions
542
+ also facilitates the use of destructors for reclaiming memory
543
+ allocated by the values of terminals and nonterminals on the
544
+ right-hand side of a rule.</p>
545
+
546
+ <a id='precrules'></a>
547
+ <h3>4.3 Precedence Rules</h3>
548
+
549
+ <p>Lemon resolves parsing ambiguities in exactly the same way as
550
+ yacc and bison. A shift-reduce conflict is resolved in favor
551
+ of the shift, and a reduce-reduce conflict is resolved by reducing
552
+ whichever rule comes first in the grammar file.</p>
553
+
554
+ <p>Just like in
555
+ yacc and bison, Lemon allows a measure of control
556
+ over the resolution of parsing conflicts using precedence rules.
557
+ A precedence value can be assigned to any terminal symbol
558
+ using the
559
+ <tt><a href='#pleft'>%left</a></tt>,
560
+ <tt><a href='#pright'>%right</a></tt> or
561
+ <tt><a href='#pnonassoc'>%nonassoc</a></tt> directives. Terminal symbols
562
+ mentioned in earlier directives have a lower precedence than
563
+ terminal symbols mentioned in later directives. For example:</p>
564
+
565
+ <pre>
566
+ %left AND.
567
+ %left OR.
568
+ %nonassoc EQ NE GT GE LT LE.
569
+ %left PLUS MINUS.
570
+ %left TIMES DIVIDE MOD.
571
+ %right EXP NOT.
572
+ </pre>
573
+
574
+ <p>In the preceding sequence of directives, the AND operator is
575
+ defined to have the lowest precedence. The OR operator is one
576
+ precedence level higher. And so forth. Hence, the grammar would
577
+ attempt to group the ambiguous expression</p>
578
+ <pre>
579
+ a AND b OR c
580
+ </pre>
581
+ <p>like this</p>
582
+ <pre>
583
+ a AND (b OR c).
584
+ </pre>
585
+ <p>The associativity (left, right or nonassoc) is used to determine
586
+ the grouping when the precedence is the same. AND is left-associative
587
+ in our example, so</p>
588
+ <pre>
589
+ a AND b AND c
590
+ </pre>
591
+ <p>is parsed like this</p>
592
+ <pre>
593
+ (a AND b) AND c.
594
+ </pre>
595
+ <p>The EXP operator is right-associative, though, so</p>
596
+ <pre>
597
+ a EXP b EXP c
598
+ </pre>
599
+ <p>is parsed like this</p>
600
+ <pre>
601
+ a EXP (b EXP c).
602
+ </pre>
603
+ <p>The nonassoc precedence is used for non-associative operators.
604
+ So</p>
605
+ <pre>
606
+ a EQ b EQ c
607
+ </pre>
608
+ <p>is an error.</p>
609
+
610
+ <p>The precedence of non-terminals is transferred to rules as follows:
611
+ The precedence of a grammar rule is equal to the precedence of the
612
+ left-most terminal symbol in the rule for which a precedence is
613
+ defined. This is normally what you want, but in those cases where
614
+ you want the precedence of a grammar rule to be something different,
615
+ you can specify an alternative precedence symbol by putting the
616
+ symbol in square braces after the period at the end of the rule and
617
+ before any C-code. For example:</p>
618
+
619
+ <pre>
620
+ expr = MINUS expr. [NOT]
621
+ </pre>
622
+
623
+ <p>This rule has a precedence equal to that of the NOT symbol, not the
624
+ MINUS symbol as would have been the case by default.</p>
625
+
626
+ <p>With the knowledge of how precedence is assigned to terminal
627
+ symbols and individual
628
+ grammar rules, we can now explain precisely how parsing conflicts
629
+ are resolved in Lemon. Shift-reduce conflicts are resolved
630
+ as follows:</p>
631
+ <ul>
632
+ <li> If either the token to be shifted or the rule to be reduced
633
+ lacks precedence information, then resolve in favor of the
634
+ shift, but report a parsing conflict.
635
+ <li> If the precedence of the token to be shifted is greater than
636
+ the precedence of the rule to reduce, then resolve in favor
637
+ of the shift. No parsing conflict is reported.
638
+ <li> If the precedence of the token to be shifted is less than the
639
+ precedence of the rule to reduce, then resolve in favor of the
640
+ reduce action. No parsing conflict is reported.
641
+ <li> If the precedences are the same and the shift token is
642
+ right-associative, then resolve in favor of the shift.
643
+ No parsing conflict is reported.
644
+ <li> If the precedences are the same and the shift token is
645
+ left-associative, then resolve in favor of the reduce.
646
+ No parsing conflict is reported.
647
+ <li> Otherwise, resolve the conflict by doing the shift, and
648
+ report a parsing conflict.
649
+ </ul>
650
+ <p>Reduce-reduce conflicts are resolved this way:</p>
651
+ <ul>
652
+ <li> If either reduce rule
653
+ lacks precedence information, then resolve in favor of the
654
+ rule that appears first in the grammar, and report a parsing
655
+ conflict.
656
+ <li> If both rules have precedence and the precedence is different,
657
+ then resolve the dispute in favor of the rule with the highest
658
+ precedence, and do not report a conflict.
659
+ <li> Otherwise, resolve the conflict by reducing by the rule that
660
+ appears first in the grammar, and report a parsing conflict.
661
+ </ul>
662
+
663
+ <a id="special"></a>
664
+ <h3>4.4 Special Directives</h3>
665
+
666
+ <p>The input grammar to Lemon consists of grammar rules and special
667
+ directives. We've described all the grammar rules, so now we'll
668
+ talk about the special directives.</p>
669
+
670
+ <p>Directives in Lemon can occur in any order. You can put them before
671
+ the grammar rules, or after the grammar rules, or in the midst of the
672
+ grammar rules. It doesn't matter. The relative order of
673
+ directives used to assign precedence to terminals is important, but
674
+ other than that, the order of directives in Lemon is arbitrary.</p>
675
+
676
+ <p>Lemon supports the following special directives:</p>
677
+ <ul>
678
+ <li><tt><a href='#pcode'>%code</a></tt>
679
+ <li><tt><a href='#default_destructor'>%default_destructor</a></tt>
680
+ <li><tt><a href='#default_type'>%default_type</a></tt>
681
+ <li><tt><a href='#destructor'>%destructor</a></tt>
682
+ <li><tt><a href='#pifdef'>%else</a></tt>
683
+ <li><tt><a href='#pifdef'>%endif</a></tt>
684
+ <li><tt><a href='#extraarg'>%extra_argument</a></tt>
685
+ <li><tt><a href='#pfallback'>%fallback</a></tt>
686
+ <li><tt><a href='#reallc'>%free</a></tt>
687
+ <li><tt><a href='#pifdef'>%if</a></tt>
688
+ <li><tt><a href='#pifdef'>%ifdef</a></tt>
689
+ <li><tt><a href='#pifdef'>%ifndef</a></tt>
690
+ <li><tt><a href='#pinclude'>%include</a></tt>
691
+ <li><tt><a href='#pleft'>%left</a></tt>
692
+ <li><tt><a href='#pname'>%name</a></tt>
693
+ <li><tt><a href='#pnonassoc'>%nonassoc</a></tt>
694
+ <li><tt><a href='#parse_accept'>%parse_accept</a></tt>
695
+ <li><tt><a href='#parse_failure'>%parse_failure</a></tt>
696
+ <li><tt><a href='#pright'>%right</a></tt>
697
+ <li><tt><a href='#reallc'>%realloc</a></tt>
698
+ <li><tt><a href='#stack_overflow'>%stack_overflow</a></tt>
699
+ <li><tt><a href='#stack_size'>%stack_size</a></tt>
700
+ <li><tt><a href='#start_symbol'>%start_symbol</a></tt>
701
+ <li><tt><a href='#syntax_error'>%syntax_error</a></tt>
702
+ <li><tt><a href='#token'>%token</a></tt>
703
+ <li><tt><a href='#token_class'>%token_class</a></tt>
704
+ <li><tt><a href='#token_destructor'>%token_destructor</a></tt>
705
+ <li><tt><a href='#token_prefix'>%token_prefix</a></tt>
706
+ <li><tt><a href='#token_type'>%token_type</a></tt>
707
+ <li><tt><a href='#ptype'>%type</a></tt>
708
+ <li><tt><a href='#pwildcard'>%wildcard</a></tt>
709
+ </ul>
710
+ <p>Each of these directives will be described separately in the
711
+ following sections:</p>
712
+
713
+ <a id='pcode'></a>
714
+ <h4>4.4.1 The <tt>%code</tt> directive</h4>
715
+
716
+ <p>The <tt>%code</tt> directive is used to specify additional C code that
717
+ is added to the end of the main output file. This is similar to
718
+ the <tt><a href='#pinclude'>%include</a></tt> directive except that
719
+ <tt>%include</tt> is inserted at the beginning of the main output file.</p>
720
+
721
+ <p><tt>%code</tt> is typically used to include some action routines or perhaps
722
+ a tokenizer or even the "main()" function
723
+ as part of the output file.</p>
724
+
725
+ <p>There can be multiple <tt>%code</tt> directives. The arguments of
726
+ all <tt>%code</tt> directives are concatenated.</p>
727
+
728
+ <a id='default_destructor'></a>
729
+ <h4>4.4.2 The <tt>%default_destructor</tt> directive</h4>
730
+
731
+ <p>The <tt>%default_destructor</tt> directive specifies a destructor to
732
+ use for non-terminals that do not have their own destructor
733
+ specified by a separate <tt>%destructor</tt> directive. See the documentation
734
+ on the <tt><a href='#destructor'>%destructor</a></tt> directive below for
735
+ additional information.</p>
736
+
737
+ <p>In some grammars, many different non-terminal symbols have the
738
+ same data type and hence the same destructor. This directive is
739
+ a convenient way to specify the same destructor for all those
740
+ non-terminals using a single statement.</p>
741
+
742
+ <a id='default_type'></a>
743
+ <h4>4.4.3 The <tt>%default_type</tt> directive</h4>
744
+
745
+ <p>The <tt>%default_type</tt> directive specifies the data type of non-terminal
746
+ symbols that do not have their own data type defined using a separate
747
+ <tt><a href='#ptype'>%type</a></tt> directive.</p>
748
+
749
+ <a id='destructor'></a>
750
+ <h4>4.4.4 The <tt>%destructor</tt> directive</h4>
751
+
752
+ <p>The <tt>%destructor</tt> directive is used to specify a destructor for
753
+ a non-terminal symbol.
754
+ (See also the <tt><a href='#token_destructor'>%token_destructor</a></tt>
755
+ directive which is used to specify a destructor for terminal symbols.)</p>
756
+
757
+ <p>A non-terminal's destructor is called to dispose of the
758
+ non-terminal's value whenever the non-terminal is popped from
759
+ the stack. This includes all of the following circumstances:</p>
760
+ <ul>
761
+ <li> When a rule reduces and the value of a non-terminal on
762
+ the right-hand side is not linked to C code.
763
+ <li> When the stack is popped during error processing.
764
+ <li> When the ParseFree() function runs.
765
+ </ul>
766
+ <p>The destructor can do whatever it wants with the value of
767
+ the non-terminal, but its design is to deallocate memory
768
+ or other resources held by that non-terminal.</p>
769
+
770
+ <p>Consider an example:</p>
771
+ <pre>
772
+ %type nt {void*}
773
+ %destructor nt { free($$); }
774
+ nt(A) ::= ID NUM. { A = malloc( 100 ); }
775
+ </pre>
776
+ <p>This example is a bit contrived, but it serves to illustrate how
777
+ destructors work. The example shows a non-terminal named
778
+ "nt" that holds values of type "void*". When the rule for
779
+ an "nt" reduces, it sets the value of the non-terminal to
780
+ space obtained from malloc(). Later, when the nt non-terminal
781
+ is popped from the stack, the destructor will fire and call
782
+ free() on this malloced space, thus avoiding a memory leak.
783
+ (Note that the symbol "$$" in the destructor code is replaced
784
+ by the value of the non-terminal.)</p>
785
+
786
+ <p>It is important to note that the value of a non-terminal is passed
787
+ to the destructor whenever the non-terminal is removed from the
788
+ stack, unless the non-terminal is used in a C-code action. If
789
+ the non-terminal is used by C-code, then it is assumed that the
790
+ C-code will take care of destroying it.
791
+ More commonly, the value is used to build some
792
+ larger structure, and we don't want to destroy it, which is why
793
+ the destructor is not called in this circumstance.</p>
794
+
795
+ <p>Destructors help avoid memory leaks by automatically freeing
796
+ allocated objects when they go out of scope.
797
+ To do the same using yacc or bison is much more difficult.</p>
798
+
799
+ <a id='extraarg'></a>
800
+ <h4>4.4.5 The <tt>%extra_argument</tt> directive</h4>
801
+
802
+ <p>The <tt>%extra_argument</tt> directive instructs Lemon to add a 4th parameter
803
+ to the parameter list of the Parse() function it generates. Lemon
804
+ doesn't do anything itself with this extra argument, but it does
805
+ make the argument available to C-code action routines, destructors,
806
+ and so forth. For example, if the grammar file contains:</p>
807
+
808
+ <pre>
809
+ %extra_argument { MyStruct *pAbc }
810
+ </pre>
811
+
812
+ <p>Then the Parse() function generated will have an 4th parameter
813
+ of type "MyStruct*" and all action routines will have access to
814
+ a variable named "pAbc" that is the value of the 4th parameter
815
+ in the most recent call to Parse().</p>
816
+
817
+ <p>The <tt>%extra_context</tt> directive works the same except that it
818
+ is passed in on the ParseAlloc() or ParseInit() routines instead of
819
+ on Parse().</p>
820
+
821
+ <a id='extractx'></a>
822
+ <h4>4.4.6 The <tt>%extra_context</tt> directive</h4>
823
+
824
+ <p>The <tt>%extra_context</tt> directive instructs Lemon to add a 2nd parameter
825
+ to the parameter list of the ParseAlloc() and ParseInit() functions. Lemon
826
+ doesn't do anything itself with these extra argument, but it does
827
+ store the value make it available to C-code action routines, destructors,
828
+ and so forth. For example, if the grammar file contains:</p>
829
+
830
+ <pre>
831
+ %extra_context { MyStruct *pAbc }
832
+ </pre>
833
+
834
+ <p>Then the ParseAlloc() and ParseInit() functions will have an 2nd parameter
835
+ of type "MyStruct*" and all action routines will have access to
836
+ a variable named "pAbc" that is the value of that 2nd parameter.</p>
837
+
838
+ <p>The <tt>%extra_argument</tt> directive works the same except that it
839
+ is passed in on the Parse() routine instead of on ParseAlloc()/ParseInit().</p>
840
+
841
+ <a id='pfallback'></a>
842
+ <h4>4.4.7 The <tt>%fallback</tt> directive</h4>
843
+
844
+ <p>The <tt>%fallback</tt> directive specifies an alternative meaning for one
845
+ or more tokens. The alternative meaning is tried if the original token
846
+ would have generated a syntax error.</p>
847
+
848
+ <p>The <tt>%fallback</tt> directive was added to support robust parsing of SQL
849
+ syntax in <a href='https://www.sqlite.org/'>SQLite</a>.
850
+ The SQL language contains a large assortment of keywords, each of which
851
+ appears as a different token to the language parser. SQL contains so
852
+ many keywords that it can be difficult for programmers to keep up with
853
+ them all. Programmers will, therefore, sometimes mistakenly use an
854
+ obscure language keyword for an identifier. The <tt>%fallback</tt> directive
855
+ provides a mechanism to tell the parser: "If you are unable to parse
856
+ this keyword, try treating it as an identifier instead."</p>
857
+
858
+ <p>The syntax of <tt>%fallback</tt> is as follows:</p>
859
+
860
+ <blockquote>
861
+ <tt>%fallback</tt> <i>ID</i> <i>TOKEN...</i> <b>.</b>
862
+ </blockquote></p>
863
+
864
+ <p>In words, the <tt>%fallback</tt> directive is followed by a list of token
865
+ names terminated by a period.
866
+ The first token name is the fallback token &mdash; the
867
+ token to which all the other tokens fall back to. The second and subsequent
868
+ arguments are tokens which fall back to the token identified by the first
869
+ argument.</p>
870
+
871
+ <a id='pifdef'></a>
872
+ <h4>4.4.8 The <tt>%if</tt> directive and its friends</h4>
873
+
874
+ <p>The <tt>%if</tt>, <tt>%ifdef</tt>, <tt>%ifndef</tt>, <tt>%else</tt>,
875
+ and <tt>%endif</tt> directives
876
+ are similar to #if, #ifdef, #ifndef, #else, and #endif in the C-preprocessor,
877
+ just not as general.
878
+ Each of these directives must begin at the left margin. No whitespace
879
+ is allowed between the "%" and the directive name.</p>
880
+
881
+ <p>Grammar text in between "<tt>%ifdef MACRO</tt>" and the next nested
882
+ "<tt>%endif</tt>" is
883
+ ignored unless the "-DMACRO" command-line option is used. Grammar text
884
+ betwen "<tt>%ifndef MACRO</tt>" and the next nested "<tt>%endif</tt>" is
885
+ included except when the "-DMACRO" command-line option is used.<p>
886
+
887
+ <p>The text in between "<tt>%if</tt> <i>CONDITIONAL</i>" and its
888
+ corresponding <tt>%endif</tt> is included only if <i>CONDITIONAL</i>
889
+ is true. The CONDITION is one or more macro names, optionally connected
890
+ using the "||" and "&amp;&amp;" binary operators, the "!" unary operator,
891
+ and grouped using balanced parentheses. Each term is true if the
892
+ corresponding macro exists, and false if it does not exist.</p>
893
+
894
+ <p>An optional "<tt>%else</tt>" directive can occur anywhere in between a
895
+ <tt>%ifdef</tt>, <tt>%ifndef</tt>, or <tt>%if</tt> directive and
896
+ its corresponding <tt>%endif</tt>.</p>
897
+
898
+ <p>Note that the argument to <tt>%ifdef</tt> and <tt>%ifndef</tt> is
899
+ intended to be a single preprocessor symbol name, not a general expression.
900
+ Use the "<tt>%if</tt>" directive for general expressions.</p>
901
+
902
+ <a id='pinclude'></a>
903
+ <h4>4.4.9 The <tt>%include</tt> directive</h4>
904
+
905
+ <p>The <tt>%include</tt> directive specifies C code that is included at the
906
+ top of the generated parser. You can include any text you want &mdash;
907
+ the Lemon parser generator copies it blindly. If you have multiple
908
+ <tt>%include</tt> directives in your grammar file, their values are concatenated
909
+ so that all <tt>%include</tt> code ultimately appears near the top of the
910
+ generated parser, in the same order as it appeared in the grammar.</p>
911
+
912
+ <p>The <tt>%include</tt> directive is very handy for getting some extra #include
913
+ preprocessor statements at the beginning of the generated parser.
914
+ For example:</p>
915
+
916
+ <pre>
917
+ %include {#include &lt;unistd.h&gt;}
918
+ </pre>
919
+
920
+ <p>This might be needed, for example, if some of the C actions in the
921
+ grammar call functions that are prototyped in unistd.h.</p>
922
+
923
+ <p>Use the <tt><a href="#pcode">%code</a></tt> directive to add code to
924
+ the end of the generated parser.</p>
925
+
926
+ <a id='pleft'></a>
927
+ <h4>4.4.10 The <tt>%left</tt> directive</h4>
928
+
929
+ The <tt>%left</tt> directive is used (along with the
930
+ <tt><a href='#pright'>%right</a></tt> and
931
+ <tt><a href='#pnonassoc'>%nonassoc</a></tt> directives) to declare
932
+ precedences of terminal symbols.
933
+ Every terminal symbol whose name appears after
934
+ a <tt>%left</tt> directive but before the next period (".") is
935
+ given the same left-associative precedence value. Subsequent
936
+ <tt>%left</tt> directives have higher precedence. For example:</p>
937
+
938
+ <pre>
939
+ %left AND.
940
+ %left OR.
941
+ %nonassoc EQ NE GT GE LT LE.
942
+ %left PLUS MINUS.
943
+ %left TIMES DIVIDE MOD.
944
+ %right EXP NOT.
945
+ </pre>
946
+
947
+ <p>Note the period that terminates each <tt>%left</tt>,
948
+ <tt>%right</tt> or <tt>%nonassoc</tt>
949
+ directive.</p>
950
+
951
+ <p>LALR(1) grammars can get into a situation where they require
952
+ a large amount of stack space if you make heavy use or right-associative
953
+ operators. For this reason, it is recommended that you use <tt>%left</tt>
954
+ rather than <tt>%right</tt> whenever possible.</p>
955
+
956
+ <a id='pname'></a>
957
+ <h4>4.4.11 The <tt>%name</tt> directive</h4>
958
+
959
+ <p>By default, the functions generated by Lemon all begin with the
960
+ five-character string "Parse". You can change this string to something
961
+ different using the <tt>%name</tt> directive. For instance:</p>
962
+
963
+ <pre>
964
+ %name Abcde
965
+ </pre>
966
+
967
+ <p>Putting this directive in the grammar file will cause Lemon to generate
968
+ functions named</p>
969
+ <ul>
970
+ <li> AbcdeAlloc(),
971
+ <li> AbcdeFree(),
972
+ <li> AbcdeTrace(), and
973
+ <li> Abcde().
974
+ </ul>
975
+ </p>The <tt>%name</tt> directive allows you to generate two or more different
976
+ parsers and link them all into the same executable.</p>
977
+
978
+ <a id='pnonassoc'></a>
979
+ <h4>4.4.12 The <tt>%nonassoc</tt> directive</h4>
980
+
981
+ <p>This directive is used to assign non-associative precedence to
982
+ one or more terminal symbols. See the section on
983
+ <a href='#precrules'>precedence rules</a>
984
+ or on the <tt><a href='#pleft'>%left</a></tt> directive
985
+ for additional information.</p>
986
+
987
+ <a id='parse_accept'></a>
988
+ <h4>4.4.13 The <tt>%parse_accept</tt> directive</h4>
989
+
990
+ <p>The <tt>%parse_accept</tt> directive specifies a block of C code that is
991
+ executed whenever the parser accepts its input string. To "accept"
992
+ an input string means that the parser was able to process all tokens
993
+ without error.</p>
994
+
995
+ <p>For example:</p>
996
+
997
+ <pre>
998
+ %parse_accept {
999
+ printf("parsing complete!\n");
1000
+ }
1001
+ </pre>
1002
+
1003
+ <a id='parse_failure'></a>
1004
+ <h4>4.4.14 The <tt>%parse_failure</tt> directive</h4>
1005
+
1006
+ <p>The <tt>%parse_failure</tt> directive specifies a block of C code that
1007
+ is executed whenever the parser fails complete. This code is not
1008
+ executed until the parser has tried and failed to resolve an input
1009
+ error using is usual error recovery strategy. The routine is
1010
+ only invoked when parsing is unable to continue.</p>
1011
+
1012
+ <pre>
1013
+ %parse_failure {
1014
+ fprintf(stderr,"Giving up. Parser is hopelessly lost...\n");
1015
+ }
1016
+ </pre>
1017
+
1018
+ <a id='pright'></a>
1019
+ <h4>4.4.15 The <tt>%right</tt> directive</h4>
1020
+
1021
+ <p>This directive is used to assign right-associative precedence to
1022
+ one or more terminal symbols. See the section on
1023
+ <a href='#precrules'>precedence rules</a>
1024
+ or on the <a href='#pleft'>%left</a> directive for additional information.</p>
1025
+
1026
+ <a id='stack_overflow'></a>
1027
+ <h4>4.4.16 The <tt>%stack_overflow</tt> directive</h4>
1028
+
1029
+ <p>The <tt>%stack_overflow</tt> directive specifies a block of C code that
1030
+ is executed if the parser's internal stack ever overflows. Typically
1031
+ this just prints an error message. After a stack overflow, the parser
1032
+ will be unable to continue and must be reset.</p>
1033
+
1034
+ <pre>
1035
+ %stack_overflow {
1036
+ fprintf(stderr,"Giving up. Parser stack overflow\n");
1037
+ }
1038
+ </pre>
1039
+
1040
+ <p>You can help prevent parser stack overflows by avoiding the use
1041
+ of right recursion and right-precedence operators in your grammar.
1042
+ Use left recursion and and left-precedence operators instead to
1043
+ encourage rules to reduce sooner and keep the stack size down.
1044
+ For example, do rules like this:</p>
1045
+ <pre>
1046
+ list ::= list element. // left-recursion. Good!
1047
+ list ::= .
1048
+ </pre>
1049
+ <p>Not like this:</p>
1050
+ <pre>
1051
+ list ::= element list. // right-recursion. Bad!
1052
+ list ::= .
1053
+ </pre>
1054
+
1055
+ <a id='stack_size'></a>
1056
+ <h4>4.4.17 The <tt>%stack_size</tt> directive</h4>
1057
+
1058
+ <p>If stack overflow is a problem and you can't resolve the trouble
1059
+ by using left-recursion, then you might want to increase the size
1060
+ of the parser's stack using this directive. Put an positive integer
1061
+ after the <tt>%stack_size</tt> directive and Lemon will generate a parse
1062
+ with a stack of the requested size. The default value is 100.</p>
1063
+
1064
+ <pre>
1065
+ %stack_size 2000
1066
+ </pre>
1067
+
1068
+ <a id='start_symbol'></a>
1069
+ <h4>4.4.18 The <tt>%start_symbol</tt> directive</h4>
1070
+
1071
+ <p>By default, the start symbol for the grammar that Lemon generates
1072
+ is the first non-terminal that appears in the grammar file. But you
1073
+ can choose a different start symbol using the
1074
+ <tt>%start_symbol</tt> directive.</p>
1075
+
1076
+ <pre>
1077
+ %start_symbol prog
1078
+ </pre>
1079
+
1080
+ <a id='syntax_error'></a>
1081
+ <h4>4.4.19 The <tt>%syntax_error</tt> directive</h4>
1082
+
1083
+ <p>See <a href='#errors'>Error Processing</a>.</p>
1084
+
1085
+ <a id='token'></a>
1086
+ <h4>4.4.20 The <tt>%token</tt> directive</h4>
1087
+
1088
+ <p>Tokens are normally created automatically, the first time they are used.
1089
+ Any identifier that begins with an upper-case letter is a token.
1090
+
1091
+ <p>Sometimes it is useful to declare tokens in advance, however. The
1092
+ integer values assigned to each token determined by the order in which
1093
+ the tokens are seen. So by declaring tokens in advance, it is possible to
1094
+ cause some tokens to have low-numbered values, which might be desirable in
1095
+ some grammers, or to have sequential values assigned to a sequence of
1096
+ related tokens. For this reason, the %token directive is provided to
1097
+ declare tokens in advance. The syntax is as follows:
1098
+
1099
+ <blockquote>
1100
+ <tt>%token</tt> <i>TOKEN</i> <i>TOKEN...</i> <b>.</b>
1101
+ </blockquote></p>
1102
+
1103
+ <p>The %token directive is followed by zero or more token symbols and
1104
+ terminated by a single ".". Each token named is created if it does not
1105
+ already exist. Tokens are created in order.
1106
+
1107
+
1108
+ <a id='token_class'></a>
1109
+ <h4>4.4.21 The <tt>%token_class</tt> directive</h4>
1110
+
1111
+ <p>Undocumented. Appears to be related to the MULTITERMINAL concept.
1112
+ <a href='http://sqlite.org/src/fdiff?v1=796930d5fc2036c7&v2=624b24c5dc048e09&sbs=0'>Implementation</a>.</p>
1113
+
1114
+ <a id='token_destructor'></a>
1115
+ <h4>4.4.22 The <tt>%token_destructor</tt> directive</h4>
1116
+
1117
+ <p>The <tt>%destructor</tt> directive assigns a destructor to a non-terminal
1118
+ symbol. (See the description of the
1119
+ <tt><a href='%destructor'>%destructor</a></tt> directive above.)
1120
+ The <tt>%token_destructor</tt> directive does the same thing
1121
+ for all terminal symbols.</p>
1122
+
1123
+ <p>Unlike non-terminal symbols, which may each have a different data type
1124
+ for their values, terminals all use the same data type (defined by
1125
+ the <tt><a href='#token_type'>%token_type</a></tt> directive)
1126
+ and so they use a common destructor.
1127
+ Other than that, the token destructor works just like the non-terminal
1128
+ destructors.</p>
1129
+
1130
+ <a id='token_prefix'></a>
1131
+ <h4>4.4.23 The <tt>%token_prefix</tt> directive</h4>
1132
+
1133
+ <p>Lemon generates #defines that assign small integer constants
1134
+ to each terminal symbol in the grammar. If desired, Lemon will
1135
+ add a prefix specified by this directive
1136
+ to each of the #defines it generates.</p>
1137
+
1138
+ <p>So if the default output of Lemon looked like this:</p>
1139
+ <pre>
1140
+ #define AND 1
1141
+ #define MINUS 2
1142
+ #define OR 3
1143
+ #define PLUS 4
1144
+ </pre>
1145
+ <p>You can insert a statement into the grammar like this:</p>
1146
+ <pre>
1147
+ %token_prefix TOKEN_
1148
+ </pre>
1149
+ <p>to cause Lemon to produce these symbols instead:</p>
1150
+ <pre>
1151
+ #define TOKEN_AND 1
1152
+ #define TOKEN_MINUS 2
1153
+ #define TOKEN_OR 3
1154
+ #define TOKEN_PLUS 4
1155
+ </pre>
1156
+
1157
+ <a id='token_type'></a><a id='ptype'></a>
1158
+ <h4>4.4.24 The <tt>%token_type</tt> and <tt>%type</tt> directives</h4>
1159
+
1160
+ <p>These directives are used to specify the data types for values
1161
+ on the parser's stack associated with terminal and non-terminal
1162
+ symbols. The values of all terminal symbols must be of the same
1163
+ type. This turns out to be the same data type as the 3rd parameter
1164
+ to the Parse() function generated by Lemon. Typically, you will
1165
+ make the value of a terminal symbol be a pointer to some kind of
1166
+ token structure. Like this:</p>
1167
+
1168
+ <pre>
1169
+ %token_type {Token*}
1170
+ </pre>
1171
+
1172
+ <p>If the data type of terminals is not specified, the default value
1173
+ is "void*".</p>
1174
+
1175
+ <p>Non-terminal symbols can each have their own data types. Typically
1176
+ the data type of a non-terminal is a pointer to the root of a parse tree
1177
+ structure that contains all information about that non-terminal.
1178
+ For example:</p>
1179
+
1180
+ <pre>
1181
+ %type expr {Expr*}
1182
+ </pre>
1183
+
1184
+ <p>Each entry on the parser's stack is actually a union containing
1185
+ instances of all data types for every non-terminal and terminal symbol.
1186
+ Lemon will automatically use the correct element of this union depending
1187
+ on what the corresponding non-terminal or terminal symbol is. But
1188
+ the grammar designer should keep in mind that the size of the union
1189
+ will be the size of its largest element. So if you have a single
1190
+ non-terminal whose data type requires 1K of storage, then your 100
1191
+ entry parser stack will require 100K of heap space. If you are willing
1192
+ and able to pay that price, fine. You just need to know.</p>
1193
+
1194
+ <a id='pwildcard'></a>
1195
+ <h4>4.4.25 The <tt>%wildcard</tt> directive</h4>
1196
+
1197
+ <p>The <tt>%wildcard</tt> directive is followed by a single token name and a
1198
+ period. This directive specifies that the identified token should
1199
+ match any input token.</p>
1200
+
1201
+ <p>When the generated parser has the choice of matching an input against
1202
+ the wildcard token and some other token, the other token is always used.
1203
+ The wildcard token is only matched if there are no alternatives.</p>
1204
+
1205
+ <a id='reallc'></a>
1206
+ <h4>4.4.26 The <tt>%realloc</tt> and <tt>%free</tt> directives</h4>
1207
+
1208
+ <p>The <tt>%realloc</tt> and <tt>%free</tt> directives defines function
1209
+ that allocate and free heap memory. The signatures of these functions
1210
+ should be the same as the realloc() and free() functions from the standard
1211
+ C library.
1212
+
1213
+ <p>If both of these functions are defined
1214
+ then these functions are used to allocate and free
1215
+ memory for supplemental parser stack space, if the initial
1216
+ parse stack space is exceeded. The initial parser stack size
1217
+ is specified by either <tt>%stack_size</tt> or the
1218
+ -DYYSTACKDEPTH compile-time flag.
1219
+
1220
+ <a id='errors'></a>
1221
+ <h2>5.0 Error Processing</h2>
1222
+
1223
+ <p>After extensive experimentation over several years, it has been
1224
+ discovered that the error recovery strategy used by yacc is about
1225
+ as good as it gets. And so that is what Lemon uses.</p>
1226
+
1227
+ <p>When a Lemon-generated parser encounters a syntax error, it
1228
+ first invokes the code specified by the <tt>%syntax_error</tt> directive, if
1229
+ any. It then enters its error recovery strategy. The error recovery
1230
+ strategy is to begin popping the parsers stack until it enters a
1231
+ state where it is permitted to shift a special non-terminal symbol
1232
+ named "error". It then shifts this non-terminal and continues
1233
+ parsing. The <tt>%syntax_error</tt> routine will not be called again
1234
+ until at least three new tokens have been successfully shifted.</p>
1235
+
1236
+ <p>If the parser pops its stack until the stack is empty, and it still
1237
+ is unable to shift the error symbol, then the
1238
+ <tt><a href='#parse_failure'>%parse_failure</a></tt> routine
1239
+ is invoked and the parser resets itself to its start state, ready
1240
+ to begin parsing a new file. This is what will happen at the very
1241
+ first syntax error, of course, if there are no instances of the
1242
+ "error" non-terminal in your grammar.</p>
1243
+
1244
+
1245
+ <a id='history'></a>
1246
+ <h2>6.0 History of Lemon</h2>
1247
+
1248
+ <p>Lemon was originally written by Richard Hipp sometime in the late
1249
+ 1980s on a Sun4 Workstation using K&amp;R C.
1250
+ There was a companion LL(1) parser generator program named "Lime".
1251
+ The Lime source code has been lost.</p>
1252
+
1253
+ <p>The lemon.c source file was originally many separate files that were
1254
+ compiled together to generate the "lemon" executable. Sometime in the
1255
+ 1990s, the individual source code files were combined together into
1256
+ the current single large "lemon.c" source file. You can still see traces
1257
+ of original filenames in the code.</p>
1258
+
1259
+ <p>Since 2001, Lemon has been part of the
1260
+ <a href="https://sqlite.org/">SQLite project</a> and the source code
1261
+ to Lemon has been managed as a part of the
1262
+ <a href="https://sqlite.org/src">SQLite source tree</a> in the following
1263
+ files:</p>
1264
+
1265
+ <ul>
1266
+ <li> <a href="https://sqlite.org/src/file/tool/lemon.c">tool/lemon.c</a>
1267
+ <li> <a href="https://sqlite.org/src/file/tool/lempar.c">tool/lempar.c</a>
1268
+ <li> <a href="https://sqlite.org/src/file/doc/lemon.html">doc/lemon.html</a>
1269
+ </ul>
1270
+
1271
+ <a id="copyright"></a>
1272
+ <h2>7.0 Copyright</h2>
1273
+
1274
+ <p>All of the source code to Lemon, including the template parser file
1275
+ "lempar.c" and this documentation file ("lemon.html") are in the public
1276
+ domain. You can use the code for any purpose and without attribution.</p>
1277
+
1278
+ <p>The code comes with no warranty. If it breaks, you get to keep both
1279
+ pieces.</p>
1280
+
1281
+ </body>
1282
+ </html>
local-test-sqlite3-delta-02/afc-sqlite3/doc/pager-invariants.txt ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *** Throughout this document, a page is deemed to have been synced
2
+ automatically as soon as it is written when PRAGMA synchronous=OFF.
3
+ Otherwise, the page is not synced until the xSync method of the VFS
4
+ is called successfully on the file containing the page.
5
+
6
+ *** Definition: A page of the database file is said to be "overwriteable" if
7
+ one or more of the following are true about the page:
8
+
9
+ (a) The original content of the page as it was at the beginning of
10
+ the transaction has been written into the rollback journal and
11
+ synced.
12
+
13
+ (b) The page was a freelist leaf page at the start of the transaction.
14
+
15
+ (c) The page number is greater than the largest page that existed in
16
+ the database file at the start of the transaction.
17
+
18
+ (1) A page of the database file is never overwritten unless one of the
19
+ following are true:
20
+
21
+ (a) The page and all other pages on the same sector are overwriteable.
22
+
23
+ (b) The atomic page write optimization is enabled, and the entire
24
+ transaction other than the update of the transaction sequence
25
+ number consists of a single page change.
26
+
27
+ (2) The content of a page written into the rollback journal exactly matches
28
+ both the content in the database when the rollback journal was written
29
+ and the content in the database at the beginning of the current
30
+ transaction.
31
+
32
+ (3) Writes to the database file are an integer multiple of the page size
33
+ in length and are aligned to a page boundary.
34
+
35
+ (4) Reads from the database file are either aligned on a page boundary and
36
+ an integer multiple of the page size in length or are taken from the
37
+ first 100 bytes of the database file.
38
+
39
+ (5) All writes to the database file are synced prior to the rollback journal
40
+ being deleted, truncated, or zeroed.
41
+
42
+ (6) If a master journal file is used, then all writes to the database file
43
+ are synced prior to the master journal being deleted.
44
+
45
+ *** Definition: Two databases (or the same database at two points it time)
46
+ are said to be "logically equivalent" if they give the same answer to
47
+ all queries. Note in particular the content of freelist leaf
48
+ pages can be changed arbitarily without effecting the logical equivalence
49
+ of the database.
50
+
51
+ (7) At any time, if any subset, including the empty set and the total set,
52
+ of the unsynced changes to a rollback journal are removed and the
53
+ journal is rolled back, the resulting database file will be logical
54
+ equivalent to the database file at the beginning of the transaction.
55
+
56
+ (8) When a transaction is rolled back, the xTruncate method of the VFS
57
+ is called to restore the database file to the same size it was at
58
+ the beginning of the transaction. (In some VFSes, the xTruncate
59
+ method is a no-op, but that does not change the fact the SQLite will
60
+ invoke it.)
61
+
62
+ (9) Whenever the database file is modified, at least one bit in the range
63
+ of bytes from 24 through 39 inclusive will be changed prior to releasing
64
+ the EXCLUSIVE lock.
65
+
66
+ (10) The pattern of bits in bytes 24 through 39 shall not repeat in less
67
+ than one billion transactions.
68
+
69
+ (11) A database file is well-formed at the beginning and at the conclusion
70
+ of every transaction.
71
+
72
+ (12) An EXCLUSIVE lock must be held on the database file before making
73
+ any changes to the database file.
74
+
75
+ (13) A SHARED lock must be held on the database file before reading any
76
+ content out of the database file.
local-test-sqlite3-delta-02/afc-sqlite3/doc/testrunner.md ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ # The testrunner.tcl Script
4
+
5
+ <ul type=none>
6
+ <li> 1. <a href=#overview>Overview</a>
7
+ <li> 2. <a href=#binary_tests>Binary Tests</a>
8
+ <ul type=none>
9
+ <li> 2.1. <a href=#organization_tests>Organization of Tcl Tests</a>
10
+ <li> 2.2. <a href=#run_tests>Commands to Run Tests</a>
11
+ <li> 2.3. <a href=#binary_test_failures>Investigating Binary Test Failures</a>
12
+ </ul>
13
+ <li> 3. <a href=#source_code_tests>Source Tests</a>
14
+ <ul type=none>
15
+ <li> 3.1. <a href=#commands_to_run_tests>Commands to Run SQLite Tests</a>
16
+ <li> 3.2. <a href=#zipvfs_tests>Running ZipVFS Tests</a>
17
+ <li> 3.3. <a href=#source_code_test_failures>Investigating Source Code Test Failures</a>
18
+ </ul>
19
+ <li> 4. <a href=#testrunner_options>Extra testrunner.tcl Options</a>
20
+ <li> 5. <a href=#cpu_cores>Controlling CPU Core Utilization</a>
21
+ </ul>
22
+
23
+ <a name=overview></a>
24
+ # 1. Overview
25
+
26
+ testrunner.tcl is a Tcl script used to run multiple SQLite tests using
27
+ multiple jobs. It supports the following types of tests:
28
+
29
+ * Tcl test scripts.
30
+
31
+ * Tests run with `make` commands. Examples:
32
+ - `make mdevtest`
33
+ - `make releasetest`
34
+ - `make sdevtest`
35
+ - `make testrunner`
36
+
37
+ testrunner.tcl pipes the output of all tests and builds run into log file
38
+ **testrunner.log**, created in the current working directory. Search this
39
+ file to find details of errors. Suggested search commands:
40
+
41
+ * `grep "^!" testrunner.log`
42
+ * `grep failed testrunner.log`
43
+
44
+ testrunner.tcl also populates SQLite database **testrunner.db**. This database
45
+ contains details of all tests run, running and to be run. A useful query
46
+ might be:
47
+
48
+ ```
49
+ SELECT * FROM script WHERE state='failed'
50
+ ```
51
+
52
+ Running the command:
53
+
54
+ ```
55
+ ./testfixture $(TESTDIR)/testrunner.tcl status
56
+ ```
57
+
58
+ in the directory containing the testrunner.db database runs various queries
59
+ to produce a succinct report on the state of a running testrunner.tcl script.
60
+ Running:
61
+
62
+ ```
63
+ watch ./testfixture $(TESTDIR)/testrunner.tcl status
64
+ ```
65
+
66
+ in another terminal is a good way to keep an eye on a long running test.
67
+
68
+ Sometimes testrunner.tcl uses the `testfixture` binary that it is run with
69
+ to run tests (see "Binary Tests" below). Sometimes it builds testfixture and
70
+ other binaries in specific configurations to test (see "Source Tests").
71
+
72
+ <a name=binary_tests></a>
73
+ # 2. Binary Tests
74
+
75
+ The commands described in this section all run various combinations of the Tcl
76
+ test scripts using the `testfixture` binary used to run the testrunner.tcl
77
+ script (i.e. they do not invoke the compiler to build new binaries, or the
78
+ `make` command to run tests that are not Tcl scripts). The procedure to run
79
+ these tests is therefore:
80
+
81
+ 1. Build the "testfixture" (or "testfixture.exe" for windows) binary using
82
+ whatever method seems convenient.
83
+
84
+ 2. Test the binary built in step 1 by running testrunner.tcl with it,
85
+ perhaps with various options.
86
+
87
+ The following sub-sections describe the various options that can be
88
+ passed to testrunner.tcl to test binary testfixture builds.
89
+
90
+ <a name=organization_tests></a>
91
+ ## 2.1. Organization of Tcl Tests
92
+
93
+ Tcl tests are stored in files that match the pattern *\*.test*. They are
94
+ found in both the $TOP/test/ directory, and in the various sub-directories
95
+ of the $TOP/ext/ directory of the source tree. Not all *\*.test* files
96
+ contain Tcl tests - a handful are Tcl scripts designed to invoke other
97
+ *\*.test* files.
98
+
99
+ The **veryquick** set of tests is a subset of all Tcl test scripts in the
100
+ source tree. In includes most tests, but excludes some that are very slow.
101
+ Almost all fault-injection tests (those that test the response of the library
102
+ to OOM or IO errors) are excluded. It is defined in source file
103
+ *test/permutations.test*.
104
+
105
+ The **full** set of tests includes all Tcl test scripts in the source tree.
106
+ To run a "full" test is to run all Tcl test scripts that can be found in the
107
+ source tree.
108
+
109
+ File *permutations.test* defines various test "permutations". A permutation
110
+ consists of:
111
+
112
+ * A subset of Tcl test scripts, and
113
+
114
+ * Runtime configuration to apply before running each test script
115
+ (e.g. enabling auto-vacuum, or disable lookaside).
116
+
117
+ Running **all** tests is to run all tests in the full test set, plus a dozen
118
+ or so permutations. The specific permutations that are run as part of "all"
119
+ are defined in file *testrunner_data.tcl*.
120
+
121
+ <a name=run_tests></a>
122
+ ## 2.2. Commands to Run Tests
123
+
124
+ To run the "veryquick" test set, use either of the following:
125
+
126
+ ```
127
+ ./testfixture $TESTDIR/testrunner.tcl
128
+ ./testfixture $TESTDIR/testrunner.tcl veryquick
129
+ ```
130
+
131
+ To run the "full" test suite:
132
+
133
+ ```
134
+ ./testfixture $TESTDIR/testrunner.tcl full
135
+ ```
136
+
137
+ To run the subset of the "full" test suite for which the test file name matches
138
+ a specified pattern (e.g. all tests that start with "fts5"), either of:
139
+
140
+ ```
141
+ ./testfixture $TESTDIR/testrunner.tcl fts5%
142
+ ./testfixture $TESTDIR/testrunner.tcl 'fts5*'
143
+ ```
144
+
145
+ Strictly speaking, for a test to be run the pattern must match the script
146
+ filename, not including the directory, using the rules of Tcl's
147
+ \[string match\] command. Except that before the matching is done, any "%"
148
+ characters specified as part of the pattern are transformed to "\*".
149
+
150
+
151
+ To run "all" tests (full + permutations):
152
+
153
+ ```
154
+ ./testfixture $TESTDIR/testrunner.tcl all
155
+ ```
156
+
157
+ <a name=binary_test_failures></a>
158
+ ## 2.3. Investigating Binary Test Failures
159
+
160
+ If a test fails, testrunner.tcl reports name of the Tcl test script and, if
161
+ applicable, the name of the permutation, to stdout. This information can also
162
+ be retrieved from either *testrunner.log* or *testrunner.db*.
163
+
164
+ If there is no permutation, the individual test script may be run with:
165
+
166
+ ```
167
+ ./testfixture $PATH_TO_SCRIPT
168
+ ```
169
+
170
+ Or, if the failure occured as part of a permutation:
171
+
172
+ ```
173
+ ./testfixture $TESTDIR/testrunner.tcl $PERMUTATION $PATH_TO_SCRIPT
174
+ ```
175
+
176
+ TODO: An example instead of "$PERMUTATION" and $PATH\_TO\_SCRIPT?
177
+
178
+ <a name=source_code_tests></a>
179
+ # 3. Source Code Tests
180
+
181
+ The commands described in this section invoke the C compiler to build
182
+ binaries from the source tree, then use those binaries to run Tcl and
183
+ other tests. The advantages of this are that:
184
+
185
+ * it is possible to test multiple build configurations with a single
186
+ command, and
187
+
188
+ * it ensures that tests are always run using binaries created with the
189
+ same set of compiler options.
190
+
191
+ The testrunner.tcl commands described in this section may be run using
192
+ either a *testfixture* (or testfixture.exe) build, or with any other Tcl
193
+ shell that supports SQLite 3.31.1 or newer via "package require sqlite3".
194
+
195
+ TODO: ./configure + Makefile.msc build systems.
196
+
197
+ <a name=commands_to_run_tests></a>
198
+ ## 3.1. Commands to Run SQLite Tests
199
+
200
+ The **mdevtest** command is equivalent to running the veryquick tests and
201
+ the `make fuzztest` target once for each of two --enable-all builds - one
202
+ with debugging enabled and one without:
203
+
204
+ ```
205
+ tclsh $TESTDIR/testrunner.tcl mdevtest
206
+ ```
207
+
208
+ In other words, it is equivalent to running:
209
+
210
+ ```
211
+ $TOP/configure --enable-all --enable-debug
212
+ make fuzztest
213
+ make testfixture
214
+ ./testfixture $TOP/test/testrunner.tcl veryquick
215
+
216
+ # Then, after removing files created by the tests above:
217
+ $TOP/configure --enable-all OPTS="-O0"
218
+ make fuzztest
219
+ make testfixture
220
+ ./testfixture $TOP/test/testrunner.tcl veryquick
221
+ ```
222
+
223
+ The **sdevtest** command is identical to the mdevtest command, except that the
224
+ second of the two builds is a sanitizer build. Specifically, this means that
225
+ OPTS="-fsanitize=address,undefined" is specified instead of OPTS="-O0":
226
+
227
+ ```
228
+ tclsh $TESTDIR/testrunner.tcl sdevtest
229
+ ```
230
+
231
+ The **release** command runs lots of tests under lots of builds. It runs
232
+ different combinations of builds and tests depending on whether it is run
233
+ on Linux, Windows or OSX. Refer to *testrunner\_data.tcl* for the details
234
+ of the specific tests run.
235
+
236
+ ```
237
+ tclsh $TESTDIR/testrunner.tcl release
238
+ ```
239
+
240
+ As with <a href=#source code tests>source code tests</a>, one or more patterns
241
+ may be appended to any of the above commands (mdevtest, sdevtest or release).
242
+ In that case only Tcl tests (no fuzz or other tests) that match the specified
243
+ pattern are run. For example, to run the just the Tcl rtree tests in all
244
+ builds and configurations supported by "release":
245
+
246
+ ```
247
+ tclsh $TESTDIR/testrunner.tcl release rtree%
248
+ ```
249
+
250
+ <a name=zipvfs_tests></a>
251
+ ## 3.2. Running ZipVFS Tests
252
+
253
+ testrunner.tcl can build a zipvfs-enabled testfixture and use it to run
254
+ tests from the Zipvfs project with the following command:
255
+
256
+ ```
257
+ tclsh $TESTDIR/testrunner.tcl --zipvfs $PATH_TO_ZIPVFS
258
+ ```
259
+
260
+ This can be combined with any of "mdevtest", "sdevtest" or "release" to
261
+ test both SQLite and Zipvfs with a single command:
262
+
263
+ ```
264
+ tclsh $TESTDIR/testrunner.tcl --zipvfs $PATH_TO_ZIPVFS mdevtest
265
+ ```
266
+
267
+ <a name=source_code_test_failures></a>
268
+ ## 3.3. Investigating Source Code Test Failures
269
+
270
+ Investigating a test failure that occurs during source code testing is a
271
+ two step process:
272
+
273
+ 1. Recreating the build configuration in which the test failed, and
274
+
275
+ 2. Re-running the actual test.
276
+
277
+ To recreate a build configuration, use the testrunner.tcl **script** command
278
+ to create a build script. A build script is a bash script on Linux or OSX, or
279
+ a dos \*.bat file on windows. For example:
280
+
281
+ ```
282
+ # Create a script that recreates build configuration "Device-One" on
283
+ # Linux or OSX:
284
+ tclsh $TESTDIR/testrunner.tcl script Device-One > make.sh
285
+
286
+ # Create a script that recreates build configuration "Have-Not" on Windows:
287
+ tclsh $TESTDIR/testrunner.tcl script Have-Not > make.bat
288
+ ```
289
+
290
+ The generated bash or \*.bat file script accepts a single argument - a makefile
291
+ target to build. This may be used either to run a `make` command test directly,
292
+ or else to build a testfixture (or testfixture.exe) binary with which to
293
+ run a Tcl test script, as <a href=#binary_test_failures>described above</a>.
294
+
295
+ <a name=testrunner_options></a>
296
+ # 4. Extra testrunner.tcl Options
297
+
298
+ The testrunner.tcl script options in this section may be used with both source
299
+ code and binary tests.
300
+
301
+ The **--buildonly** option instructs testrunner.tcl just to build the binaries
302
+ required by a test, not to run any actual tests. For example:
303
+
304
+ ```
305
+ # Build binaries required by release test.
306
+ tclsh $TESTDIR/testrunner.tcl --buildonly release"
307
+ ```
308
+
309
+ The **--dryrun** option prevents testrunner.tcl from building any binaries
310
+ or running any tests. Instead, it just writes the shell commands that it
311
+ would normally execute into the testrunner.log file. Example:
312
+
313
+ ```
314
+ # Log the shell commmands that make up the mdevtest test.
315
+ tclsh $TESTDIR/testrunner.tcl --dryrun mdevtest"
316
+ ```
317
+
318
+ The **--explain** option is similar to --dryrun in that it prevents testrunner.tcl
319
+ from building any binaries or running any tests. The difference is that --explain
320
+ prints on standard output a human-readable summary of all the builds and tests that
321
+ would have been run.
322
+
323
+ ```
324
+ # Show what builds and tests would have been run
325
+ tclsh $TESTDIR/testrunner.tcl --explain mdevtest
326
+ ```
327
+
328
+ <a name=cpu_cores></a>
329
+ # 5. Controlling CPU Core Utilization
330
+
331
+ When running either binary or source code tests, testrunner.tcl reports the
332
+ number of jobs it intends to use to stdout. e.g.
333
+
334
+ ```
335
+ $ ./testfixture $TESTDIR/testrunner.tcl
336
+ splitting work across 16 jobs
337
+ ... more output ...
338
+ ```
339
+
340
+ By default, testfixture.tcl attempts to set the number of jobs to the number
341
+ of real cores on the machine. This can be overridden using the "--jobs" (or -j)
342
+ switch:
343
+
344
+ ```
345
+ $ ./testfixture $TESTDIR/testrunner.tcl --jobs 8
346
+ splitting work across 8 jobs
347
+ ... more output ...
348
+ ```
349
+
350
+ The number of jobs may also be changed while an instance of testrunner.tcl is
351
+ running by exucuting the following command from the directory containing the
352
+ testrunner.log and testrunner.db files:
353
+
354
+ ```
355
+ $ ./testfixture $TESTDIR/testrunner.tcl njob $NEW_NUMBER_OF_JOBS
356
+ ```
local-test-sqlite3-delta-02/afc-sqlite3/doc/trusted-schema.md ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # The new-security-options branch
2
+
3
+ ## The problem that the [new-security-options](/timeline?r=new-security-options) branch tries to solve
4
+
5
+ An attacker might modify the schema of an SQLite database by adding
6
+ structures that cause code to run when some other application opens and
7
+ reads the database. For example, the attacker might replace a table
8
+ definition with a view. Or the attacker might add triggers to tables
9
+ or views, or add new CHECK constraints or generated columns or indexes
10
+ with expressions in the index list or in the WHERE clause. If the
11
+ added features invoke SQL functions or virtual tables with side effects,
12
+ that might cause harm to the system if run by a high-privilege victim.
13
+ Or, the added features might exfiltrate information if the database is
14
+ read by a high-privilege victim.
15
+
16
+ The changes in this branch strive to make it easier for high-privilege
17
+ applications to safely read SQLite database files that might have been
18
+ maliciously corrupted by an attacker.
19
+
20
+ ## Overview of changes in [new-security-options](/timeline?r=new-security-options)
21
+
22
+ The basic idea is to tag every SQL function and virtual table with one
23
+ of three risk levels:
24
+
25
+ 1. Innocuous
26
+ 2. Normal
27
+ 3. Direct-Only
28
+
29
+ Innocuous functions/vtabs are safe and can be used at any time.
30
+ Direct-only elements, in contrast, might have cause side-effects and
31
+ should only be used from top-level SQL, not from within triggers or views nor
32
+ in elements of the schema such as CHECK constraint, DEFAULT values,
33
+ generated columns, index expressions, or in the WHERE clause of a
34
+ partial index that are potentially under the control of an attacker.
35
+ Normal elements behave like Innocuous if TRUSTED\_SCHEMA=on
36
+ and behave like direct-only if TRUSTED\_SCHEMA=off.
37
+
38
+ Application-defined functions and virtual tables go in as Normal unless
39
+ the application takes deliberate steps to change the risk level.
40
+
41
+ For backwards compatibility, the default is TRUSTED\_SCHEMA=on. Documentation
42
+ will be updated to recommend applications turn TRUSTED\_SCHEMA to off.
43
+
44
+ An innocuous function or virtual table is one that can only read content
45
+ from the database file in which it resides, and can only alter the database
46
+ in which it resides. Most SQL functions are innocuous. For example, there
47
+ is no harm in an attacker running the abs() function.
48
+
49
+ Direct-only elements that have side-effects that go outside the database file
50
+ in which it lives, or return information from outside of the database file.
51
+ Examples of direct-only elements include:
52
+
53
+ 1. The fts3\_tokenizer() function
54
+ 2. The writefile() function
55
+ 3. The readfile() function
56
+ 4. The zipvfs virtual table
57
+ 5. The csv virtual table
58
+
59
+ We do not want an attacker to be able to add these kinds of things to
60
+ the database schema and possibly trick a high-privilege application
61
+ from performing any of these actions. Therefore, functions and vtabs
62
+ with side-effects are marked as Direct-Only.
63
+
64
+ Legacy applications might add other risky functions or vtabs. Those will
65
+ go in as "Normal" by default. For optimal security, we want those risky
66
+ app-defined functions and vtabs to be direct-only, but making that the
67
+ default might break some legacy applications. Hence, all app-defined
68
+ functions and vtabs go in as Normal, but the application can switch them
69
+ over to "Direct-Only" behavior using a single pragma.
70
+
71
+ The restrictions on the use of functions and virtual tables do not apply
72
+ to TEMP. A TEMP VIEW or a TEMP TRIGGER can use any valid SQL function
73
+ or virtual table. The idea is that TEMP views and triggers must be
74
+ directly created by the application and are thus under the control of the
75
+ application. TEMP views and triggers cannot be created by an attacker who
76
+ corrupts the schema of a persistent database file. Hence TEMP views and
77
+ triggers are safe.
78
+
79
+ ## Specific changes
80
+
81
+ 1. New sqlite3\_db\_config() option SQLITE\_DBCONFIG\_TRUSTED\_SCHEMA for
82
+ turning TRUSTED\_SCHEMA on and off. It defaults to ON.
83
+
84
+ 2. Compile-time option -DSQLITE\_TRUSTED\_SCHEMA=0 causes the default
85
+ TRUSTED\_SCHEMA setting to be off.
86
+
87
+ 3. New pragma "PRAGMA trusted\_schema=(ON\|OFF);". This provides access
88
+ to the TRUSTED_SCHEMA setting for application coded using scripting
89
+ languages or other secondary languages where they are unable to make
90
+ calls to sqlite3\_db\_config().
91
+
92
+ 4. New options for the "enc" parameter to sqlite3\_create\_function() and
93
+ its kin:
94
+ <ol type="a">
95
+ <li> _SQLITE\_INNOCUOUS_ &rarr; tags the new functions as Innocuous
96
+ <li> _SQLITE\_DIRECTONLY_ &rarr; tags the new functions as Direct-Only
97
+ </ol>
98
+
99
+ 5. New options to sqlite3\_vtab\_config():
100
+ <ol type="a">
101
+ <li> _SQLITE\_VTAB\_INNOCUOUS_ &rarr; tags the vtab as Innocuous
102
+ <li> _SQLITE\_VTAB\_DIRECTONLY_ &rarr; tags the vtab as Direct-Only
103
+ </ol>
104
+
105
+ 6. Change many of the functions and virtual tables in the SQLite source
106
+ tree to use one of the tags above.
107
+
108
+ 7. Enhanced PRAGMA function\_list and virtual-table "pragma\_function\_list"
109
+ with additional columns. The columns now are:
110
+ <ul>
111
+ <li> _name_ &rarr; Name of the function
112
+ <li> _builtin_ &rarr; 1 for built-in functions. 0 otherwise.
113
+ <li> _type_ &rarr; 's'=Scalar, 'a'=Aggregate, 'w'=Window
114
+ <li> _enc_ &rarr; 'utf8', 'utf16le', or 'utf16be'
115
+ <li> _narg_ &rarr; number of argument
116
+ <li> _flags_ &rarr; Bitmask of SQLITE\_INNOCUOUS, SQLITE\_DIRECTONLY,
117
+ SQLITE\_DETERMINISTIC, SQLITE\_SUBTYPE, and
118
+ SQLITE\_FUNC\_INTERNAL flags.
119
+ </ul>
120
+ <p>The last four columns are new.
121
+
122
+ 8. The function\_list PRAGMA now also shows all entries for each function.
123
+ So, for example, if a function can take either 2 or 3 arguments,
124
+ there are separate rows for the 2-argument and 3-argument versions of
125
+ the function.
126
+
127
+ ## Additional Notes
128
+
129
+ The function_list enhancements allow the application to query the set
130
+ of SQL functions that meet various criteria. For example, to see all
131
+ SQL functions that are never allowed to be used in the schema or in
132
+ trigger or views:
133
+
134
+ ~~~
135
+ SELECT DISTINCT name FROM pragma_function_list
136
+ WHERE (flags & 0x80000)!=0
137
+ ORDER BY name;
138
+ ~~~
139
+
140
+ Doing the same is not possible for virtual tables, as a virtual table
141
+ might be Innocuous, Normal, or Direct-Only depending on the arguments
142
+ passed into the xConnect method.
local-test-sqlite3-delta-02/afc-sqlite3/doc/vdbesort-memory.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ 20-11-2020
3
+
4
+ # Memory Allocation In vdbesort.c
5
+
6
+ Memory allocation is slightly different depending on:
7
+
8
+ * whether or not SQLITE_CONFIG_SMALL_MALLOC is set, and
9
+ * whether or not worker threads are enabled.
10
+
11
+ ## SQLITE_CONFIG_SMALL_MALLOC=0
12
+
13
+ Assuming SQLITE_CONFIG_SMALL_MALLOC is not set, keys passed to the sorter are
14
+ added to an in-memory buffer. This buffer is grown using sqlite3Realloc() as
15
+ required it reaches the size configured for the main pager cache using "PRAGMA
16
+ cache_size". i.e. if the user has executed "PRAGMA main.cache_size = -2048",
17
+ then this buffer is allowed to grow up to 2MB in size.
18
+
19
+ Once the buffer has grown to its threshold, keys are sorted and written to
20
+ a temp file. If worker threads are not enabled, this is the only significant
21
+ allocation the sorter module makes. After keys are sorted and flushed out to
22
+ the temp file, the buffer is reused to accumulate the next batch of keys.
23
+
24
+ If worker threads are available, then the buffer is passed to a worker thread
25
+ to sort and flush once it is full, and a new buffer allocated to allow the
26
+ main thread to continue to accumulate keys. Buffers are reused once they
27
+ have been flushed, so in this case at most (nWorker+1) buffers are allocated
28
+ and used, where nWorker is the number of configured worker threads.
29
+
30
+ There are no other significant users of heap memory in the sorter module.
31
+ Once sorted buffers of keys have been flushed to disk, they are read back
32
+ either by mapping the file (via sqlite3_file.xFetch()) or else read back
33
+ in one page at a time.
34
+
35
+ All buffers are allocated by the main thread. A sorter object is associated
36
+ with a single database connection, to which it holds a pointer.
37
+
38
+ ## SQLITE_CONFIG_SMALL_MALLOC=1
39
+
40
+ This case is similar to the above, except that instead of accumulating
41
+ multiple keys in a single large buffer, sqlite3VdbeSorterWrite() stores
42
+ keys in a regular heap-memory linked list (one allocation per element).
43
+ List elements are freed as they are flushed to disk, either by the main
44
+ thread or by a worker thread.
45
+
46
+ Each time a key is added the sorter (and an allocation made),
47
+ sqlite3HeapNearlyFull() is called. If it returns true, the current
48
+ list of keys is flushed to a temporary file, even if it has not yet
49
+ reached the size threshold.