Fossil

Hex Artifact Content
Login

Artifact f219f8ecfe85c31446238b0468d241d2d87cf851222dd58fe84d9380e37f9ba5:


0000: 23 20 53 79 73 74 65 6d 20 61 75 74 6f 63 6f 6e  # System autocon
0010: 66 69 67 75 72 61 74 69 6f 6e 2e 20 54 72 79 3a  figuration. Try:
0020: 20 2e 2f 63 6f 6e 66 69 67 75 72 65 20 2d 2d 68   ./configure --h
0030: 65 6c 70 0a 0a 23 20 54 68 69 73 20 6d 75 73 74  elp..# This must
0040: 20 62 65 20 61 62 6f 76 65 20 22 6f 70 74 69 6f   be above "optio
0050: 6e 73 22 20 62 65 6c 6f 77 20 62 65 63 61 75 73  ns" below becaus
0060: 65 20 69 74 20 69 6d 70 6c 69 63 69 74 6c 79 20  e it implicitly 
0070: 62 72 69 6e 67 73 20 69 6e 20 74 68 65 0a 23 20  brings in the.# 
0080: 64 65 66 61 75 6c 74 20 41 75 74 6f 73 65 74 75  default Autosetu
0090: 70 20 6f 70 74 69 6f 6e 73 2c 20 74 68 69 6e 67  p options, thing
00a0: 73 20 6c 69 6b 65 20 2d 2d 70 72 65 66 69 78 2e  s like --prefix.
00b0: 0a 75 73 65 20 63 63 20 63 63 2d 6c 69 62 0a 0a  .use cc cc-lib..
00c0: 6f 70 74 69 6f 6e 73 20 7b 0a 20 20 20 20 77 69  options {.    wi
00d0: 74 68 2d 6f 70 65 6e 73 73 6c 3a 70 61 74 68 7c  th-openssl:path|
00e0: 61 75 74 6f 7c 74 72 65 65 7c 6e 6f 6e 65 0a 20  auto|tree|none. 
00f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0100: 20 20 20 20 20 20 20 20 3d 3e 20 7b 4c 6f 6f 6b          => {Look
0110: 20 66 6f 72 20 4f 70 65 6e 53 53 4c 20 69 6e 20   for OpenSSL in 
0120: 74 68 65 20 67 69 76 65 6e 20 70 61 74 68 2c 20  the given path, 
0130: 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 2c 20 69  automatically, i
0140: 6e 20 74 68 65 20 73 6f 75 72 63 65 20 74 72 65  n the source tre
0150: 65 2c 20 6f 72 20 6e 6f 6e 65 7d 0a 20 20 20 20  e, or none}.    
0160: 77 69 74 68 2d 7a 6c 69 62 3a 70 61 74 68 7c 61  with-zlib:path|a
0170: 75 74 6f 7c 74 72 65 65 0a 20 20 20 20 20 20 20  uto|tree.       
0180: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0190: 20 20 3d 3e 20 7b 4c 6f 6f 6b 20 66 6f 72 20 7a    => {Look for z
01a0: 6c 69 62 20 69 6e 20 74 68 65 20 67 69 76 65 6e  lib in the given
01b0: 20 70 61 74 68 2c 20 61 75 74 6f 6d 61 74 69 63   path, automatic
01c0: 61 6c 6c 79 2c 20 6f 72 20 69 6e 20 74 68 65 20  ally, or in the 
01d0: 73 6f 75 72 63 65 20 74 72 65 65 7d 0a 20 20 20  source tree}.   
01e0: 20 77 69 74 68 2d 73 71 6c 69 74 65 3a 70 61 74   with-sqlite:pat
01f0: 68 7c 61 75 74 6f 7c 74 72 65 65 0a 20 20 20 20  h|auto|tree.    
0200: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0210: 20 20 20 20 20 3d 3e 20 7b 4c 6f 6f 6b 20 66 6f       => {Look fo
0220: 72 20 73 71 6c 69 74 65 20 69 6e 20 74 68 65 20  r sqlite in the 
0230: 67 69 76 65 6e 20 70 61 74 68 2c 20 61 75 74 6f  given path, auto
0240: 6d 61 74 69 63 61 6c 6c 79 2c 20 6f 72 20 69 6e  matically, or in
0250: 20 74 68 65 20 73 6f 75 72 63 65 20 74 72 65 65   the source tree
0260: 2e 7d 0a 20 20 20 20 77 69 74 68 2d 65 78 65 63  .}.    with-exec
0270: 2d 72 65 6c 2d 70 61 74 68 73 3d 30 0a 20 20 20  -rel-paths=0.   
0280: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0290: 20 20 20 20 20 20 3d 3e 20 7b 45 6e 61 62 6c 65        => {Enable
02a0: 20 72 65 6c 61 74 69 76 65 20 70 61 74 68 73 20   relative paths 
02b0: 66 6f 72 20 65 78 74 65 72 6e 61 6c 20 64 69 66  for external dif
02c0: 66 2f 67 64 69 66 66 7d 0a 20 20 20 20 77 69 74  f/gdiff}.    wit
02d0: 68 2d 73 61 6e 69 74 69 7a 65 72 3a 20 20 20 20  h-sanitizer:    
02e0: 20 20 3d 3e 20 7b 42 75 69 6c 64 20 77 69 74 68    => {Build with
02f0: 20 43 20 63 6f 6d 70 69 6c 65 72 27 73 20 2d 66   C compiler's -f
0300: 73 61 6e 69 74 69 7a 65 3d 4c 49 53 54 3b 20 65  sanitize=LIST; e
0310: 2e 67 2e 20 61 64 64 72 65 73 73 2c 65 6e 75 6d  .g. address,enum
0320: 2c 6e 75 6c 6c 2c 75 6e 64 65 66 69 6e 65 64 7d  ,null,undefined}
0330: 0a 20 20 20 20 77 69 74 68 2d 74 68 31 2d 64 6f  .    with-th1-do
0340: 63 73 3d 30 20 20 20 20 20 20 3d 3e 20 7b 45 6e  cs=0      => {En
0350: 61 62 6c 65 20 54 48 31 20 66 6f 72 20 65 6d 62  able TH1 for emb
0360: 65 64 64 65 64 20 64 6f 63 75 6d 65 6e 74 61 74  edded documentat
0370: 69 6f 6e 20 70 61 67 65 73 7d 0a 20 20 20 20 77  ion pages}.    w
0380: 69 74 68 2d 74 68 31 2d 68 6f 6f 6b 73 3d 30 20  ith-th1-hooks=0 
0390: 20 20 20 20 3d 3e 20 7b 45 6e 61 62 6c 65 20 54      => {Enable T
03a0: 48 31 20 68 6f 6f 6b 73 20 66 6f 72 20 63 6f 6d  H1 hooks for com
03b0: 6d 61 6e 64 73 20 61 6e 64 20 77 65 62 20 70 61  mands and web pa
03c0: 67 65 73 7d 0a 20 20 20 20 77 69 74 68 2d 74 63  ges}.    with-tc
03d0: 6c 3a 70 61 74 68 20 20 20 20 20 20 20 20 3d 3e  l:path        =>
03e0: 20 7b 45 6e 61 62 6c 65 20 54 63 6c 20 69 6e 74   {Enable Tcl int
03f0: 65 67 72 61 74 69 6f 6e 2c 20 77 69 74 68 20 54  egration, with T
0400: 63 6c 20 69 6e 20 74 68 65 20 73 70 65 63 69 66  cl in the specif
0410: 69 65 64 20 70 61 74 68 7d 0a 20 20 20 20 77 69  ied path}.    wi
0420: 74 68 2d 74 63 6c 2d 73 74 75 62 73 3d 30 20 20  th-tcl-stubs=0  
0430: 20 20 20 3d 3e 20 7b 45 6e 61 62 6c 65 20 54 63     => {Enable Tc
0440: 6c 20 69 6e 74 65 67 72 61 74 69 6f 6e 20 76 69  l integration vi
0450: 61 20 73 74 75 62 73 20 6c 69 62 72 61 72 79 20  a stubs library 
0460: 6d 65 63 68 61 6e 69 73 6d 7d 0a 20 20 20 20 77  mechanism}.    w
0470: 69 74 68 2d 74 63 6c 2d 70 72 69 76 61 74 65 2d  ith-tcl-private-
0480: 73 74 75 62 73 3d 30 0a 20 20 20 20 20 20 20 20  stubs=0.        
0490: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
04a0: 20 3d 3e 20 7b 45 6e 61 62 6c 65 20 54 63 6c 20   => {Enable Tcl 
04b0: 69 6e 74 65 67 72 61 74 69 6f 6e 20 76 69 61 20  integration via 
04c0: 70 72 69 76 61 74 65 20 73 74 75 62 73 20 6d 65  private stubs me
04d0: 63 68 61 6e 69 73 6d 7d 0a 20 20 20 20 77 69 74  chanism}.    wit
04e0: 68 2d 6d 6d 61 6e 3d 30 20 20 20 20 20 20 20 20  h-mman=0        
04f0: 20 20 3d 3e 20 7b 45 6e 61 62 6c 65 20 75 73 65    => {Enable use
0500: 20 6f 66 20 50 4f 53 49 58 20 6d 65 6d 6f 72 79   of POSIX memory
0510: 20 41 50 49 73 20 66 72 6f 6d 20 22 73 79 73 2f   APIs from "sys/
0520: 6d 6d 61 6e 2e 68 22 7d 0a 20 20 20 20 77 69 74  mman.h"}.    wit
0530: 68 2d 73 65 65 3d 30 20 20 20 20 20 20 20 20 20  h-see=0         
0540: 20 20 3d 3e 20 7b 45 6e 61 62 6c 65 20 74 68 65    => {Enable the
0550: 20 53 51 4c 69 74 65 20 45 6e 63 72 79 70 74 69   SQLite Encrypti
0560: 6f 6e 20 45 78 74 65 6e 73 69 6f 6e 20 28 53 45  on Extension (SE
0570: 45 29 7d 0a 20 20 20 20 70 72 69 6e 74 2d 6d 69  E)}.    print-mi
0580: 6e 69 6d 75 6d 2d 73 71 6c 69 74 65 2d 76 65 72  nimum-sqlite-ver
0590: 73 69 6f 6e 3d 30 0a 20 20 20 20 20 20 20 20 20  sion=0.         
05a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
05b0: 3d 3e 20 7b 70 72 69 6e 74 20 74 68 65 20 6d 69  => {print the mi
05c0: 6e 69 6d 75 6d 20 53 51 4c 69 74 65 20 76 65 72  nimum SQLite ver
05d0: 73 69 6f 6e 20 6e 75 6d 62 65 72 20 72 65 71 75  sion number requ
05e0: 69 72 65 64 2c 20 61 6e 64 20 65 78 69 74 7d 0a  ired, and exit}.
05f0: 20 20 20 20 69 6e 74 65 72 6e 61 6c 2d 73 71 6c      internal-sql
0600: 69 74 65 3d 31 20 20 20 20 3d 3e 20 7b 44 6f 6e  ite=1    => {Don
0610: 27 74 20 75 73 65 20 74 68 65 20 69 6e 74 65 72  't use the inter
0620: 6e 61 6c 20 53 51 4c 69 74 65 2c 20 75 73 65 20  nal SQLite, use 
0630: 74 68 65 20 73 79 73 74 65 6d 20 6f 6e 65 7d 0a  the system one}.
0640: 20 20 20 20 73 74 61 74 69 63 3d 30 20 20 20 20      static=0    
0650: 20 20 20 20 20 20 20 20 20 3d 3e 20 7b 4c 69 6e           => {Lin
0660: 6b 20 61 20 73 74 61 74 69 63 20 65 78 65 63 75  k a static execu
0670: 74 61 62 6c 65 7d 0a 20 20 20 20 66 75 73 65 66  table}.    fusef
0680: 73 3d 31 20 20 20 20 20 20 20 20 20 20 20 20 20  s=1             
0690: 3d 3e 20 7b 44 69 73 61 62 6c 65 20 74 68 65 20  => {Disable the 
06a0: 46 75 73 65 20 46 69 6c 65 73 79 73 74 65 6d 7d  Fuse Filesystem}
06b0: 0a 20 20 20 20 66 6f 73 73 69 6c 2d 64 65 62 75  .    fossil-debu
06c0: 67 3d 30 20 20 20 20 20 20 20 3d 3e 20 7b 42 75  g=0       => {Bu
06d0: 69 6c 64 20 77 69 74 68 20 66 6f 73 73 69 6c 20  ild with fossil 
06e0: 64 65 62 75 67 67 69 6e 67 20 65 6e 61 62 6c 65  debugging enable
06f0: 64 7d 0a 20 20 20 20 6e 6f 2d 6f 70 74 3d 30 20  d}.    no-opt=0 
0700: 20 20 20 20 20 20 20 20 20 20 20 20 3d 3e 20 7b              => {
0710: 42 75 69 6c 64 20 77 69 74 68 6f 75 74 20 6f 70  Build without op
0720: 74 69 6d 69 7a 61 74 69 6f 6e 7d 0a 20 20 20 20  timization}.    
0730: 6a 73 6f 6e 3d 30 20 20 20 20 20 20 20 20 20 20  json=0          
0740: 20 20 20 20 20 3d 3e 20 7b 42 75 69 6c 64 20 77       => {Build w
0750: 69 74 68 20 66 6f 73 73 69 6c 20 4a 53 4f 4e 20  ith fossil JSON 
0760: 41 50 49 20 65 6e 61 62 6c 65 64 7d 0a 20 20 20  API enabled}.   
0770: 20 77 69 74 68 2d 65 6d 73 64 6b 3a 70 61 74 68   with-emsdk:path
0780: 20 20 20 20 20 20 3d 3e 20 7b 44 69 72 65 63 74        => {Direct
0790: 6f 72 79 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74  ory containing t
07a0: 68 65 20 45 6d 73 63 72 69 70 74 65 6e 20 53 44  he Emscripten SD
07b0: 4b 7d 0a 20 20 20 20 63 6f 6d 70 69 6c 65 2d 63  K}.    compile-c
07c0: 6f 6d 6d 61 6e 64 73 3d 30 20 3d 3e 0a 20 20 20  ommands=0 =>.   
07d0: 20 20 20 22 43 68 65 63 6b 20 66 6f 72 20 63 6f     "Check for co
07e0: 6d 70 69 6c 65 5f 63 6f 6d 6d 61 6e 64 73 2e 6a  mpile_commands.j
07f0: 73 6f 6e 20 73 75 70 70 6f 72 74 2e 22 0a 7d 0a  son support.".}.
0800: 0a 23 20 55 70 64 61 74 65 20 74 68 65 20 6d 69  .# Update the mi
0810: 6e 69 6d 75 6d 20 72 65 71 75 69 72 65 64 20 53  nimum required S
0820: 51 4c 69 74 65 20 76 65 72 73 69 6f 6e 20 6e 75  QLite version nu
0830: 6d 62 65 72 20 68 65 72 65 2c 20 61 6e 64 20 61  mber here, and a
0840: 6c 73 6f 0a 23 20 69 6e 20 73 72 63 2f 6d 61 69  lso.# in src/mai
0850: 6e 2e 63 20 6e 65 61 72 20 74 68 65 20 73 71 6c  n.c near the sql
0860: 69 74 65 33 5f 6c 69 62 76 65 72 73 69 6f 6e 5f  ite3_libversion_
0870: 6e 75 6d 62 65 72 28 29 20 63 61 6c 6c 2e 20 20  number() call.  
0880: 54 61 6b 65 20 63 61 72 65 0a 23 20 74 68 61 74  Take care.# that
0890: 20 62 6f 74 68 20 70 6c 61 63 65 73 20 61 67 72   both places agr
08a0: 65 65 21 0a 64 65 66 69 6e 65 20 4d 49 4e 49 4d  ee!.define MINIM
08b0: 55 4d 5f 53 51 4c 49 54 45 5f 56 45 52 53 49 4f  UM_SQLITE_VERSIO
08c0: 4e 20 22 33 2e 34 36 2e 30 22 0a 0a 23 20 54 68  N "3.46.0"..# Th
08d0: 69 73 20 69 73 20 75 73 65 66 75 6c 20 66 6f 72  is is useful for
08e0: 20 70 65 6f 70 6c 65 20 77 61 6e 74 69 6e 67 20   people wanting 
08f0: 46 6f 73 73 69 6c 20 74 6f 20 75 73 65 20 61 6e  Fossil to use an
0900: 20 65 78 74 65 72 6e 61 6c 20 53 51 4c 69 74 65   external SQLite
0910: 20 6c 69 62 72 61 72 79 0a 23 20 74 6f 20 63 6f   library.# to co
0920: 6d 70 61 72 65 20 74 68 65 20 6f 6e 65 20 74 68  mpare the one th
0930: 65 79 20 68 61 76 65 20 61 67 61 69 6e 73 74 20  ey have against 
0940: 74 68 65 20 6d 69 6e 69 6d 75 6d 20 72 65 71 75  the minimum requ
0950: 69 72 65 64 0a 69 66 20 7b 5b 6f 70 74 2d 62 6f  ired.if {[opt-bo
0960: 6f 6c 20 70 72 69 6e 74 2d 6d 69 6e 69 6d 75 6d  ol print-minimum
0970: 2d 73 71 6c 69 74 65 2d 76 65 72 73 69 6f 6e 5d  -sqlite-version]
0980: 7d 20 7b 0a 20 20 20 20 70 75 74 73 20 5b 67 65  } {.    puts [ge
0990: 74 2d 64 65 66 69 6e 65 20 4d 49 4e 49 4d 55 4d  t-define MINIMUM
09a0: 5f 53 51 4c 49 54 45 5f 56 45 52 53 49 4f 4e 5d  _SQLITE_VERSION]
09b0: 0a 20 20 20 20 65 78 69 74 20 30 0a 7d 0a 0a 73  .    exit 0.}..s
09c0: 65 74 20 6f 75 74 4f 66 54 72 65 65 42 75 69 6c  et outOfTreeBuil
09d0: 64 20 30 0a 69 66 20 7b 21 5b 66 69 6c 65 20 65  d 0.if {![file e
09e0: 78 69 73 74 73 20 66 6f 73 73 69 6c 2e 31 5d 7d  xists fossil.1]}
09f0: 20 7b 0a 20 20 70 75 74 73 20 22 54 68 69 73 20   {.  puts "This 
0a00: 61 70 70 65 61 72 73 20 74 6f 20 62 65 20 61 6e  appears to be an
0a10: 20 6f 75 74 2d 6f 66 2d 74 72 65 65 20 62 75 69   out-of-tree bui
0a20: 6c 64 2e 22 0a 20 20 73 65 74 20 6f 75 74 4f 66  ld.".  set outOf
0a30: 54 72 65 65 42 75 69 6c 64 20 31 0a 7d 0a 0a 23  TreeBuild 1.}..#
0a40: 20 73 71 6c 69 74 65 20 77 61 6e 74 73 20 74 68   sqlite wants th
0a50: 65 73 65 20 74 79 70 65 73 20 69 66 20 70 6f 73  ese types if pos
0a60: 73 69 62 6c 65 0a 63 63 2d 77 69 74 68 20 7b 2d  sible.cc-with {-
0a70: 69 6e 63 6c 75 64 65 73 20 7b 73 74 64 69 6e 74  includes {stdint
0a80: 2e 68 20 69 6e 74 74 79 70 65 73 2e 68 7d 7d 20  .h inttypes.h}} 
0a90: 7b 0a 20 20 20 20 63 63 2d 63 68 65 63 6b 2d 74  {.    cc-check-t
0aa0: 79 70 65 73 20 75 69 6e 74 33 32 5f 74 20 75 69  ypes uint32_t ui
0ab0: 6e 74 31 36 5f 74 20 69 6e 74 31 36 5f 74 20 75  nt16_t int16_t u
0ac0: 69 6e 74 38 5f 74 0a 7d 0a 0a 23 20 55 73 65 20  int8_t.}..# Use 
0ad0: 70 72 65 61 64 2f 70 77 72 69 74 65 20 73 79 73  pread/pwrite sys
0ae0: 74 65 6d 20 63 61 6c 6c 73 20 69 6e 20 70 6c 61  tem calls in pla
0af0: 63 65 20 6f 66 20 73 65 65 6b 20 2b 20 72 65 61  ce of seek + rea
0b00: 64 2f 77 72 69 74 65 20 69 66 20 70 6f 73 73 69  d/write if possi
0b10: 62 6c 65 0a 64 65 66 69 6e 65 20 55 53 45 5f 50  ble.define USE_P
0b20: 52 45 41 44 20 5b 63 63 2d 63 68 65 63 6b 2d 66  READ [cc-check-f
0b30: 75 6e 63 74 69 6f 6e 73 20 70 72 65 61 64 5d 0a  unctions pread].
0b40: 0a 23 20 49 66 20 77 65 20 68 61 76 65 20 63 73  .# If we have cs
0b50: 63 6f 70 65 20 68 65 72 65 2c 20 77 65 27 6c 6c  cope here, we'll
0b60: 20 75 73 65 20 69 74 20 69 6e 20 74 68 65 20 22   use it in the "
0b70: 74 61 67 73 22 20 74 61 72 67 65 74 0a 69 66 20  tags" target.if 
0b80: 7b 5b 63 63 2d 63 68 65 63 6b 2d 70 72 6f 67 73  {[cc-check-progs
0b90: 20 63 73 63 6f 70 65 5d 7d 20 7b 0a 20 20 20 20   cscope]} {.    
0ba0: 64 65 66 69 6e 65 20 43 4f 4c 4c 45 43 54 5f 43  define COLLECT_C
0bb0: 53 43 4f 50 45 5f 44 41 54 41 20 22 63 73 63 6f  SCOPE_DATA "csco
0bc0: 70 65 20 2d 62 52 20 24 3a 3a 61 75 74 6f 73 65  pe -bR $::autose
0bd0: 74 75 70 28 73 72 63 64 69 72 29 2f 73 72 63 2f  tup(srcdir)/src/
0be0: 2a 2e 5c 5b 63 68 5c 5d 22 0a 7d 20 65 6c 73 65  *.\[ch\]".} else
0bf0: 20 7b 0a 20 20 20 20 64 65 66 69 6e 65 20 43 4f   {.    define CO
0c00: 4c 4c 45 43 54 5f 43 53 43 4f 50 45 5f 44 41 54  LLECT_CSCOPE_DAT
0c10: 41 20 22 22 0a 7d 0a 0a 23 20 46 69 6e 64 20 74  A "".}..# Find t
0c20: 63 6c 73 68 20 66 6f 72 20 74 68 65 20 74 65 73  clsh for the tes
0c30: 74 20 73 75 69 74 65 2e 0a 23 0a 23 20 57 65 20  t suite..#.# We 
0c40: 63 61 6e 27 74 20 75 73 65 20 6a 69 6d 73 68 20  can't use jimsh 
0c50: 66 6f 72 20 74 68 69 73 3a 20 74 68 65 20 74 65  for this: the te
0c60: 73 74 20 73 75 69 74 65 20 75 73 65 73 20 66 65  st suite uses fe
0c70: 61 74 75 72 65 73 20 6f 66 20 54 63 6c 20 74 68  atures of Tcl th
0c80: 61 74 0a 23 20 4a 69 6d 20 64 6f 65 73 6e 27 74  at.# Jim doesn't
0c90: 20 73 75 70 70 6f 72 74 2c 20 65 69 74 68 65 72   support, either
0ca0: 20 73 74 61 74 69 63 61 6c 6c 79 20 6f 72 20 64   statically or d
0cb0: 75 65 20 74 6f 20 74 68 65 20 77 61 79 20 69 74  ue to the way it
0cc0: 27 73 20 62 75 69 6c 74 20 62 79 0a 23 20 61 75  's built by.# au
0cd0: 74 6f 73 65 74 75 70 2e 20 20 46 6f 72 20 65 78  tosetup.  For ex
0ce0: 61 6d 70 6c 65 2c 20 4a 69 6d 20 73 75 70 70 6f  ample, Jim suppo
0cf0: 72 74 73 20 60 66 69 6c 65 20 6e 6f 72 6d 61 6c  rts `file normal
0d00: 69 7a 65 60 2c 20 62 75 74 20 6f 6e 6c 79 20 69  ize`, but only i
0d10: 66 0a 23 20 79 6f 75 20 62 75 69 6c 64 20 69 74  f.# you build it
0d20: 20 77 69 74 68 20 48 41 56 45 5f 52 45 41 4c 50   with HAVE_REALP
0d30: 41 54 48 2c 20 77 68 69 63 68 20 77 6f 6e 27 74  ATH, which won't
0d40: 20 65 76 65 72 20 62 65 20 64 65 66 69 6e 65 64   ever be defined
0d50: 20 69 6e 20 74 68 69 73 0a 23 20 63 6f 6e 74 65   in this.# conte
0d60: 78 74 20 62 65 63 61 75 73 65 20 61 75 74 6f 73  xt because autos
0d70: 65 74 75 70 20 64 6f 65 73 6e 27 74 20 74 72 79  etup doesn't try
0d80: 20 74 6f 20 64 69 73 63 6f 76 65 72 20 70 6c 61   to discover pla
0d90: 74 66 6f 72 6d 2d 73 70 65 63 69 66 69 63 0a 23  tform-specific.#
0da0: 20 64 65 74 61 69 6c 73 20 6c 69 6b 65 20 74 68   details like th
0db0: 61 74 20 62 65 66 6f 72 65 20 69 74 20 64 65 63  at before it dec
0dc0: 69 64 65 73 20 74 6f 20 62 75 69 6c 64 20 6a 69  ides to build ji
0dd0: 6d 73 68 30 2e 20 20 42 65 73 69 64 65 73 20 77  msh0.  Besides w
0de0: 68 69 63 68 2c 0a 23 20 61 75 74 6f 73 65 74 75  hich,.# autosetu
0df0: 70 20 77 6f 6e 27 74 20 62 75 69 6c 64 20 6a 69  p won't build ji
0e00: 6d 73 68 30 20 61 74 20 61 6c 6c 20 69 66 20 69  msh0 at all if i
0e10: 74 20 63 61 6e 20 66 69 6e 64 20 74 63 6c 73 68  t can find tclsh
0e20: 20 69 74 73 65 6c 66 2e 0a 23 20 49 72 6f 6e 69   itself..# Ironi
0e30: 63 61 6c 6c 79 2c 20 74 68 69 73 20 6d 65 61 6e  cally, this mean
0e40: 73 20 77 65 20 6d 61 79 20 72 69 67 68 74 20 6e  s we may right n
0e50: 6f 77 20 62 65 20 72 75 6e 6e 69 6e 67 20 75 6e  ow be running un
0e60: 64 65 72 20 65 69 74 68 65 72 20 6a 69 6d 73 68  der either jimsh
0e70: 30 0a 23 20 6f 72 20 61 20 76 65 72 73 69 6f 6e  0.# or a version
0e80: 20 6f 66 20 74 63 6c 73 68 20 74 68 61 74 20 77   of tclsh that w
0e90: 65 20 66 69 6e 64 20 75 6e 73 75 69 74 61 62 6c  e find unsuitabl
0ea0: 65 20 62 65 6c 6f 77 21 0a 63 63 2d 63 68 65 63  e below!.cc-chec
0eb0: 6b 2d 70 72 6f 67 73 20 74 63 6c 73 68 0a 73 65  k-progs tclsh.se
0ec0: 74 20 68 62 74 64 20 2f 75 73 72 2f 6c 6f 63 61  t hbtd /usr/loca
0ed0: 6c 2f 43 65 6c 6c 61 72 2f 74 63 6c 2d 74 6b 0a  l/Cellar/tcl-tk.
0ee0: 69 66 20 7b 5b 73 74 72 69 6e 67 20 65 71 75 61  if {[string equa
0ef0: 6c 20 66 61 6c 73 65 20 5b 67 65 74 2d 64 65 66  l false [get-def
0f00: 69 6e 65 20 54 43 4c 53 48 5d 5d 7d 20 7b 0a 20  ine TCLSH]]} {. 
0f10: 20 20 20 6d 73 67 2d 72 65 73 75 6c 74 20 22 57     msg-result "W
0f20: 41 52 4e 49 4e 47 3a 20 27 6d 61 6b 65 20 74 65  ARNING: 'make te
0f30: 73 74 27 20 77 69 6c 6c 20 6e 6f 74 20 72 75 6e  st' will not run
0f40: 20 68 65 72 65 2e 22 0a 7d 20 65 6c 73 65 20 7b   here.".} else {
0f50: 0a 20 20 20 20 73 65 74 20 76 20 5b 65 78 65 63  .    set v [exec
0f60: 20 2f 62 69 6e 2f 73 68 20 2d 63 20 22 65 63 68   /bin/sh -c "ech
0f70: 6f 20 27 70 75 74 73 20 5c 24 74 63 6c 5f 76 65  o 'puts \$tcl_ve
0f80: 72 73 69 6f 6e 27 20 7c 20 74 63 6c 73 68 22 5d  rsion' | tclsh"]
0f90: 0a 20 20 20 20 69 66 20 7b 5b 65 78 70 72 20 7b  .    if {[expr {
0fa0: 24 76 20 3e 3d 20 38 2e 36 7d 5d 7d 20 7b 0a 20  $v >= 8.6}]} {. 
0fb0: 20 20 20 20 20 20 20 6d 73 67 2d 72 65 73 75 6c         msg-resul
0fc0: 74 20 22 46 6f 75 6e 64 20 54 63 6c 73 68 20 76  t "Found Tclsh v
0fd0: 65 72 73 69 6f 6e 20 24 76 20 69 6e 20 74 68 65  ersion $v in the
0fe0: 20 50 41 54 48 2e 22 0a 20 20 20 20 20 20 20 20   PATH.".        
0ff0: 64 65 66 69 6e 65 20 54 43 4c 53 48 20 74 63 6c  define TCLSH tcl
1000: 73 68 0a 20 20 20 20 7d 20 65 6c 73 65 69 66 20  sh.    } elseif 
1010: 7b 5b 66 69 6c 65 20 69 73 64 69 72 65 63 74 6f  {[file isdirecto
1020: 72 79 20 24 68 62 74 64 5d 7d 20 7b 0a 20 20 20  ry $hbtd]} {.   
1030: 20 20 20 20 20 23 20 54 68 69 73 20 69 73 20 61       # This is a
1040: 20 6d 61 63 4f 53 20 73 79 73 74 65 6d 20 77 69   macOS system wi
1050: 74 68 20 74 68 65 20 48 6f 6d 65 62 72 65 77 20  th the Homebrew 
1060: 76 65 72 73 69 6f 6e 20 6f 66 20 54 63 6c 2f 54  version of Tcl/T
1070: 6b 0a 20 20 20 20 20 20 20 20 23 20 69 6e 73 74  k.        # inst
1080: 61 6c 6c 65 64 2e 20 20 53 65 6c 65 63 74 20 74  alled.  Select t
1090: 68 65 20 6e 65 77 65 73 74 20 76 65 72 73 69 6f  he newest versio
10a0: 6e 2e 20 20 49 74 20 77 6f 6e 27 74 20 6e 6f 72  n.  It won't nor
10b0: 6d 61 6c 6c 79 20 62 65 0a 20 20 20 20 20 20 20  mally be.       
10c0: 20 23 20 69 6e 20 74 68 65 20 50 41 54 48 20 74   # in the PATH t
10d0: 6f 20 61 76 6f 69 64 20 73 68 61 64 6f 77 69 6e  o avoid shadowin
10e0: 67 20 2f 75 73 72 2f 62 69 6e 2f 74 63 6c 73 68  g /usr/bin/tclsh
10f0: 2c 20 61 6e 64 20 65 76 65 6e 20 69 66 20 69 74  , and even if it
1100: 0a 20 20 20 20 20 20 20 20 23 20 77 65 72 65 20  .        # were 
1110: 69 6e 20 74 68 65 20 50 41 54 48 2c 20 69 74 27  in the PATH, it'
1120: 73 20 62 61 64 20 70 72 61 63 74 69 63 65 20 74  s bad practice t
1130: 6f 20 70 75 74 20 2f 75 73 72 2f 6c 6f 63 61 6c  o put /usr/local
1140: 2f 62 69 6e 20 28 74 68 65 0a 20 20 20 20 20 20  /bin (the.      
1150: 20 20 23 20 48 6f 6d 65 62 72 65 77 20 64 65 66    # Homebrew def
1160: 61 75 6c 74 29 20 61 68 65 61 64 20 6f 66 20 2f  ault) ahead of /
1170: 75 73 72 2f 62 69 6e 2c 20 65 73 70 65 63 69 61  usr/bin, especia
1180: 6c 6c 79 20 67 69 76 65 6e 20 74 68 61 74 0a 20  lly given that. 
1190: 20 20 20 20 20 20 20 23 20 69 74 27 73 20 75 73         # it's us
11a0: 65 72 2d 77 72 69 74 65 61 62 6c 65 20 62 79 20  er-writeable by 
11b0: 64 65 66 61 75 6c 74 20 77 69 74 68 20 48 6f 6d  default with Hom
11c0: 65 62 72 65 77 2e 20 20 54 68 75 73 2c 20 77 65  ebrew.  Thus, we
11d0: 20 63 61 6e 20 62 65 0a 20 20 20 20 20 20 20 20   can be.        
11e0: 23 20 70 72 65 74 74 79 20 73 75 72 65 20 74 68  # pretty sure th
11f0: 65 20 6f 6e 6c 79 20 77 61 79 20 74 6f 20 63 61  e only way to ca
1200: 6c 6c 20 69 74 20 69 73 20 77 69 74 68 20 61 6e  ll it is with an
1210: 20 61 62 73 6f 6c 75 74 65 20 70 61 74 68 2e 0a   absolute path..
1220: 20 20 20 20 20 20 20 20 73 65 74 20 76 20 5b 65          set v [e
1230: 78 65 63 20 6c 73 20 2d 74 72 20 24 68 62 74 64  xec ls -tr $hbtd
1240: 20 7c 20 74 61 69 6c 20 2d 31 5d 0a 20 20 20 20   | tail -1].    
1250: 20 20 20 20 73 65 74 20 70 61 74 68 20 22 24 68      set path "$h
1260: 62 74 64 2f 24 76 2f 62 69 6e 2f 74 63 6c 73 68  btd/$v/bin/tclsh
1270: 22 0a 20 20 20 20 20 20 20 20 64 65 66 69 6e 65  ".        define
1280: 20 54 43 4c 53 48 20 24 70 61 74 68 0a 20 20 20   TCLSH $path.   
1290: 20 20 20 20 20 6d 73 67 2d 72 65 73 75 6c 74 20       msg-result 
12a0: 22 55 73 69 6e 67 20 48 6f 6d 65 62 72 65 77 20  "Using Homebrew 
12b0: 54 63 6c 2f 54 6b 20 76 65 72 73 69 6f 6e 20 24  Tcl/Tk version $
12c0: 70 61 74 68 2e 22 0a 20 20 20 20 7d 20 65 6c 73  path.".    } els
12d0: 65 20 7b 0a 20 20 20 20 20 20 20 20 6d 73 67 2d  e {.        msg-
12e0: 72 65 73 75 6c 74 20 22 57 41 52 4e 49 4e 47 3a  result "WARNING:
12f0: 20 74 63 6c 73 68 20 24 76 20 66 6f 75 6e 64 3b   tclsh $v found;
1300: 20 6e 65 65 64 20 3e 3d 20 38 2e 36 20 66 6f 72   need >= 8.6 for
1310: 20 27 6d 61 6b 65 20 74 65 73 74 27 2e 22 0a 20   'make test'.". 
1320: 20 20 20 20 20 20 20 64 65 66 69 6e 65 20 54 43         define TC
1330: 4c 53 48 20 66 61 6c 73 65 20 20 20 20 20 3b 23  LSH false     ;#
1340: 20 66 6f 72 63 65 20 22 6d 61 6b 65 20 74 65 73   force "make tes
1350: 74 22 20 66 61 69 6c 75 72 65 20 76 69 61 20 2f  t" failure via /
1360: 75 73 72 2f 62 69 6e 2f 66 61 6c 73 65 0a 20 20  usr/bin/false.  
1370: 20 20 7d 0a 7d 0a 0a 64 65 66 69 6e 65 20 45 58    }.}..define EX
1380: 54 52 41 5f 43 46 4c 41 47 53 20 22 2d 57 61 6c  TRA_CFLAGS "-Wal
1390: 6c 22 0a 64 65 66 69 6e 65 20 45 58 54 52 41 5f  l".define EXTRA_
13a0: 4c 44 46 4c 41 47 53 20 22 22 0a 64 65 66 69 6e  LDFLAGS "".defin
13b0: 65 20 55 53 45 5f 53 59 53 54 45 4d 5f 53 51 4c  e USE_SYSTEM_SQL
13c0: 49 54 45 20 30 0a 64 65 66 69 6e 65 20 55 53 45  ITE 0.define USE
13d0: 5f 4c 49 4e 45 4e 4f 49 53 45 20 30 0a 64 65 66  _LINENOISE 0.def
13e0: 69 6e 65 20 55 53 45 5f 4d 4d 41 4e 5f 48 20 30  ine USE_MMAN_H 0
13f0: 0a 64 65 66 69 6e 65 20 55 53 45 5f 53 45 45 20  .define USE_SEE 
1400: 30 0a 64 65 66 69 6e 65 20 53 51 4c 49 54 45 33  0.define SQLITE3
1410: 5f 4f 52 49 47 49 4e 20 30 0a 23 20 53 51 4c 49  _ORIGIN 0.# SQLI
1420: 54 45 33 5f 4f 52 49 47 49 4e 20 30 20 3d 20 73  TE3_ORIGIN 0 = s
1430: 72 63 2f 73 71 6c 69 74 65 33 2c 20 31 3d 73 72  rc/sqlite3, 1=sr
1440: 63 2f 73 71 6c 69 74 65 33 2d 73 65 65 2e 63 2c  c/sqlite3-see.c,
1450: 20 32 3d 63 6c 69 65 6e 74 2d 70 72 6f 76 69 64   2=client-provid
1460: 65 64 0a 0a 23 20 4d 61 69 6e 74 61 69 6e 20 74  ed..# Maintain t
1470: 68 65 20 43 38 39 2f 43 39 30 2d 73 74 79 6c 65  he C89/C90-style
1480: 20 6f 72 64 65 72 20 6f 66 20 76 61 72 69 61 62   order of variab
1490: 6c 65 20 64 65 63 6c 61 72 61 74 69 6f 6e 73 20  le declarations 
14a0: 62 65 66 6f 72 65 20 73 74 61 74 65 6d 65 6e 74  before statement
14b0: 73 2e 0a 23 20 43 68 65 63 6b 20 69 66 20 74 68  s..# Check if th
14c0: 65 20 63 6f 6d 70 69 6c 65 72 20 73 75 70 70 6f  e compiler suppo
14d0: 72 74 73 20 74 68 65 20 72 65 73 70 65 63 74 69  rts the respecti
14e0: 76 65 20 77 61 72 6e 69 6e 67 20 66 6c 61 67 2e  ve warning flag.
14f0: 0a 69 66 20 7b 5b 63 63 74 65 73 74 20 2d 63 66  .if {[cctest -cf
1500: 6c 61 67 73 20 2d 57 64 65 63 6c 61 72 61 74 69  lags -Wdeclarati
1510: 6f 6e 2d 61 66 74 65 72 2d 73 74 61 74 65 6d 65  on-after-stateme
1520: 6e 74 5d 7d 20 7b 0a 20 20 20 20 64 65 66 69 6e  nt]} {.    defin
1530: 65 2d 61 70 70 65 6e 64 20 45 58 54 52 41 5f 43  e-append EXTRA_C
1540: 46 4c 41 47 53 20 2d 57 64 65 63 6c 61 72 61 74  FLAGS -Wdeclarat
1550: 69 6f 6e 2d 61 66 74 65 72 2d 73 74 61 74 65 6d  ion-after-statem
1560: 65 6e 74 0a 7d 0a 0a 0a 23 20 54 68 69 73 20 70  ent.}...# This p
1570: 72 6f 63 65 64 75 72 65 20 69 73 20 61 20 63 75  rocedure is a cu
1580: 73 74 6f 6d 69 7a 65 64 20 76 65 72 73 69 6f 6e  stomized version
1590: 20 6f 66 20 22 63 63 2d 63 68 65 63 6b 2d 66 75   of "cc-check-fu
15a0: 6e 63 74 69 6f 6e 2d 69 6e 2d 6c 69 62 22 2c 0a  nction-in-lib",.
15b0: 23 20 74 68 61 74 20 64 6f 65 73 20 6e 6f 74 20  # that does not 
15c0: 6d 6f 64 69 66 79 20 74 68 65 20 4c 49 42 53 20  modify the LIBS 
15d0: 76 61 72 69 61 62 6c 65 2e 20 20 49 74 73 20 75  variable.  Its u
15e0: 73 65 20 70 72 65 76 65 6e 74 73 20 70 72 65 6d  se prevents prem
15f0: 61 74 75 72 65 6c 79 0a 23 20 70 75 6c 6c 69 6e  aturely.# pullin
1600: 67 20 69 6e 20 6c 69 62 72 61 72 69 65 73 20 74  g in libraries t
1610: 68 61 74 20 77 69 6c 6c 20 62 65 20 61 64 64 65  hat will be adde
1620: 64 20 6c 61 74 65 72 20 61 6e 79 68 6f 77 20 28  d later anyhow (
1630: 65 2e 67 2e 20 22 2d 6c 64 6c 22 29 2e 0a 70 72  e.g. "-ldl")..pr
1640: 6f 63 20 63 68 65 63 6b 2d 66 75 6e 63 74 69 6f  oc check-functio
1650: 6e 2d 69 6e 2d 6c 69 62 20 7b 66 75 6e 63 74 69  n-in-lib {functi
1660: 6f 6e 20 6c 69 62 73 20 7b 6f 74 68 65 72 6c 69  on libs {otherli
1670: 62 73 20 7b 7d 7d 7d 20 7b 0a 20 20 20 20 69 66  bs {}}} {.    if
1680: 20 7b 5b 73 74 72 69 6e 67 20 6c 65 6e 67 74 68   {[string length
1690: 20 24 6f 74 68 65 72 6c 69 62 73 5d 7d 20 7b 0a   $otherlibs]} {.
16a0: 20 20 20 20 20 20 20 20 6d 73 67 2d 63 68 65 63          msg-chec
16b0: 6b 69 6e 67 20 22 43 68 65 63 6b 69 6e 67 20 66  king "Checking f
16c0: 6f 72 20 24 66 75 6e 63 74 69 6f 6e 20 69 6e 20  or $function in 
16d0: 24 6c 69 62 73 20 77 69 74 68 20 24 6f 74 68 65  $libs with $othe
16e0: 72 6c 69 62 73 2e 2e 2e 22 0a 20 20 20 20 7d 20  rlibs...".    } 
16f0: 65 6c 73 65 20 7b 0a 20 20 20 20 20 20 20 20 6d  else {.        m
1700: 73 67 2d 63 68 65 63 6b 69 6e 67 20 22 43 68 65  sg-checking "Che
1710: 63 6b 69 6e 67 20 66 6f 72 20 24 66 75 6e 63 74  cking for $funct
1720: 69 6f 6e 20 69 6e 20 24 6c 69 62 73 2e 2e 2e 22  ion in $libs..."
1730: 0a 20 20 20 20 7d 0a 20 20 20 20 73 65 74 20 66  .    }.    set f
1740: 6f 75 6e 64 20 30 0a 20 20 20 20 63 63 2d 77 69  ound 0.    cc-wi
1750: 74 68 20 5b 6c 69 73 74 20 2d 6c 69 62 73 20 24  th [list -libs $
1760: 6f 74 68 65 72 6c 69 62 73 5d 20 7b 0a 20 20 20  otherlibs] {.   
1770: 20 20 20 20 20 69 66 20 7b 5b 63 63 74 65 73 74       if {[cctest
1780: 5f 66 75 6e 63 74 69 6f 6e 20 24 66 75 6e 63 74  _function $funct
1790: 69 6f 6e 5d 7d 20 7b 0a 20 20 20 20 20 20 20 20  ion]} {.        
17a0: 20 20 20 20 6d 73 67 2d 72 65 73 75 6c 74 20 22      msg-result "
17b0: 6e 6f 6e 65 20 6e 65 65 64 65 64 22 0a 20 20 20  none needed".   
17c0: 20 20 20 20 20 20 20 20 20 64 65 66 69 6e 65 20           define 
17d0: 6c 69 62 5f 24 66 75 6e 63 74 69 6f 6e 20 22 22  lib_$function ""
17e0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 63  .            inc
17f0: 72 20 66 6f 75 6e 64 0a 20 20 20 20 20 20 20 20  r found.        
1800: 7d 20 65 6c 73 65 20 7b 0a 20 20 20 20 20 20 20  } else {.       
1810: 20 20 20 20 20 66 6f 72 65 61 63 68 20 6c 69 62       foreach lib
1820: 20 24 6c 69 62 73 20 7b 0a 20 20 20 20 20 20 20   $libs {.       
1830: 20 20 20 20 20 20 20 20 20 63 63 2d 77 69 74 68           cc-with
1840: 20 5b 6c 69 73 74 20 2d 6c 69 62 73 20 2d 6c 24   [list -libs -l$
1850: 6c 69 62 5d 20 7b 0a 20 20 20 20 20 20 20 20 20  lib] {.         
1860: 20 20 20 20 20 20 20 20 20 20 20 69 66 20 7b 5b             if {[
1870: 63 63 74 65 73 74 5f 66 75 6e 63 74 69 6f 6e 20  cctest_function 
1880: 24 66 75 6e 63 74 69 6f 6e 5d 7d 20 7b 0a 20 20  $function]} {.  
1890: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
18a0: 20 20 20 20 20 20 6d 73 67 2d 72 65 73 75 6c 74        msg-result
18b0: 20 2d 6c 24 6c 69 62 0a 20 20 20 20 20 20 20 20   -l$lib.        
18c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
18d0: 64 65 66 69 6e 65 20 6c 69 62 5f 24 66 75 6e 63  define lib_$func
18e0: 74 69 6f 6e 20 2d 6c 24 6c 69 62 0a 20 20 20 20  tion -l$lib.    
18f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1900: 20 20 20 20 69 6e 63 72 20 66 6f 75 6e 64 0a 20      incr found. 
1910: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1920: 20 20 20 20 20 20 20 62 72 65 61 6b 0a 20 20 20         break.   
1930: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1940: 20 7d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20   }.             
1950: 20 20 20 7d 0a 20 20 20 20 20 20 20 20 20 20 20     }.           
1960: 20 7d 0a 20 20 20 20 20 20 20 20 7d 0a 20 20 20   }.        }.   
1970: 20 7d 0a 20 20 20 20 69 66 20 7b 24 66 6f 75 6e   }.    if {$foun
1980: 64 7d 20 7b 0a 20 20 20 20 20 20 20 20 64 65 66  d} {.        def
1990: 69 6e 65 20 5b 66 65 61 74 75 72 65 2d 64 65 66  ine [feature-def
19a0: 69 6e 65 2d 6e 61 6d 65 20 24 66 75 6e 63 74 69  ine-name $functi
19b0: 6f 6e 5d 0a 20 20 20 20 7d 20 65 6c 73 65 20 7b  on].    } else {
19c0: 0a 20 20 20 20 20 20 20 20 6d 73 67 2d 72 65 73  .        msg-res
19d0: 75 6c 74 20 22 6e 6f 22 0a 20 20 20 20 7d 0a 20  ult "no".    }. 
19e0: 20 20 20 72 65 74 75 72 6e 20 24 66 6f 75 6e 64     return $found
19f0: 0a 7d 0a 0a 69 66 20 7b 21 5b 6f 70 74 2d 62 6f  .}..if {![opt-bo
1a00: 6f 6c 20 69 6e 74 65 72 6e 61 6c 2d 73 71 6c 69  ol internal-sqli
1a10: 74 65 5d 7d 20 7b 0a 20 20 70 72 6f 63 20 66 69  te]} {.  proc fi
1a20: 6e 64 5f 73 79 73 74 65 6d 5f 73 71 6c 69 74 65  nd_system_sqlite
1a30: 20 7b 7d 20 7b 0a 0a 20 20 20 20 23 20 4f 6e 20   {} {..    # On 
1a40: 73 6f 6d 65 20 73 79 73 74 65 6d 73 20 28 73 6c  some systems (sl
1a50: 61 63 6b 77 61 72 65 29 2c 20 6c 69 62 73 71 6c  ackware), libsql
1a60: 69 74 65 33 20 72 65 71 75 69 72 65 73 20 2d 6c  ite3 requires -l
1a70: 64 6c 20 74 6f 20 6c 69 6e 6b 2e 20 53 6f 0a 20  dl to link. So. 
1a80: 20 20 20 23 20 73 65 61 72 63 68 20 66 6f 72 20     # search for 
1a90: 74 68 65 20 73 79 73 74 65 6d 20 53 51 4c 69 74  the system SQLit
1aa0: 65 20 6f 6e 63 65 20 77 69 74 68 20 2d 6c 64 6c  e once with -ldl
1ab0: 2c 20 61 6e 64 20 6f 6e 63 65 20 77 69 74 68 6f  , and once witho
1ac0: 75 74 2e 20 49 66 0a 20 20 20 20 23 20 74 68 65  ut. If.    # the
1ad0: 20 6c 69 62 72 61 72 79 20 63 61 6e 20 6f 6e 6c   library can onl
1ae0: 79 20 62 65 20 66 6f 75 6e 64 20 77 69 74 68 20  y be found with 
1af0: 24 65 78 74 72 61 6c 69 62 73 20 73 65 74 20 74  $extralibs set t
1b00: 6f 20 2d 6c 64 6c 2c 20 74 68 65 6e 0a 20 20 20  o -ldl, then.   
1b10: 20 23 20 74 68 65 20 63 6f 64 65 20 62 65 6c 6f   # the code belo
1b20: 77 20 77 69 6c 6c 20 61 70 70 65 6e 64 20 2d 6c  w will append -l
1b30: 64 6c 20 74 6f 20 4c 49 42 53 2e 0a 20 20 20 20  dl to LIBS..    
1b40: 23 0a 20 20 20 20 66 6f 72 65 61 63 68 20 65 78  #.    foreach ex
1b50: 74 72 61 6c 69 62 73 20 7b 7b 7d 20 7b 2d 6c 64  tralibs {{} {-ld
1b60: 6c 7d 7d 20 7b 0a 0a 20 20 20 20 20 20 23 20 4c  l}} {..      # L
1b70: 6f 63 61 74 65 20 74 68 65 20 73 79 73 74 65 6d  ocate the system
1b80: 20 53 51 4c 69 74 65 20 62 79 20 73 65 61 72 63   SQLite by searc
1b90: 68 69 6e 67 20 66 6f 72 20 73 71 6c 69 74 65 33  hing for sqlite3
1ba0: 5f 6f 70 65 6e 28 29 2e 20 54 68 65 6e 20 63 68  _open(). Then ch
1bb0: 65 63 6b 0a 20 20 20 20 20 20 23 20 69 66 20 73  eck.      # if s
1bc0: 71 6c 69 74 65 33 5f 73 74 6d 74 5f 69 73 65 78  qlite3_stmt_isex
1bd0: 70 6c 61 69 6e 20 63 61 6e 20 62 65 20 66 6f 75  plain can be fou
1be0: 6e 64 20 61 73 20 77 65 6c 6c 2e 20 49 66 20 77  nd as well. If w
1bf0: 65 20 63 61 6e 20 66 69 6e 64 20 6f 70 65 6e 28  e can find open(
1c00: 29 20 62 75 74 0a 20 20 20 20 20 20 23 20 6e 6f  ) but.      # no
1c10: 74 20 73 74 6d 74 5f 69 73 65 78 70 6c 61 69 6e  t stmt_isexplain
1c20: 28 29 2c 20 74 68 65 6e 20 74 68 65 20 73 79 73  (), then the sys
1c30: 74 65 6d 20 53 51 4c 69 74 65 20 69 73 20 74 6f  tem SQLite is to
1c40: 6f 20 6f 6c 64 20 74 6f 20 6c 69 6e 6b 20 61 67  o old to link ag
1c50: 61 69 6e 73 74 0a 20 20 20 20 20 20 23 20 66 6f  ainst.      # fo
1c60: 73 73 69 6c 2e 0a 20 20 20 20 20 20 23 0a 20 20  ssil..      #.  
1c70: 20 20 20 20 69 66 20 7b 5b 63 68 65 63 6b 2d 66      if {[check-f
1c80: 75 6e 63 74 69 6f 6e 2d 69 6e 2d 6c 69 62 20 73  unction-in-lib s
1c90: 71 6c 69 74 65 33 5f 6f 70 65 6e 20 73 71 6c 69  qlite3_open sqli
1ca0: 74 65 33 20 24 65 78 74 72 61 6c 69 62 73 5d 7d  te3 $extralibs]}
1cb0: 20 7b 0a 20 20 20 20 20 20 20 20 23 20 53 75 63   {.        # Suc
1cc0: 63 65 73 73 2e 20 55 70 64 61 74 65 20 73 79 6d  cess. Update sym
1cd0: 62 6f 6c 73 20 61 6e 64 20 72 65 74 75 72 6e 2e  bols and return.
1ce0: 0a 20 20 20 20 20 20 20 20 23 0a 20 20 20 20 20  .        #.     
1cf0: 20 20 20 64 65 66 69 6e 65 20 55 53 45 5f 53 59     define USE_SY
1d00: 53 54 45 4d 5f 53 51 4c 49 54 45 20 31 0a 20 20  STEM_SQLITE 1.  
1d10: 20 20 20 20 20 20 64 65 66 69 6e 65 2d 61 70 70        define-app
1d20: 65 6e 64 20 4c 49 42 53 20 2d 6c 73 71 6c 69 74  end LIBS -lsqlit
1d30: 65 33 0a 20 20 20 20 20 20 20 20 64 65 66 69 6e  e3.        defin
1d40: 65 2d 61 70 70 65 6e 64 20 4c 49 42 53 20 24 65  e-append LIBS $e
1d50: 78 74 72 61 6c 69 62 73 0a 20 20 20 20 20 20 20  xtralibs.       
1d60: 20 72 65 74 75 72 6e 0a 20 20 20 20 20 20 7d 0a   return.      }.
1d70: 20 20 20 20 7d 0a 20 20 20 20 75 73 65 72 2d 65      }.    user-e
1d80: 72 72 6f 72 20 22 73 79 73 74 65 6d 20 73 71 6c  rror "system sql
1d90: 69 74 65 33 20 6e 6f 74 20 66 6f 75 6e 64 22 0a  ite3 not found".
1da0: 20 20 7d 0a 0a 20 20 66 69 6e 64 5f 73 79 73 74    }..  find_syst
1db0: 65 6d 5f 73 71 6c 69 74 65 0a 0a 20 20 70 72 6f  em_sqlite..  pro
1dc0: 63 20 74 65 73 74 5f 73 79 73 74 65 6d 5f 73 71  c test_system_sq
1dd0: 6c 69 74 65 20 7b 7d 20 7b 0a 20 20 20 20 23 20  lite {} {.    # 
1de0: 43 68 65 63 6b 20 63 6f 6d 70 61 74 69 62 69 6c  Check compatibil
1df0: 69 74 79 20 6f 66 20 74 68 65 20 73 79 73 74 65  ity of the syste
1e00: 6d 20 53 51 4c 69 74 65 20 6c 69 62 72 61 72 79  m SQLite library
1e10: 20 62 79 20 72 75 6e 6e 69 6e 67 20 74 68 65 0a   by running the.
1e20: 20 20 20 20 23 20 73 71 6c 63 6f 6d 70 74 74 65      # sqlcomptte
1e30: 73 74 2e 63 20 70 72 6f 67 72 61 6d 20 69 6e 20  st.c program in 
1e40: 74 68 65 20 73 6f 75 72 63 65 20 74 72 65 65 20  the source tree 
1e50: 70 61 73 73 65 73 0a 20 20 20 20 23 20 4d 49 4e  passes.    # MIN
1e60: 49 4d 55 4d 5f 53 51 4c 49 54 45 5f 56 45 52 53  IMUM_SQLITE_VERS
1e70: 49 4f 4e 20 73 65 74 20 61 74 20 74 68 65 20 74  ION set at the t
1e80: 6f 70 20 6f 66 20 74 68 69 73 20 66 69 6c 65 20  op of this file 
1e90: 74 6f 0a 20 20 20 20 23 20 73 71 6c 63 6f 6d 70  to.    # sqlcomp
1ea0: 74 74 65 73 74 2e 63 0a 20 20 20 20 23 0a 20 20  ttest.c.    #.  
1eb0: 20 20 73 65 74 20 63 6d 64 6c 69 6e 65 20 7b 7d    set cmdline {}
1ec0: 0a 20 20 20 20 6c 61 70 70 65 6e 64 20 63 6d 64  .    lappend cmd
1ed0: 6c 69 6e 65 20 7b 2a 7d 5b 67 65 74 2d 64 65 66  line {*}[get-def
1ee0: 69 6e 65 20 43 43 41 43 48 45 5d 0a 20 20 20 20  ine CCACHE].    
1ef0: 6c 61 70 70 65 6e 64 20 63 6d 64 6c 69 6e 65 20  lappend cmdline 
1f00: 7b 2a 7d 5b 67 65 74 2d 64 65 66 69 6e 65 20 43  {*}[get-define C
1f10: 43 5d 20 7b 2a 7d 5b 67 65 74 2d 64 65 66 69 6e  C] {*}[get-defin
1f20: 65 20 43 46 4c 41 47 53 5d 0a 20 20 20 20 6c 61  e CFLAGS].    la
1f30: 70 70 65 6e 64 20 63 6d 64 6c 69 6e 65 20 24 3a  ppend cmdline $:
1f40: 3a 61 75 74 6f 73 65 74 75 70 28 64 69 72 29 2f  :autosetup(dir)/
1f50: 2e 2e 2f 74 6f 6f 6c 73 2f 73 71 6c 63 6f 6d 70  ../tools/sqlcomp
1f60: 61 74 74 65 73 74 2e 63 20 2d 6f 20 63 6f 6e 66  attest.c -o conf
1f70: 74 65 73 74 5f 5f 0a 20 20 20 20 6c 61 70 70 65  test__.    lappe
1f80: 6e 64 20 63 6d 64 6c 69 6e 65 20 7b 2a 7d 5b 67  nd cmdline {*}[g
1f90: 65 74 2d 64 65 66 69 6e 65 20 4c 44 46 4c 41 47  et-define LDFLAG
1fa0: 53 5d 0a 20 20 20 20 6c 61 70 70 65 6e 64 20 63  S].    lappend c
1fb0: 6d 64 6c 69 6e 65 20 7b 2a 7d 5b 67 65 74 2d 64  mdline {*}[get-d
1fc0: 65 66 69 6e 65 20 4c 49 42 53 5d 0a 20 20 20 20  efine LIBS].    
1fd0: 73 65 74 20 73 71 6c 69 74 65 2d 76 65 72 73 69  set sqlite-versi
1fe0: 6f 6e 20 5b 73 74 72 69 6e 67 20 63 61 74 20 22  on [string cat "
1ff0: 2d 44 20 4d 49 4e 49 4d 55 4d 5f 53 51 4c 49 54  -D MINIMUM_SQLIT
2000: 45 5f 56 45 52 53 49 4f 4e 3d 22 20 5b 67 65 74  E_VERSION=" [get
2010: 2d 64 65 66 69 6e 65 20 4d 49 4e 49 4d 55 4d 5f  -define MINIMUM_
2020: 53 51 4c 49 54 45 5f 56 45 52 53 49 4f 4e 5d 5d  SQLITE_VERSION]]
2030: 0a 20 20 20 20 6c 61 70 70 65 6e 64 20 63 6d 64  .    lappend cmd
2040: 6c 69 6e 65 20 7b 2a 7d 5b 73 65 74 20 73 71 6c  line {*}[set sql
2050: 69 74 65 2d 76 65 72 73 69 6f 6e 5d 0a 20 20 20  ite-version].   
2060: 20 73 65 74 20 6f 6b 20 31 0a 20 20 20 20 73 65   set ok 1.    se
2070: 74 20 65 72 72 20 5b 63 61 74 63 68 20 7b 65 78  t err [catch {ex
2080: 65 63 2d 77 69 74 68 2d 73 74 64 65 72 72 20 7b  ec-with-stderr {
2090: 2a 7d 24 63 6d 64 6c 69 6e 65 7d 20 72 65 73 75  *}$cmdline} resu
20a0: 6c 74 20 65 72 72 69 6e 66 6f 5d 0a 20 20 20 20  lt errinfo].    
20b0: 69 66 20 7b 24 65 72 72 7d 20 7b 0a 20 20 20 20  if {$err} {.    
20c0: 20 20 20 63 6f 6e 66 69 67 6c 6f 67 20 22 46 61     configlog "Fa
20d0: 69 6c 65 64 3a 20 5b 6a 6f 69 6e 20 24 63 6d 64  iled: [join $cmd
20e0: 6c 69 6e 65 5d 22 0a 20 20 20 20 20 20 20 69 66  line]".       if
20f0: 20 7b 5b 73 74 72 69 6e 67 20 6c 65 6e 67 74 68   {[string length
2100: 20 24 72 65 73 75 6c 74 5d 3e 30 7d 20 7b 63 6f   $result]>0} {co
2110: 6e 66 69 67 6c 6f 67 20 24 72 65 73 75 6c 74 7d  nfiglog $result}
2120: 0a 20 20 20 20 20 20 20 63 6f 6e 66 69 67 6c 6f  .       configlo
2130: 67 20 22 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 22  g "============"
2140: 0a 20 20 20 20 20 20 20 73 65 74 20 6f 6b 20 30  .       set ok 0
2150: 0a 20 20 20 20 7d 20 65 6c 73 65 69 66 20 7b 24  .    } elseif {$
2160: 3a 3a 61 75 74 6f 73 65 74 75 70 28 64 65 62 75  ::autosetup(debu
2170: 67 29 7d 20 7b 0a 20 20 20 20 20 20 20 63 6f 6e  g)} {.       con
2180: 66 69 67 6c 6f 67 20 22 43 6f 6d 70 69 6c 65 64  figlog "Compiled
2190: 20 4f 4b 3a 20 5b 6a 6f 69 6e 20 24 63 6d 64 6c   OK: [join $cmdl
21a0: 69 6e 65 5d 22 0a 20 20 20 20 20 20 20 63 6f 6e  ine]".       con
21b0: 66 69 67 6c 6f 67 20 22 3d 3d 3d 3d 3d 3d 3d 3d  figlog "========
21c0: 3d 3d 3d 3d 22 0a 20 20 20 20 7d 0a 20 20 20 20  ====".    }.    
21d0: 69 66 20 7b 21 24 6f 6b 7d 20 7b 0a 20 20 20 20  if {!$ok} {.    
21e0: 20 20 75 73 65 72 2d 65 72 72 6f 72 20 22 75 6e    user-error "un
21f0: 61 62 6c 65 20 74 6f 20 63 6f 6d 70 69 6c 65 20  able to compile 
2200: 53 51 4c 69 74 65 20 63 6f 6d 70 61 74 69 62 69  SQLite compatibi
2210: 6c 69 74 79 20 74 65 73 74 20 70 72 6f 67 72 61  lity test progra
2220: 6d 22 0a 20 20 20 20 7d 0a 20 20 20 20 73 65 74  m".    }.    set
2230: 20 65 72 72 20 5b 63 61 74 63 68 20 7b 65 78 65   err [catch {exe
2240: 63 2d 77 69 74 68 2d 73 74 64 65 72 72 20 2e 2f  c-with-stderr ./
2250: 63 6f 6e 66 74 65 73 74 5f 5f 7d 20 72 65 73 75  conftest__} resu
2260: 6c 74 20 65 72 72 69 6e 66 6f 5d 0a 20 20 20 20  lt errinfo].    
2270: 69 66 20 7b 5b 67 65 74 2d 64 65 66 69 6e 65 20  if {[get-define 
2280: 62 75 69 6c 64 5d 20 65 71 20 5b 67 65 74 2d 64  build] eq [get-d
2290: 65 66 69 6e 65 20 68 6f 73 74 5d 7d 20 7b 0a 20  efine host]} {. 
22a0: 20 20 20 20 20 73 65 74 20 65 72 72 20 5b 63 61       set err [ca
22b0: 74 63 68 20 7b 65 78 65 63 2d 77 69 74 68 2d 73  tch {exec-with-s
22c0: 74 64 65 72 72 20 2e 2f 63 6f 6e 66 74 65 73 74  tderr ./conftest
22d0: 5f 5f 7d 20 72 65 73 75 6c 74 20 65 72 72 69 6e  __} result errin
22e0: 66 6f 5d 0a 20 20 20 20 20 20 69 66 20 7b 24 65  fo].      if {$e
22f0: 72 72 7d 20 7b 0a 20 20 20 20 20 20 20 20 75 73  rr} {.        us
2300: 65 72 2d 65 72 72 6f 72 20 24 72 65 73 75 6c 74  er-error $result
2310: 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a 20  .      }.    }. 
2320: 20 20 20 66 69 6c 65 20 64 65 6c 65 74 65 20 2e     file delete .
2330: 2f 63 6f 6e 66 74 65 73 74 5f 5f 0a 20 20 7d 0a  /conftest__.  }.
2340: 20 20 74 65 73 74 5f 73 79 73 74 65 6d 5f 73 71    test_system_sq
2350: 6c 69 74 65 0a 0a 7d 0a 0a 70 72 6f 63 20 69 73  lite..}..proc is
2360: 5f 6d 69 6e 67 77 20 7b 7d 20 7b 0a 20 20 20 20  _mingw {} {.    
2370: 72 65 74 75 72 6e 20 5b 73 74 72 69 6e 67 20 6d  return [string m
2380: 61 74 63 68 20 2a 6d 69 6e 67 77 2a 20 5b 67 65  atch *mingw* [ge
2390: 74 2d 64 65 66 69 6e 65 20 68 6f 73 74 5d 5d 0a  t-define host]].
23a0: 7d 0a 0a 69 66 20 7b 5b 69 73 5f 6d 69 6e 67 77  }..if {[is_mingw
23b0: 5d 7d 20 7b 0a 20 20 20 20 64 65 66 69 6e 65 2d  ]} {.    define-
23c0: 61 70 70 65 6e 64 20 45 58 54 52 41 5f 43 46 4c  append EXTRA_CFL
23d0: 41 47 53 20 2d 44 42 52 4f 4b 45 4e 5f 4d 49 4e  AGS -DBROKEN_MIN
23e0: 47 57 5f 43 4d 44 4c 49 4e 45 0a 20 20 20 20 64  GW_CMDLINE.    d
23f0: 65 66 69 6e 65 2d 61 70 70 65 6e 64 20 4c 49 42  efine-append LIB
2400: 53 20 2d 6c 6b 65 72 6e 65 6c 33 32 20 2d 6c 77  S -lkernel32 -lw
2410: 73 32 5f 33 32 0a 7d 20 65 6c 73 65 20 7b 0a 20  s2_32.} else {. 
2420: 20 20 20 23 0a 20 20 20 20 23 20 4e 4f 54 45 3a     #.    # NOTE:
2430: 20 41 6c 6c 20 70 6c 61 74 66 6f 72 6d 73 20 65   All platforms e
2440: 78 63 65 70 74 20 4d 69 6e 47 57 20 73 68 6f 75  xcept MinGW shou
2450: 6c 64 20 75 73 65 20 74 68 65 20 6c 69 6e 65 6e  ld use the linen
2460: 6f 69 73 65 0a 20 20 20 20 23 20 20 20 20 20 20  oise.    #      
2470: 20 70 61 63 6b 61 67 65 2e 20 20 49 74 20 69 73   package.  It is
2480: 20 63 75 72 72 65 6e 74 6c 79 20 75 6e 73 75 70   currently unsup
2490: 70 6f 72 74 65 64 20 6f 6e 20 57 69 6e 33 32 2e  ported on Win32.
24a0: 0a 20 20 20 20 23 0a 20 20 20 20 64 65 66 69 6e  .    #.    defin
24b0: 65 20 55 53 45 5f 4c 49 4e 45 4e 4f 49 53 45 20  e USE_LINENOISE 
24c0: 31 0a 7d 0a 0a 69 66 20 7b 5b 73 74 72 69 6e 67  1.}..if {[string
24d0: 20 6d 61 74 63 68 20 2a 2d 73 6f 6c 61 72 69 73   match *-solaris
24e0: 2a 20 5b 67 65 74 2d 64 65 66 69 6e 65 20 68 6f  * [get-define ho
24f0: 73 74 5d 5d 7d 20 7b 0a 20 20 20 20 64 65 66 69  st]]} {.    defi
2500: 6e 65 2d 61 70 70 65 6e 64 20 45 58 54 52 41 5f  ne-append EXTRA_
2510: 43 46 4c 41 47 53 20 7b 2d 44 5f 5f 45 58 54 45  CFLAGS {-D__EXTE
2520: 4e 53 49 4f 4e 53 5f 5f 7d 0a 7d 0a 0a 69 66 20  NSIONS__}.}..if 
2530: 7b 5b 6f 70 74 2d 62 6f 6f 6c 20 66 6f 73 73 69  {[opt-bool fossi
2540: 6c 2d 64 65 62 75 67 5d 7d 20 7b 0a 20 20 20 20  l-debug]} {.    
2550: 64 65 66 69 6e 65 20 43 46 4c 41 47 53 20 7b 2d  define CFLAGS {-
2560: 67 20 2d 4f 30 20 2d 57 61 6c 6c 7d 0a 20 20 20  g -O0 -Wall}.   
2570: 20 64 65 66 69 6e 65 2d 61 70 70 65 6e 64 20 43   define-append C
2580: 46 4c 41 47 53 20 2d 44 46 4f 53 53 49 4c 5f 44  FLAGS -DFOSSIL_D
2590: 45 42 55 47 0a 20 20 20 20 6d 73 67 2d 72 65 73  EBUG.    msg-res
25a0: 75 6c 74 20 22 44 65 62 75 67 67 69 6e 67 20 73  ult "Debugging s
25b0: 75 70 70 6f 72 74 20 65 6e 61 62 6c 65 64 22 0a  upport enabled".
25c0: 7d 0a 0a 69 66 20 7b 5b 6f 70 74 2d 62 6f 6f 6c  }..if {[opt-bool
25d0: 20 6e 6f 2d 6f 70 74 5d 7d 20 7b 0a 20 20 20 20   no-opt]} {.    
25e0: 64 65 66 69 6e 65 20 43 46 4c 41 47 53 20 7b 2d  define CFLAGS {-
25f0: 67 20 2d 4f 30 20 2d 57 61 6c 6c 7d 0a 20 20 20  g -O0 -Wall}.   
2600: 20 6d 73 67 2d 72 65 73 75 6c 74 20 22 42 75 69   msg-result "Bui
2610: 6c 74 69 6e 67 20 77 69 74 68 6f 75 74 20 63 6f  lting without co
2620: 6d 70 69 6c 65 72 20 6f 70 74 69 6d 69 7a 61 74  mpiler optimizat
2630: 69 6f 6e 22 0a 20 20 20 20 69 66 20 7b 5b 6f 70  ion".    if {[op
2640: 74 2d 62 6f 6f 6c 20 66 6f 73 73 69 6c 2d 64 65  t-bool fossil-de
2650: 62 75 67 5d 7d 20 7b 0a 20 20 20 20 20 20 20 20  bug]} {.        
2660: 64 65 66 69 6e 65 2d 61 70 70 65 6e 64 20 43 46  define-append CF
2670: 4c 41 47 53 20 2d 44 46 4f 53 53 49 4c 5f 44 45  LAGS -DFOSSIL_DE
2680: 42 55 47 0a 20 20 20 20 7d 0a 7d 0a 0a 69 66 20  BUG.    }.}..if 
2690: 7b 5b 6f 70 74 2d 62 6f 6f 6c 20 77 69 74 68 2d  {[opt-bool with-
26a0: 6d 6d 61 6e 5d 7d 20 7b 0a 20 20 20 20 64 65 66  mman]} {.    def
26b0: 69 6e 65 2d 61 70 70 65 6e 64 20 45 58 54 52 41  ine-append EXTRA
26c0: 5f 43 46 4c 41 47 53 20 2d 44 55 53 45 5f 4d 4d  _CFLAGS -DUSE_MM
26d0: 41 4e 5f 48 0a 20 20 20 20 64 65 66 69 6e 65 20  AN_H.    define 
26e0: 55 53 45 5f 4d 4d 41 4e 5f 48 20 31 0a 20 20 20  USE_MMAN_H 1.   
26f0: 20 6d 73 67 2d 72 65 73 75 6c 74 20 22 45 6e 61   msg-result "Ena
2700: 62 6c 69 6e 67 20 5c 22 73 79 73 2f 6d 6d 61 6e  bling \"sys/mman
2710: 2e 68 5c 22 20 73 75 70 70 6f 72 74 22 0a 7d 0a  .h\" support".}.
2720: 0a 69 66 20 7b 5b 6f 70 74 2d 62 6f 6f 6c 20 77  .if {[opt-bool w
2730: 69 74 68 2d 73 65 65 5d 7d 20 7b 0a 20 20 20 20  ith-see]} {.    
2740: 64 65 66 69 6e 65 2d 61 70 70 65 6e 64 20 45 58  define-append EX
2750: 54 52 41 5f 43 46 4c 41 47 53 20 2d 44 55 53 45  TRA_CFLAGS -DUSE
2760: 5f 53 45 45 0a 20 20 20 20 64 65 66 69 6e 65 20  _SEE.    define 
2770: 55 53 45 5f 53 45 45 20 31 0a 20 20 20 20 64 65  USE_SEE 1.    de
2780: 66 69 6e 65 20 53 51 4c 49 54 45 33 5f 4f 52 49  fine SQLITE3_ORI
2790: 47 49 4e 20 31 0a 20 20 20 20 6d 73 67 2d 72 65  GIN 1.    msg-re
27a0: 73 75 6c 74 20 22 45 6e 61 62 6c 69 6e 67 20 65  sult "Enabling e
27b0: 6e 63 72 79 70 74 69 6f 6e 20 73 75 70 70 6f 72  ncryption suppor
27c0: 74 22 0a 7d 0a 0a 69 66 20 7b 5b 6f 70 74 2d 62  t".}..if {[opt-b
27d0: 6f 6f 6c 20 6a 73 6f 6e 5d 7d 20 7b 0a 20 20 20  ool json]} {.   
27e0: 20 23 20 52 65 6d 69 6e 64 65 72 2f 46 49 58 4d   # Reminder/FIXM
27f0: 45 20 28 73 74 65 70 68 61 6e 29 3a 20 46 4f 53  E (stephan): FOS
2800: 53 49 4c 5f 45 4e 41 42 4c 45 5f 4a 53 4f 4e 0a  SIL_ENABLE_JSON.
2810: 20 20 20 20 23 20 69 73 20 72 65 71 75 69 72 65      # is require
2820: 64 20 69 6e 20 74 68 65 20 43 46 4c 41 47 53 20  d in the CFLAGS 
2830: 62 65 63 61 75 73 65 20 6a 73 6f 6e 2a 2e 63 0a  because json*.c.
2840: 20 20 20 20 23 20 68 61 76 65 20 23 69 66 64 65      # have #ifde
2850: 66 20 67 75 61 72 64 73 20 61 72 6f 75 6e 64 20  f guards around 
2860: 74 68 65 20 77 68 6f 6c 65 20 66 69 6c 65 20 77  the whole file w
2870: 69 74 68 6f 75 74 0a 20 20 20 20 23 20 72 65 61  ithout.    # rea
2880: 64 69 6e 67 20 63 6f 6e 66 69 67 2e 68 20 66 69  ding config.h fi
2890: 72 73 74 2e 0a 20 20 20 20 64 65 66 69 6e 65 2d  rst..    define-
28a0: 61 70 70 65 6e 64 20 45 58 54 52 41 5f 43 46 4c  append EXTRA_CFL
28b0: 41 47 53 20 2d 44 46 4f 53 53 49 4c 5f 45 4e 41  AGS -DFOSSIL_ENA
28c0: 42 4c 45 5f 4a 53 4f 4e 0a 20 20 20 20 64 65 66  BLE_JSON.    def
28d0: 69 6e 65 20 46 4f 53 53 49 4c 5f 45 4e 41 42 4c  ine FOSSIL_ENABL
28e0: 45 5f 4a 53 4f 4e 0a 20 20 20 20 6d 73 67 2d 72  E_JSON.    msg-r
28f0: 65 73 75 6c 74 20 22 4a 53 4f 4e 20 73 75 70 70  esult "JSON supp
2900: 6f 72 74 20 65 6e 61 62 6c 65 64 22 0a 7d 0a 0a  ort enabled".}..
2910: 69 66 20 7b 5b 6f 70 74 2d 62 6f 6f 6c 20 77 69  if {[opt-bool wi
2920: 74 68 2d 65 78 65 63 2d 72 65 6c 2d 70 61 74 68  th-exec-rel-path
2930: 73 5d 7d 20 7b 0a 20 20 20 20 64 65 66 69 6e 65  s]} {.    define
2940: 2d 61 70 70 65 6e 64 20 45 58 54 52 41 5f 43 46  -append EXTRA_CF
2950: 4c 41 47 53 20 2d 44 46 4f 53 53 49 4c 5f 45 4e  LAGS -DFOSSIL_EN
2960: 41 42 4c 45 5f 45 58 45 43 5f 52 45 4c 5f 50 41  ABLE_EXEC_REL_PA
2970: 54 48 53 0a 20 20 20 20 64 65 66 69 6e 65 20 46  THS.    define F
2980: 4f 53 53 49 4c 5f 45 4e 41 42 4c 45 5f 45 58 45  OSSIL_ENABLE_EXE
2990: 43 5f 52 45 4c 5f 50 41 54 48 53 0a 20 20 20 20  C_REL_PATHS.    
29a0: 6d 73 67 2d 72 65 73 75 6c 74 20 22 52 65 6c 61  msg-result "Rela
29b0: 74 69 76 65 20 70 61 74 68 73 20 69 6e 20 65 78  tive paths in ex
29c0: 74 65 72 6e 61 6c 20 64 69 66 66 2f 67 64 69 66  ternal diff/gdif
29d0: 66 20 65 6e 61 62 6c 65 64 22 0a 7d 0a 0a 69 66  f enabled".}..if
29e0: 20 7b 5b 6f 70 74 2d 62 6f 6f 6c 20 77 69 74 68   {[opt-bool with
29f0: 2d 74 68 31 2d 64 6f 63 73 5d 7d 20 7b 0a 20 20  -th1-docs]} {.  
2a00: 20 20 64 65 66 69 6e 65 2d 61 70 70 65 6e 64 20    define-append 
2a10: 45 58 54 52 41 5f 43 46 4c 41 47 53 20 2d 44 46  EXTRA_CFLAGS -DF
2a20: 4f 53 53 49 4c 5f 45 4e 41 42 4c 45 5f 54 48 31  OSSIL_ENABLE_TH1
2a30: 5f 44 4f 43 53 0a 20 20 20 20 64 65 66 69 6e 65  _DOCS.    define
2a40: 20 46 4f 53 53 49 4c 5f 45 4e 41 42 4c 45 5f 54   FOSSIL_ENABLE_T
2a50: 48 31 5f 44 4f 43 53 0a 20 20 20 20 6d 73 67 2d  H1_DOCS.    msg-
2a60: 72 65 73 75 6c 74 20 22 54 48 31 20 65 6d 62 65  result "TH1 embe
2a70: 64 64 65 64 20 64 6f 63 75 6d 65 6e 74 61 74 69  dded documentati
2a80: 6f 6e 20 73 75 70 70 6f 72 74 20 65 6e 61 62 6c  on support enabl
2a90: 65 64 22 0a 7d 0a 0a 69 66 20 7b 5b 6f 70 74 2d  ed".}..if {[opt-
2aa0: 62 6f 6f 6c 20 77 69 74 68 2d 74 68 31 2d 68 6f  bool with-th1-ho
2ab0: 6f 6b 73 5d 7d 20 7b 0a 20 20 20 20 64 65 66 69  oks]} {.    defi
2ac0: 6e 65 2d 61 70 70 65 6e 64 20 45 58 54 52 41 5f  ne-append EXTRA_
2ad0: 43 46 4c 41 47 53 20 2d 44 46 4f 53 53 49 4c 5f  CFLAGS -DFOSSIL_
2ae0: 45 4e 41 42 4c 45 5f 54 48 31 5f 48 4f 4f 4b 53  ENABLE_TH1_HOOKS
2af0: 0a 20 20 20 20 64 65 66 69 6e 65 20 46 4f 53 53  .    define FOSS
2b00: 49 4c 5f 45 4e 41 42 4c 45 5f 54 48 31 5f 48 4f  IL_ENABLE_TH1_HO
2b10: 4f 4b 53 0a 20 20 20 20 6d 73 67 2d 72 65 73 75  OKS.    msg-resu
2b20: 6c 74 20 22 54 48 31 20 68 6f 6f 6b 73 20 73 75  lt "TH1 hooks su
2b30: 70 70 6f 72 74 20 65 6e 61 62 6c 65 64 22 0a 7d  pport enabled".}
2b40: 0a 0a 23 69 66 20 7b 5b 6f 70 74 2d 62 6f 6f 6c  ..#if {[opt-bool
2b50: 20 6d 61 72 6b 64 6f 77 6e 5d 7d 20 7b 0a 23 20   markdown]} {.# 
2b60: 20 20 20 23 20 6e 6f 2d 6f 70 2e 20 20 4d 61 72     # no-op.  Mar
2b70: 6b 64 6f 77 6e 20 69 73 20 6e 6f 77 20 65 6e 61  kdown is now ena
2b80: 62 6c 65 64 20 62 79 20 64 65 66 61 75 6c 74 2e  bled by default.
2b90: 0a 23 20 20 20 20 6d 73 67 2d 72 65 73 75 6c 74  .#    msg-result
2ba0: 20 22 4d 61 72 6b 64 6f 77 6e 20 73 75 70 70 6f   "Markdown suppo
2bb0: 72 74 20 65 6e 61 62 6c 65 64 22 0a 23 7d 0a 0a  rt enabled".#}..
2bc0: 69 66 20 7b 5b 6f 70 74 2d 62 6f 6f 6c 20 73 74  if {[opt-bool st
2bd0: 61 74 69 63 5d 7d 20 7b 0a 20 20 20 20 23 20 58  atic]} {.    # X
2be0: 58 58 3a 20 54 68 69 73 20 77 69 6c 6c 20 6e 6f  XX: This will no
2bf0: 74 20 77 6f 72 6b 20 6f 6e 20 61 6c 6c 20 73 79  t work on all sy
2c00: 73 74 65 6d 73 2e 0a 20 20 20 20 64 65 66 69 6e  stems..    defin
2c10: 65 2d 61 70 70 65 6e 64 20 45 58 54 52 41 5f 4c  e-append EXTRA_L
2c20: 44 46 4c 41 47 53 20 2d 73 74 61 74 69 63 0a 20  DFLAGS -static. 
2c30: 20 20 20 6d 73 67 2d 72 65 73 75 6c 74 20 22 54     msg-result "T
2c40: 72 79 69 6e 67 20 74 6f 20 6c 69 6e 6b 20 73 74  rying to link st
2c50: 61 74 69 63 61 6c 6c 79 22 0a 7d 20 65 6c 73 65  atically".} else
2c60: 20 7b 0a 20 20 20 20 64 65 66 69 6e 65 2d 61 70   {.    define-ap
2c70: 70 65 6e 64 20 45 58 54 52 41 5f 43 46 4c 41 47  pend EXTRA_CFLAG
2c80: 53 20 2d 44 46 4f 53 53 49 4c 5f 44 59 4e 41 4d  S -DFOSSIL_DYNAM
2c90: 49 43 5f 42 55 49 4c 44 3d 31 0a 20 20 20 20 64  IC_BUILD=1.    d
2ca0: 65 66 69 6e 65 20 46 4f 53 53 49 4c 5f 44 59 4e  efine FOSSIL_DYN
2cb0: 41 4d 49 43 5f 42 55 49 4c 44 0a 7d 0a 0a 23 20  AMIC_BUILD.}..# 
2cc0: 43 68 65 63 6b 20 66 6f 72 20 6c 69 62 72 61 72  Check for librar
2cd0: 69 65 73 20 74 68 61 74 20 6e 65 65 64 20 74 6f  ies that need to
2ce0: 20 62 65 20 73 6f 72 74 65 64 20 6f 75 74 20 65   be sorted out e
2cf0: 61 72 6c 79 0a 63 63 2d 63 68 65 63 6b 2d 66 75  arly.cc-check-fu
2d00: 6e 63 74 69 6f 6e 2d 69 6e 2d 6c 69 62 20 69 63  nction-in-lib ic
2d10: 6f 6e 76 20 69 63 6f 6e 76 0a 0a 23 20 48 65 6c  onv iconv..# Hel
2d20: 70 65 72 20 66 6f 72 20 4f 70 65 6e 53 53 4c 20  per for OpenSSL 
2d30: 63 68 65 63 6b 69 6e 67 0a 70 72 6f 63 20 63 68  checking.proc ch
2d40: 65 63 6b 2d 66 6f 72 2d 6f 70 65 6e 73 73 6c 20  eck-for-openssl 
2d50: 7b 6d 73 67 20 7b 63 66 6c 61 67 73 20 7b 7d 7d  {msg {cflags {}}
2d60: 20 7b 6c 69 62 73 20 7b 2d 6c 73 73 6c 20 2d 6c   {libs {-lssl -l
2d70: 63 72 79 70 74 6f 20 2d 6c 70 74 68 72 65 61 64  crypto -lpthread
2d80: 7d 7d 7d 20 7b 0a 20 20 20 20 6d 73 67 2d 63 68  }}} {.    msg-ch
2d90: 65 63 6b 69 6e 67 20 22 43 68 65 63 6b 69 6e 67  ecking "Checking
2da0: 20 66 6f 72 20 24 6d 73 67 2e 2e 2e 22 0a 20 20   for $msg...".  
2db0: 20 20 73 65 74 20 72 63 20 30 0a 20 20 20 20 69    set rc 0.    i
2dc0: 66 20 7b 5b 69 73 5f 6d 69 6e 67 77 5d 7d 20 7b  f {[is_mingw]} {
2dd0: 0a 20 20 20 20 20 20 20 20 6c 61 70 70 65 6e 64  .        lappend
2de0: 20 6c 69 62 73 20 2d 6c 67 64 69 33 32 20 2d 6c   libs -lgdi32 -l
2df0: 77 73 6f 63 6b 33 32 20 2d 6c 63 72 79 70 74 33  wsock32 -lcrypt3
2e00: 32 0a 20 20 20 20 7d 0a 20 20 20 20 69 66 20 7b  2.    }.    if {
2e10: 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 3a 3a 7a  [info exists ::z
2e20: 6c 69 62 5f 6c 69 62 5d 7d 20 7b 0a 20 20 20 20  lib_lib]} {.    
2e30: 20 20 20 20 6c 61 70 70 65 6e 64 20 6c 69 62 73      lappend libs
2e40: 20 24 3a 3a 7a 6c 69 62 5f 6c 69 62 0a 20 20 20   $::zlib_lib.   
2e50: 20 7d 0a 20 20 20 20 6d 73 67 2d 71 75 69 65 74   }.    msg-quiet
2e60: 20 63 63 2d 77 69 74 68 20 5b 6c 69 73 74 20 2d   cc-with [list -
2e70: 63 66 6c 61 67 73 20 24 63 66 6c 61 67 73 20 2d  cflags $cflags -
2e80: 6c 69 62 73 20 24 6c 69 62 73 5d 20 7b 0a 20 20  libs $libs] {.  
2e90: 20 20 20 20 20 20 69 66 20 7b 5b 63 63 2d 63 68        if {[cc-ch
2ea0: 65 63 6b 2d 69 6e 63 6c 75 64 65 73 20 6f 70 65  eck-includes ope
2eb0: 6e 73 73 6c 2f 73 73 6c 2e 68 5d 20 26 26 20 5c  nssl/ssl.h] && \
2ec0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
2ed0: 20 5b 63 63 2d 63 68 65 63 6b 2d 66 75 6e 63 74   [cc-check-funct
2ee0: 69 6f 6e 73 20 53 53 4c 5f 6e 65 77 5d 7d 20 7b  ions SSL_new]} {
2ef0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 63  .            inc
2f00: 72 20 72 63 0a 20 20 20 20 20 20 20 20 7d 0a 20  r rc.        }. 
2f10: 20 20 20 7d 0a 20 20 20 20 69 66 20 7b 21 24 72     }.    if {!$r
2f20: 63 20 26 26 20 21 5b 69 73 5f 6d 69 6e 67 77 5d  c && ![is_mingw]
2f30: 7d 20 7b 0a 20 20 20 20 20 20 20 20 23 20 4f 6e  } {.        # On
2f40: 20 73 6f 6d 65 20 73 79 73 74 65 6d 73 2c 20 4f   some systems, O
2f50: 70 65 6e 53 53 4c 20 61 70 70 65 61 72 73 20 74  penSSL appears t
2f60: 6f 20 72 65 71 75 69 72 65 20 2d 6c 64 6c 20 74  o require -ldl t
2f70: 6f 20 6c 69 6e 6b 2e 0a 20 20 20 20 20 20 20 20  o link..        
2f80: 6c 61 70 70 65 6e 64 20 6c 69 62 73 20 2d 6c 64  lappend libs -ld
2f90: 6c 0a 20 20 20 20 20 20 20 20 6d 73 67 2d 71 75  l.        msg-qu
2fa0: 69 65 74 20 63 63 2d 77 69 74 68 20 5b 6c 69 73  iet cc-with [lis
2fb0: 74 20 2d 63 66 6c 61 67 73 20 24 63 66 6c 61 67  t -cflags $cflag
2fc0: 73 20 2d 6c 69 62 73 20 24 6c 69 62 73 5d 20 7b  s -libs $libs] {
2fd0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20  .            if 
2fe0: 7b 5b 63 63 2d 63 68 65 63 6b 2d 69 6e 63 6c 75  {[cc-check-inclu
2ff0: 64 65 73 20 6f 70 65 6e 73 73 6c 2f 73 73 6c 2e  des openssl/ssl.
3000: 68 5d 20 26 26 20 5c 0a 20 20 20 20 20 20 20 20  h] && \.        
3010: 20 20 20 20 20 20 20 20 20 20 20 20 5b 63 63 2d              [cc-
3020: 63 68 65 63 6b 2d 66 75 6e 63 74 69 6f 6e 73 20  check-functions 
3030: 53 53 4c 5f 6e 65 77 5d 7d 20 7b 0a 20 20 20 20  SSL_new]} {.    
3040: 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 63 72              incr
3050: 20 72 63 0a 20 20 20 20 20 20 20 20 20 20 20 20   rc.            
3060: 7d 0a 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20  }.        }.    
3070: 7d 0a 20 20 20 20 69 66 20 7b 24 72 63 7d 20 7b  }.    if {$rc} {
3080: 0a 20 20 20 20 20 20 20 20 6d 73 67 2d 72 65 73  .        msg-res
3090: 75 6c 74 20 22 6f 6b 22 0a 20 20 20 20 20 20 20  ult "ok".       
30a0: 20 72 65 74 75 72 6e 20 31 0a 20 20 20 20 7d 20   return 1.    } 
30b0: 65 6c 73 65 20 7b 0a 20 20 20 20 20 20 20 20 6d  else {.        m
30c0: 73 67 2d 72 65 73 75 6c 74 20 22 6e 6f 22 0a 20  sg-result "no". 
30d0: 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 30 0a         return 0.
30e0: 20 20 20 20 7d 0a 7d 0a 0a 23 20 43 68 65 63 6b      }.}..# Check
30f0: 20 66 6f 72 20 7a 6c 69 62 2c 20 75 73 69 6e 67   for zlib, using
3100: 20 74 68 65 20 67 69 76 65 6e 20 6c 6f 63 61 74   the given locat
3110: 69 6f 6e 20 69 66 20 73 70 65 63 69 66 69 65 64  ion if specified
3120: 0a 73 65 74 20 7a 6c 69 62 70 61 74 68 20 5b 6f  .set zlibpath [o
3130: 70 74 2d 76 61 6c 20 77 69 74 68 2d 7a 6c 69 62  pt-val with-zlib
3140: 5d 0a 69 66 20 7b 24 7a 6c 69 62 70 61 74 68 20  ].if {$zlibpath 
3150: 65 71 20 22 74 72 65 65 22 7d 20 7b 0a 20 20 73  eq "tree"} {.  s
3160: 65 74 20 7a 6c 69 62 64 69 72 20 5b 66 69 6c 65  et zlibdir [file
3170: 20 64 69 72 6e 61 6d 65 20 24 61 75 74 6f 73 65   dirname $autose
3180: 74 75 70 28 64 69 72 29 5d 2f 63 6f 6d 70 61 74  tup(dir)]/compat
3190: 2f 7a 6c 69 62 0a 20 20 69 66 20 7b 21 5b 66 69  /zlib.  if {![fi
31a0: 6c 65 20 69 73 64 69 72 65 63 74 6f 72 79 20 24  le isdirectory $
31b0: 7a 6c 69 62 64 69 72 5d 7d 20 7b 0a 20 20 20 20  zlibdir]} {.    
31c0: 75 73 65 72 2d 65 72 72 6f 72 20 22 54 68 65 20  user-error "The 
31d0: 7a 6c 69 62 20 69 6e 20 73 6f 75 72 63 65 20 74  zlib in source t
31e0: 72 65 65 20 64 69 72 65 63 74 6f 72 79 20 64 6f  ree directory do
31f0: 65 73 20 6e 6f 74 20 65 78 69 73 74 22 0a 20 20  es not exist".  
3200: 7d 20 65 6c 73 65 69 66 20 7b 20 28 5b 6c 6c 65  } elseif { ([lle
3210: 6e 67 74 68 20 5b 67 6c 6f 62 20 2d 6e 6f 63 6f  ngth [glob -noco
3220: 6d 70 6c 61 69 6e 20 2d 64 69 72 65 63 74 6f 72  mplain -director
3230: 79 20 24 7a 6c 69 62 64 69 72 20 6c 69 62 7a 2a  y $zlibdir libz*
3240: 5d 5d 20 3d 3d 20 30 29 20 7d 20 7b 0a 20 20 20  ]] == 0) } {.   
3250: 20 75 73 65 72 2d 65 72 72 6f 72 20 22 57 69 74   user-error "Wit
3260: 68 20 2d 2d 77 69 74 68 2d 7a 6c 69 62 3d 74 72  h --with-zlib=tr
3270: 65 65 2c 20 24 7a 6c 69 62 64 69 72 20 6d 75 73  ee, $zlibdir mus
3280: 74 20 62 65 20 63 6f 6e 66 69 67 75 72 65 64 20  t be configured 
3290: 61 6e 64 20 62 75 69 6c 74 20 66 69 72 73 74 2e  and built first.
32a0: 22 0a 20 20 7d 0a 20 20 63 63 2d 77 69 74 68 20  ".  }.  cc-with 
32b0: 5b 6c 69 73 74 20 2d 63 66 6c 61 67 73 20 22 2d  [list -cflags "-
32c0: 49 24 7a 6c 69 62 64 69 72 20 2d 4c 24 7a 6c 69  I$zlibdir -L$zli
32d0: 62 64 69 72 22 5d 0a 20 20 64 65 66 69 6e 65 2d  bdir"].  define-
32e0: 61 70 70 65 6e 64 20 45 58 54 52 41 5f 43 46 4c  append EXTRA_CFL
32f0: 41 47 53 20 2d 49 24 7a 6c 69 62 64 69 72 0a 20  AGS -I$zlibdir. 
3300: 20 64 65 66 69 6e 65 2d 61 70 70 65 6e 64 20 4c   define-append L
3310: 49 42 53 20 24 7a 6c 69 62 64 69 72 2f 6c 69 62  IBS $zlibdir/lib
3320: 7a 2e 61 0a 20 20 73 65 74 20 3a 3a 7a 6c 69 62  z.a.  set ::zlib
3330: 5f 6c 69 62 20 24 7a 6c 69 62 64 69 72 2f 6c 69  _lib $zlibdir/li
3340: 62 7a 2e 61 0a 20 20 6d 73 67 2d 72 65 73 75 6c  bz.a.  msg-resul
3350: 74 20 22 55 73 69 6e 67 20 7a 6c 69 62 20 69 6e  t "Using zlib in
3360: 20 73 6f 75 72 63 65 20 74 72 65 65 22 0a 7d 20   source tree".} 
3370: 65 6c 73 65 20 7b 0a 20 20 73 65 74 20 63 66 74  else {.  set cft
3380: 72 79 20 7b 22 22 7d 0a 20 20 73 65 74 20 6c 64  ry {""}.  set ld
3390: 74 72 79 20 7b 22 22 7d 0a 20 20 69 66 20 7b 24  try {""}.  if {$
33a0: 7a 6c 69 62 70 61 74 68 20 6e 69 20 7b 61 75 74  zlibpath ni {aut
33b0: 6f 20 22 22 7d 7d 20 7b 0a 20 20 20 20 6c 61 70  o ""}} {.    lap
33c0: 70 65 6e 64 20 63 66 74 72 79 20 22 2d 49 24 7a  pend cftry "-I$z
33d0: 6c 69 62 70 61 74 68 22 0a 20 20 20 20 6c 61 70  libpath".    lap
33e0: 70 65 6e 64 20 63 66 74 72 79 20 22 2d 49 24 7a  pend cftry "-I$z
33f0: 6c 69 62 70 61 74 68 2f 69 6e 63 6c 75 64 65 22  libpath/include"
3400: 0a 20 20 20 20 6c 61 70 70 65 6e 64 20 6c 64 74  .    lappend ldt
3410: 72 79 20 22 2d 4c 24 7a 6c 69 62 70 61 74 68 22  ry "-L$zlibpath"
3420: 0a 20 20 20 20 6c 61 70 70 65 6e 64 20 6c 64 74  .    lappend ldt
3430: 72 79 20 22 2d 4c 24 7a 6c 69 62 70 61 74 68 2f  ry "-L$zlibpath/
3440: 6c 69 62 22 0a 20 20 7d 0a 0a 20 20 23 20 52 65  lib".  }..  # Re
3450: 76 65 72 73 65 20 74 68 65 20 6c 69 73 74 20 6f  verse the list o
3460: 66 20 74 65 73 74 73 20 73 6f 20 77 65 20 63 68  f tests so we ch
3470: 65 63 6b 20 6d 6f 73 74 2d 73 70 65 63 69 66 69  eck most-specifi
3480: 63 20 74 6f 20 6c 65 61 73 74 2c 20 65 6c 73 65  c to least, else
3490: 0a 20 20 23 20 70 6c 61 74 66 6f 72 6d 20 64 65  .  # platform de
34a0: 76 65 6c 20 66 69 6c 65 73 20 77 69 6c 6c 20 73  vel files will s
34b0: 68 61 64 6f 77 20 6c 6f 63 61 6c 20 2d 2d 77 69  hadow local --wi
34c0: 74 68 2d 7a 6c 69 62 20 6f 76 65 72 72 69 64 65  th-zlib override
34d0: 73 2e 0a 20 20 66 6f 72 65 61 63 68 20 63 20 5b  s..  foreach c [
34e0: 6c 72 65 76 65 72 73 65 20 24 63 66 74 72 79 5d  lreverse $cftry]
34f0: 20 7b 0a 20 20 20 20 69 66 20 7b 5b 63 63 2d 77   {.    if {[cc-w
3500: 69 74 68 20 5b 6c 69 73 74 20 2d 63 66 6c 61 67  ith [list -cflag
3510: 73 20 24 63 5d 20 7b 63 63 2d 63 68 65 63 6b 2d  s $c] {cc-check-
3520: 69 6e 63 6c 75 64 65 73 20 7a 6c 69 62 2e 68 7d  includes zlib.h}
3530: 5d 7d 20 7b 0a 20 20 20 20 20 20 69 66 20 7b 24  ]} {.      if {$
3540: 63 20 65 71 20 22 22 7d 20 7b 0a 20 20 20 20 20  c eq ""} {.     
3550: 20 20 20 6d 73 67 2d 72 65 73 75 6c 74 20 22 46     msg-result "F
3560: 6f 75 6e 64 20 7a 6c 69 62 2e 68 20 69 6e 20 64  ound zlib.h in d
3570: 65 66 61 75 6c 74 20 69 6e 63 6c 75 64 65 20 70  efault include p
3580: 61 74 68 22 0a 20 20 20 20 20 20 7d 20 65 6c 73  ath".      } els
3590: 65 20 7b 0a 20 20 20 20 20 20 20 20 64 65 66 69  e {.        defi
35a0: 6e 65 2d 61 70 70 65 6e 64 20 45 58 54 52 41 5f  ne-append EXTRA_
35b0: 43 46 4c 41 47 53 20 22 24 63 22 0a 20 20 20 20  CFLAGS "$c".    
35c0: 20 20 20 20 6d 73 67 2d 72 65 73 75 6c 74 20 22      msg-result "
35d0: 46 6f 75 6e 64 20 7a 6c 69 62 2e 68 20 76 69 61  Found zlib.h via
35e0: 20 24 63 22 0a 20 20 20 20 20 20 7d 0a 20 20 20   $c".      }.   
35f0: 20 20 20 73 65 74 20 63 66 6f 75 6e 64 20 24 63     set cfound $c
3600: 0a 20 20 20 20 20 20 62 72 65 61 6b 0a 20 20 20  .      break.   
3610: 20 7d 0a 20 20 7d 0a 20 20 69 66 20 7b 21 5b 69   }.  }.  if {![i
3620: 6e 66 6f 20 65 78 69 73 74 73 20 63 66 6f 75 6e  nfo exists cfoun
3630: 64 5d 7d 20 7b 0a 20 20 20 20 75 73 65 72 2d 65  d]} {.    user-e
3640: 72 72 6f 72 20 22 7a 6c 69 62 2e 68 20 6e 6f 74  rror "zlib.h not
3650: 20 66 6f 75 6e 64 3b 20 65 69 74 68 65 72 20 69   found; either i
3660: 6e 73 74 61 6c 6c 20 69 74 20 6f 72 20 73 70 65  nstall it or spe
3670: 63 69 66 79 20 69 74 73 20 6c 6f 63 61 74 69 6f  cify its locatio
3680: 6e 20 76 69 61 20 2d 2d 77 69 74 68 2d 7a 6c 69  n via --with-zli
3690: 62 22 0a 20 20 7d 0a 20 20 66 6f 72 65 61 63 68  b".  }.  foreach
36a0: 20 6c 63 68 65 63 6b 20 5b 6c 72 65 76 65 72 73   lcheck [lrevers
36b0: 65 20 24 6c 64 74 72 79 5d 20 7b 0a 20 20 20 20  e $ldtry] {.    
36c0: 69 66 20 7b 5b 63 63 2d 77 69 74 68 20 5b 6c 69  if {[cc-with [li
36d0: 73 74 20 2d 63 66 6c 61 67 73 20 22 24 63 66 6f  st -cflags "$cfo
36e0: 75 6e 64 20 24 6c 63 68 65 63 6b 22 5d 20 7b 63  und $lcheck"] {c
36f0: 68 65 63 6b 2d 66 75 6e 63 74 69 6f 6e 2d 69 6e  heck-function-in
3700: 2d 6c 69 62 20 69 6e 66 6c 61 74 65 45 6e 64 20  -lib inflateEnd 
3710: 7a 7d 5d 7d 20 7b 0a 20 20 20 20 20 20 69 66 20  z}]} {.      if 
3720: 7b 24 6c 63 68 65 63 6b 20 65 71 20 22 22 7d 20  {$lcheck eq ""} 
3730: 7b 0a 20 20 20 20 20 20 20 20 6d 73 67 2d 72 65  {.        msg-re
3740: 73 75 6c 74 20 22 4c 69 6e 6b 65 64 20 74 6f 20  sult "Linked to 
3750: 7a 6c 69 62 20 76 69 61 20 64 65 66 61 75 6c 74  zlib via default
3760: 20 6c 69 62 72 61 72 79 20 70 61 74 68 22 0a 20   library path". 
3770: 20 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 20 20       } else {.  
3780: 20 20 20 20 20 20 64 65 66 69 6e 65 2d 61 70 70        define-app
3790: 65 6e 64 20 45 58 54 52 41 5f 4c 44 46 4c 41 47  end EXTRA_LDFLAG
37a0: 53 20 22 24 6c 63 68 65 63 6b 22 0a 20 20 20 20  S "$lcheck".    
37b0: 20 20 20 20 6d 73 67 2d 72 65 73 75 6c 74 20 22      msg-result "
37c0: 4c 69 6e 6b 65 64 20 74 6f 20 7a 6c 69 62 20 76  Linked to zlib v
37d0: 69 61 20 24 6c 63 68 65 63 6b 22 0a 20 20 20 20  ia $lcheck".    
37e0: 20 20 7d 0a 20 20 20 20 20 20 62 72 65 61 6b 0a    }.      break.
37f0: 20 20 20 20 7d 0a 20 20 7d 0a 20 20 73 65 74 20      }.  }.  set 
3800: 3a 3a 7a 6c 69 62 5f 6c 69 62 20 2d 6c 7a 0a 7d  ::zlib_lib -lz.}
3810: 0a 0a 73 65 74 20 73 73 6c 64 69 72 73 20 5b 6f  ..set ssldirs [o
3820: 70 74 2d 76 61 6c 20 77 69 74 68 2d 6f 70 65 6e  pt-val with-open
3830: 73 73 6c 5d 0a 69 66 20 7b 24 73 73 6c 64 69 72  ssl].if {$ssldir
3840: 73 20 6e 65 20 22 6e 6f 6e 65 22 7d 20 7b 0a 20  s ne "none"} {. 
3850: 20 20 20 73 65 74 20 66 6f 75 6e 64 20 30 0a 20     set found 0. 
3860: 20 20 20 69 66 20 7b 24 73 73 6c 64 69 72 73 20     if {$ssldirs 
3870: 65 71 20 22 74 72 65 65 22 7d 20 7b 0a 20 20 20  eq "tree"} {.   
3880: 20 20 20 20 20 73 65 74 20 73 73 6c 64 69 72 20       set ssldir 
3890: 5b 66 69 6c 65 20 64 69 72 6e 61 6d 65 20 24 61  [file dirname $a
38a0: 75 74 6f 73 65 74 75 70 28 64 69 72 29 5d 2f 63  utosetup(dir)]/c
38b0: 6f 6d 70 61 74 2f 6f 70 65 6e 73 73 6c 0a 20 20  ompat/openssl.  
38c0: 20 20 20 20 20 20 69 66 20 7b 21 5b 66 69 6c 65        if {![file
38d0: 20 69 73 64 69 72 65 63 74 6f 72 79 20 24 73 73   isdirectory $ss
38e0: 6c 64 69 72 5d 7d 20 7b 0a 20 20 20 20 20 20 20  ldir]} {.       
38f0: 20 20 20 20 20 75 73 65 72 2d 65 72 72 6f 72 20       user-error 
3900: 22 54 68 65 20 4f 70 65 6e 53 53 4c 20 69 6e 20  "The OpenSSL in 
3910: 73 6f 75 72 63 65 20 74 72 65 65 20 64 69 72 65  source tree dire
3920: 63 74 6f 72 79 20 64 6f 65 73 20 6e 6f 74 20 65  ctory does not e
3930: 78 69 73 74 22 0a 20 20 20 20 20 20 20 20 7d 0a  xist".        }.
3940: 20 20 20 20 20 20 20 20 73 65 74 20 6d 73 67 20          set msg 
3950: 22 73 73 6c 20 69 6e 20 24 73 73 6c 64 69 72 22  "ssl in $ssldir"
3960: 0a 20 20 20 20 20 20 20 20 73 65 74 20 63 66 6c  .        set cfl
3970: 61 67 73 20 22 2d 49 24 73 73 6c 64 69 72 2f 69  ags "-I$ssldir/i
3980: 6e 63 6c 75 64 65 22 0a 20 20 20 20 20 20 20 20  nclude".        
3990: 73 65 74 20 6c 64 66 6c 61 67 73 20 22 2d 4c 24  set ldflags "-L$
39a0: 73 73 6c 64 69 72 22 0a 20 20 20 20 20 20 20 20  ssldir".        
39b0: 73 65 74 20 73 73 6c 6c 69 62 73 20 22 24 73 73  set ssllibs "$ss
39c0: 6c 64 69 72 2f 6c 69 62 73 73 6c 2e 61 20 24 73  ldir/libssl.a $s
39d0: 73 6c 64 69 72 2f 6c 69 62 63 72 79 70 74 6f 2e  sldir/libcrypto.
39e0: 61 20 2d 6c 70 74 68 72 65 61 64 22 0a 20 20 20  a -lpthread".   
39f0: 20 20 20 20 20 73 65 74 20 66 6f 75 6e 64 20 5b       set found [
3a00: 63 68 65 63 6b 2d 66 6f 72 2d 6f 70 65 6e 73 73  check-for-openss
3a10: 6c 20 22 73 73 6c 20 69 6e 20 73 6f 75 72 63 65  l "ssl in source
3a20: 20 74 72 65 65 22 20 22 24 63 66 6c 61 67 73 20   tree" "$cflags 
3a30: 24 6c 64 66 6c 61 67 73 22 20 24 73 73 6c 6c 69  $ldflags" $sslli
3a40: 62 73 5d 0a 20 20 20 20 7d 20 65 6c 73 65 20 7b  bs].    } else {
3a50: 0a 20 20 20 20 20 20 20 20 69 66 20 7b 24 73 73  .        if {$ss
3a60: 6c 64 69 72 73 20 69 6e 20 7b 61 75 74 6f 20 22  ldirs in {auto "
3a70: 22 7d 7d 20 7b 0a 20 20 20 20 20 20 20 20 20 20  "}} {.          
3a80: 20 20 63 61 74 63 68 20 7b 0a 20 20 20 20 20 20    catch {.      
3a90: 20 20 20 20 20 20 20 20 20 20 73 65 74 20 63 66            set cf
3aa0: 6c 61 67 73 20 5b 65 78 65 63 20 70 6b 67 2d 63  lags [exec pkg-c
3ab0: 6f 6e 66 69 67 20 6f 70 65 6e 73 73 6c 20 2d 2d  onfig openssl --
3ac0: 63 66 6c 61 67 73 2d 6f 6e 6c 79 2d 49 5d 0a 20  cflags-only-I]. 
3ad0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73                 s
3ae0: 65 74 20 6c 64 66 6c 61 67 73 20 5b 65 78 65 63  et ldflags [exec
3af0: 20 70 6b 67 2d 63 6f 6e 66 69 67 20 6f 70 65 6e   pkg-config open
3b00: 73 73 6c 20 2d 2d 6c 69 62 73 2d 6f 6e 6c 79 2d  ssl --libs-only-
3b10: 4c 5d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  L].             
3b20: 20 20 20 73 65 74 20 66 6f 75 6e 64 20 5b 63 68     set found [ch
3b30: 65 63 6b 2d 66 6f 72 2d 6f 70 65 6e 73 73 6c 20  eck-for-openssl 
3b40: 22 73 73 6c 20 76 69 61 20 70 6b 67 2d 63 6f 6e  "ssl via pkg-con
3b50: 66 69 67 22 20 22 24 63 66 6c 61 67 73 20 24 6c  fig" "$cflags $l
3b60: 64 66 6c 61 67 73 22 5d 0a 20 20 20 20 20 20 20  dflags"].       
3b70: 20 20 20 20 20 7d 20 6d 73 67 0a 20 20 20 20 20       } msg.     
3b80: 20 20 20 20 20 20 20 69 66 20 7b 21 24 66 6f 75         if {!$fou
3b90: 6e 64 7d 20 7b 0a 20 20 20 20 20 20 20 20 20 20  nd} {.          
3ba0: 20 20 20 20 20 20 73 65 74 20 73 73 6c 64 69 72        set ssldir
3bb0: 73 20 22 7b 7d 20 2f 75 73 72 2f 73 66 77 20 2f  s "{} /usr/sfw /
3bc0: 75 73 72 2f 6c 6f 63 61 6c 2f 73 73 6c 20 2f 75  usr/local/ssl /u
3bd0: 73 72 2f 6c 69 62 2f 73 73 6c 20 2f 75 73 72 2f  sr/lib/ssl /usr/
3be0: 73 73 6c 20 5c 0a 20 20 20 20 20 20 20 20 20 20  ssl \.          
3bf0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3c00: 20 20 20 2f 75 73 72 2f 70 6b 67 20 2f 75 73 72     /usr/pkg /usr
3c10: 2f 6c 6f 63 61 6c 20 2f 75 73 72 20 2f 75 73 72  /local /usr /usr
3c20: 2f 6c 6f 63 61 6c 2f 6f 70 74 2f 6f 70 65 6e 73  /local/opt/opens
3c30: 73 6c 20 5c 0a 20 20 20 20 20 20 20 20 20 20 20  sl \.           
3c40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3c50: 20 20 2f 6f 70 74 2f 68 6f 6d 65 62 72 65 77 2f    /opt/homebrew/
3c60: 6f 70 74 2f 6f 70 65 6e 73 73 6c 22 0a 20 20 20  opt/openssl".   
3c70: 20 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20           }.     
3c80: 20 20 20 7d 0a 20 20 20 20 20 20 20 20 69 66 20     }.        if 
3c90: 7b 21 24 66 6f 75 6e 64 7d 20 7b 0a 20 20 20 20  {!$found} {.    
3ca0: 20 20 20 20 20 20 20 20 66 6f 72 65 61 63 68 20          foreach 
3cb0: 64 69 72 20 24 73 73 6c 64 69 72 73 20 7b 0a 20  dir $ssldirs {. 
3cc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69                 i
3cd0: 66 20 7b 24 64 69 72 20 65 71 20 22 22 7d 20 7b  f {$dir eq ""} {
3ce0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
3cf0: 20 20 20 20 20 73 65 74 20 6d 73 67 20 22 73 79       set msg "sy
3d00: 73 74 65 6d 20 73 73 6c 22 0a 20 20 20 20 20 20  stem ssl".      
3d10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 65                se
3d20: 74 20 63 66 6c 61 67 73 20 22 22 0a 20 20 20 20  t cflags "".    
3d30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3d40: 73 65 74 20 6c 64 66 6c 61 67 73 20 22 22 0a 20  set ldflags "". 
3d50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d                 }
3d60: 20 65 6c 73 65 20 7b 0a 20 20 20 20 20 20 20 20   else {.        
3d70: 20 20 20 20 20 20 20 20 20 20 20 20 73 65 74 20              set 
3d80: 6d 73 67 20 22 73 73 6c 20 69 6e 20 24 64 69 72  msg "ssl in $dir
3d90: 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ".              
3da0: 20 20 20 20 20 20 73 65 74 20 63 66 6c 61 67 73        set cflags
3db0: 20 22 2d 49 24 64 69 72 2f 69 6e 63 6c 75 64 65   "-I$dir/include
3dc0: 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ".              
3dd0: 20 20 20 20 20 20 73 65 74 20 6c 64 66 6c 61 67        set ldflag
3de0: 73 20 22 2d 4c 24 64 69 72 2f 6c 69 62 22 0a 20  s "-L$dir/lib". 
3df0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d                 }
3e00: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
3e10: 20 69 66 20 7b 5b 63 68 65 63 6b 2d 66 6f 72 2d   if {[check-for-
3e20: 6f 70 65 6e 73 73 6c 20 24 6d 73 67 20 22 24 63  openssl $msg "$c
3e30: 66 6c 61 67 73 20 24 6c 64 66 6c 61 67 73 22 5d  flags $ldflags"]
3e40: 7d 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20  } {.            
3e50: 20 20 20 20 20 20 20 20 69 6e 63 72 20 66 6f 75          incr fou
3e60: 6e 64 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  nd.             
3e70: 20 20 20 20 20 20 20 62 72 65 61 6b 0a 20 20 20         break.   
3e80: 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0a 20               }. 
3e90: 20 20 20 20 20 20 20 20 20 20 20 7d 0a 20 20 20             }.   
3ea0: 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a 20 20 20       }.    }.   
3eb0: 20 69 66 20 7b 24 66 6f 75 6e 64 7d 20 7b 0a 20   if {$found} {. 
3ec0: 20 20 20 20 20 20 20 64 65 66 69 6e 65 20 46 4f         define FO
3ed0: 53 53 49 4c 5f 45 4e 41 42 4c 45 5f 53 53 4c 0a  SSIL_ENABLE_SSL.
3ee0: 20 20 20 20 20 20 20 20 64 65 66 69 6e 65 2d 61          define-a
3ef0: 70 70 65 6e 64 20 45 58 54 52 41 5f 43 46 4c 41  ppend EXTRA_CFLA
3f00: 47 53 20 24 63 66 6c 61 67 73 0a 20 20 20 20 20  GS $cflags.     
3f10: 20 20 20 64 65 66 69 6e 65 2d 61 70 70 65 6e 64     define-append
3f20: 20 45 58 54 52 41 5f 4c 44 46 4c 41 47 53 20 24   EXTRA_LDFLAGS $
3f30: 6c 64 66 6c 61 67 73 0a 20 20 20 20 20 20 20 20  ldflags.        
3f40: 64 65 66 69 6e 65 2d 61 70 70 65 6e 64 20 43 46  define-append CF
3f50: 4c 41 47 53 20 24 63 66 6c 61 67 73 0a 20 20 20  LAGS $cflags.   
3f60: 20 20 20 20 20 64 65 66 69 6e 65 2d 61 70 70 65       define-appe
3f70: 6e 64 20 4c 44 46 4c 41 47 53 20 24 6c 64 66 6c  nd LDFLAGS $ldfl
3f80: 61 67 73 0a 20 20 20 20 20 20 20 20 69 66 20 7b  ags.        if {
3f90: 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 73 73 6c  [info exists ssl
3fa0: 6c 69 62 73 5d 7d 20 7b 0a 20 20 20 20 20 20 20  libs]} {.       
3fb0: 20 20 20 20 20 64 65 66 69 6e 65 2d 61 70 70 65       define-appe
3fc0: 6e 64 20 4c 49 42 53 20 24 73 73 6c 6c 69 62 73  nd LIBS $ssllibs
3fd0: 0a 20 20 20 20 20 20 20 20 7d 20 65 6c 73 65 20  .        } else 
3fe0: 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 64 65  {.            de
3ff0: 66 69 6e 65 2d 61 70 70 65 6e 64 20 4c 49 42 53  fine-append LIBS
4000: 20 2d 6c 73 73 6c 20 2d 6c 63 72 79 70 74 6f 0a   -lssl -lcrypto.
4010: 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20          }.      
4020: 20 20 69 66 20 7b 5b 69 6e 66 6f 20 65 78 69 73    if {[info exis
4030: 74 73 20 3a 3a 7a 6c 69 62 5f 6c 69 62 5d 7d 20  ts ::zlib_lib]} 
4040: 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 64 65  {.            de
4050: 66 69 6e 65 2d 61 70 70 65 6e 64 20 4c 49 42 53  fine-append LIBS
4060: 20 24 3a 3a 7a 6c 69 62 5f 6c 69 62 0a 20 20 20   $::zlib_lib.   
4070: 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20 69       }.        i
4080: 66 20 7b 5b 69 73 5f 6d 69 6e 67 77 5d 7d 20 7b  f {[is_mingw]} {
4090: 0a 20 20 20 20 20 20 20 20 20 20 20 20 64 65 66  .            def
40a0: 69 6e 65 2d 61 70 70 65 6e 64 20 4c 49 42 53 20  ine-append LIBS 
40b0: 2d 6c 67 64 69 33 32 20 2d 6c 77 73 6f 63 6b 33  -lgdi32 -lwsock3
40c0: 32 20 2d 6c 63 72 79 70 74 33 32 0a 20 20 20 20  2 -lcrypt32.    
40d0: 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20 6d 73      }.        ms
40e0: 67 2d 72 65 73 75 6c 74 20 22 48 54 54 50 53 20  g-result "HTTPS 
40f0: 73 75 70 70 6f 72 74 20 65 6e 61 62 6c 65 64 22  support enabled"
4100: 0a 0a 20 20 20 20 20 20 20 20 23 20 53 69 6c 65  ..        # Sile
4110: 6e 63 65 20 4f 70 65 6e 53 53 4c 20 64 65 70 72  nce OpenSSL depr
4120: 65 63 61 74 69 6f 6e 20 77 61 72 6e 69 6e 67 73  ecation warnings
4130: 20 6f 6e 20 4d 61 63 20 4f 53 20 58 20 31 30 2e   on Mac OS X 10.
4140: 37 2e 0a 20 20 20 20 20 20 20 20 69 66 20 7b 5b  7..        if {[
4150: 73 74 72 69 6e 67 20 6d 61 74 63 68 20 2a 2d 64  string match *-d
4160: 61 72 77 69 6e 2a 20 5b 67 65 74 2d 64 65 66 69  arwin* [get-defi
4170: 6e 65 20 68 6f 73 74 5d 5d 7d 20 7b 0a 20 20 20  ne host]]} {.   
4180: 20 20 20 20 20 20 20 20 20 69 66 20 7b 5b 63 63           if {[cc
4190: 74 65 73 74 20 2d 63 66 6c 61 67 73 20 7b 2d 57  test -cflags {-W
41a0: 64 65 70 72 65 63 61 74 65 64 2d 64 65 63 6c 61  deprecated-decla
41b0: 72 61 74 69 6f 6e 73 7d 5d 7d 20 7b 0a 20 20 20  rations}]} {.   
41c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 66               def
41d0: 69 6e 65 2d 61 70 70 65 6e 64 20 45 58 54 52 41  ine-append EXTRA
41e0: 5f 43 46 4c 41 47 53 20 2d 57 64 65 70 72 65 63  _CFLAGS -Wdeprec
41f0: 61 74 65 64 2d 64 65 63 6c 61 72 61 74 69 6f 6e  ated-declaration
4200: 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0a  s.            }.
4210: 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 20          }.    } 
4220: 65 6c 73 65 20 7b 0a 20 20 20 20 20 20 20 20 75  else {.        u
4230: 73 65 72 2d 65 72 72 6f 72 20 22 4f 70 65 6e 53  ser-error "OpenS
4240: 53 4c 20 6e 6f 74 20 66 6f 75 6e 64 2e 20 43 6f  SL not found. Co
4250: 6e 73 69 64 65 72 20 2d 2d 77 69 74 68 2d 6f 70  nsider --with-op
4260: 65 6e 73 73 6c 3d 6e 6f 6e 65 20 74 6f 20 64 69  enssl=none to di
4270: 73 61 62 6c 65 20 48 54 54 50 53 20 73 75 70 70  sable HTTPS supp
4280: 6f 72 74 22 0a 20 20 20 20 7d 0a 7d 20 65 6c 73  ort".    }.} els
4290: 65 20 7b 0a 20 20 20 20 69 66 20 7b 5b 69 6e 66  e {.    if {[inf
42a0: 6f 20 65 78 69 73 74 73 20 3a 3a 7a 6c 69 62 5f  o exists ::zlib_
42b0: 6c 69 62 5d 7d 20 7b 0a 20 20 20 20 20 20 20 20  lib]} {.        
42c0: 64 65 66 69 6e 65 2d 61 70 70 65 6e 64 20 4c 49  define-append LI
42d0: 42 53 20 24 3a 3a 7a 6c 69 62 5f 6c 69 62 0a 20  BS $::zlib_lib. 
42e0: 20 20 20 7d 0a 7d 0a 0a 0a 0a 23 23 23 23 23 23     }.}....######
42f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
4300: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
4310: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
4320: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
4330: 23 23 0a 23 20 2d 2d 77 69 74 68 2d 73 71 6c 69  ##.# --with-sqli
4340: 74 65 3d 50 41 54 48 20 63 68 65 63 6b 73 20 66  te=PATH checks f
4350: 6f 72 20 74 68 65 20 66 69 72 73 74 20 69 74 20  or the first it 
4360: 66 69 6e 64 73 20 6f 66 20 74 68 65 20 66 6f 6c  finds of the fol
4370: 6c 6f 77 69 6e 67 2e 2e 2e 0a 23 20 2d 20 50 41  lowing....# - PA
4380: 54 48 2f 73 71 6c 69 74 65 33 2e 63 20 61 6e 64  TH/sqlite3.c and
4390: 20 50 41 54 48 2f 73 71 6c 69 74 65 33 2e 68 0a   PATH/sqlite3.h.
43a0: 23 20 2d 20 50 41 54 48 2f 73 71 6c 69 74 65 33  # - PATH/sqlite3
43b0: 2e 6f 20 28 61 6e 64 20 61 73 73 75 6d 65 73 20  .o (and assumes 
43c0: 73 71 6c 69 74 65 33 2e 68 20 69 73 20 77 69 74  sqlite3.h is wit
43d0: 68 20 69 74 29 0a 23 20 2d 20 50 41 54 48 2f 6c  h it).# - PATH/l
43e0: 69 62 2f 6c 69 62 73 71 6c 69 74 65 33 2a 20 61  ib/libsqlite3* a
43f0: 6e 64 20 50 41 54 48 2f 69 6e 63 6c 75 64 65 2f  nd PATH/include/
4400: 73 71 6c 69 74 65 33 2e 68 0a 64 65 66 69 6e 65  sqlite3.h.define
4410: 20 43 46 4c 41 47 53 5f 49 4e 43 4c 55 44 45 20   CFLAGS_INCLUDE 
4420: 7b 7d 0a 23 20 5e 5e 5e 20 43 46 4c 41 47 53 5f  {}.# ^^^ CFLAGS_
4430: 49 4e 43 4c 55 44 45 20 69 73 20 4f 4e 4c 59 20  INCLUDE is ONLY 
4440: 66 6f 72 20 2d 49 2e 2e 2e 20 66 6c 61 67 73 20  for -I... flags 
4450: 61 6e 64 20 74 68 65 69 72 20 6f 72 64 65 72 20  and their order 
4460: 69 73 0a 23 20 73 69 67 6e 69 66 69 63 61 6e 74  is.# significant
4470: 20 73 6f 20 74 68 61 74 20 2d 2d 77 69 74 68 2d   so that --with-
4480: 73 71 6c 69 74 65 3d 50 41 54 48 27 73 20 68 65  sqlite=PATH's he
4490: 61 64 65 72 20 63 61 6e 20 73 68 61 64 6f 77 20  ader can shadow 
44a0: 6f 75 72 0a 23 20 6f 77 6e 2e 20 4f 6e 65 20 63  our.# own. One c
44b0: 61 76 65 61 74 20 77 69 74 68 20 74 68 69 73 20  aveat with this 
44c0: 69 73 20 74 68 61 74 20 77 65 20 63 61 6e 6e 6f  is that we canno
44d0: 74 20 70 6f 69 6e 74 20 2d 2d 77 69 74 68 2d 73  t point --with-s
44e0: 71 6c 69 74 65 3d 50 41 54 48 0a 23 20 74 6f 20  qlite=PATH.# to 
44f0: 74 68 65 20 72 6f 6f 74 20 6f 66 20 73 71 6c 69  the root of sqli
4500: 74 65 33 27 73 20 6f 77 6e 20 62 75 69 6c 64 20  te3's own build 
4510: 74 72 65 65 20 62 65 63 61 75 73 65 20 74 68 61  tree because tha
4520: 74 20 64 69 72 20 68 61 73 20 61 0a 23 20 63 6f  t dir has a.# co
4530: 6e 66 69 67 2e 68 20 77 68 69 63 68 20 65 6e 64  nfig.h which end
4540: 73 20 75 70 20 73 68 61 64 6f 77 69 6e 67 20 73  s up shadowing s
4550: 72 63 2f 63 6f 6e 66 69 67 2e 68 2c 20 62 72 65  rc/config.h, bre
4560: 61 6b 69 6e 67 20 6f 75 72 20 62 75 69 6c 64 2e  aking our build.
4570: 0a 73 65 74 20 73 71 33 70 61 74 68 20 5b 6f 70  .set sq3path [op
4580: 74 2d 76 61 6c 20 77 69 74 68 2d 73 71 6c 69 74  t-val with-sqlit
4590: 65 5d 0a 64 65 66 69 6e 65 20 53 51 4c 49 54 45  e].define SQLITE
45a0: 33 5f 53 52 43 2e 32 20 7b 7d 0a 64 65 66 69 6e  3_SRC.2 {}.defin
45b0: 65 20 53 51 4c 49 54 45 33 5f 4f 42 4a 2e 32 20  e SQLITE3_OBJ.2 
45c0: 7b 7d 0a 64 65 66 69 6e 65 20 53 51 4c 49 54 45  {}.define SQLITE
45d0: 33 5f 53 48 45 4c 4c 5f 53 52 43 2e 32 20 7b 24  3_SHELL_SRC.2 {$
45e0: 28 53 51 4c 49 54 45 33 5f 53 48 45 4c 4c 5f 53  (SQLITE3_SHELL_S
45f0: 52 43 2e 30 29 7d 0a 69 66 20 7b 24 73 71 33 70  RC.0)}.if {$sq3p
4600: 61 74 68 20 69 6e 20 7b 74 72 65 65 20 22 22 7d  ath in {tree ""}
4610: 7d 20 7b 0a 20 20 6d 73 67 2d 72 65 73 75 6c 74  } {.  msg-result
4620: 20 22 55 73 69 6e 67 20 73 71 6c 69 74 65 33 2e   "Using sqlite3.
4630: 63 20 66 72 6f 6d 20 74 68 69 73 20 73 6f 75 72  c from this sour
4640: 63 65 20 74 72 65 65 2e 22 0a 7d 20 65 6c 73 65  ce tree.".} else
4650: 20 7b 0a 20 20 23 20 53 51 4c 49 54 45 33 5f 4f   {.  # SQLITE3_O
4660: 52 49 47 49 4e 3a 0a 20 20 23 20 20 20 30 20 3d  RIGIN:.  #   0 =
4670: 20 6c 6f 63 61 6c 20 73 6f 75 72 63 65 20 74 72   local source tr
4680: 65 65 0a 20 20 23 20 20 20 31 20 3d 20 75 73 65  ee.  #   1 = use
4690: 20 65 78 74 65 72 6e 61 6c 20 6c 69 62 20 6f 72   external lib or
46a0: 20 73 71 6c 69 74 65 33 2e 6f 0a 20 20 23 20 20   sqlite3.o.  #  
46b0: 20 32 20 3d 20 75 73 65 20 65 78 74 65 72 6e 61   2 = use externa
46c0: 6c 20 73 71 6c 69 74 65 33 2e 63 20 61 6e 64 20  l sqlite3.c and 
46d0: 28 69 66 20 66 6f 75 6e 64 29 20 73 68 65 6c 6c  (if found) shell
46e0: 2e 63 0a 20 20 64 65 66 69 6e 65 20 55 53 45 5f  .c.  define USE_
46f0: 53 59 53 54 45 4d 5f 53 51 4c 49 54 45 20 31 0a  SYSTEM_SQLITE 1.
4700: 20 20 64 65 66 69 6e 65 20 53 51 4c 49 54 45 33    define SQLITE3
4710: 5f 4f 52 49 47 49 4e 20 32 0a 20 20 69 66 20 7b  _ORIGIN 2.  if {
4720: 24 73 71 33 70 61 74 68 20 21 3d 20 22 61 75 74  $sq3path != "aut
4730: 6f 22 7d 20 7b 0a 20 20 20 20 69 66 20 7b 28 5b  o"} {.    if {([
4740: 66 69 6c 65 20 65 78 69 73 74 73 20 24 73 71 33  file exists $sq3
4750: 70 61 74 68 2f 73 71 6c 69 74 65 33 2e 63 5d 29  path/sqlite3.c])
4760: 20 26 26 20 5c 0a 20 20 20 20 20 20 20 20 28 5b   && \.        ([
4770: 66 69 6c 65 20 65 78 69 73 74 73 20 24 73 71 33  file exists $sq3
4780: 70 61 74 68 2f 73 71 6c 69 74 65 33 2e 68 5d 29  path/sqlite3.h])
4790: 20 7d 20 7b 0a 20 20 20 20 20 20 23 20 50 72 65   } {.      # Pre
47a0: 66 65 72 20 73 71 6c 69 74 65 33 2e 5b 63 68 5d  fer sqlite3.[ch]
47b0: 20 69 66 20 66 6f 75 6e 64 2e 0a 20 20 20 20 20   if found..     
47c0: 20 64 65 66 69 6e 65 20 53 51 4c 49 54 45 33 5f   define SQLITE3_
47d0: 53 52 43 2e 32 20 24 73 71 33 70 61 74 68 2f 73  SRC.2 $sq3path/s
47e0: 71 6c 69 74 65 33 2e 63 0a 20 20 20 20 20 20 64  qlite3.c.      d
47f0: 65 66 69 6e 65 20 53 51 4c 49 54 45 33 5f 4f 42  efine SQLITE3_OB
4800: 4a 2e 32 20 7b 24 28 53 51 4c 49 54 45 33 5f 4f  J.2 {$(SQLITE3_O
4810: 42 4a 2e 30 29 7d 0a 20 20 20 20 20 20 64 65 66  BJ.0)}.      def
4820: 69 6e 65 20 55 53 45 5f 53 59 53 54 45 4d 5f 53  ine USE_SYSTEM_S
4830: 51 4c 49 54 45 20 32 0a 20 20 20 20 20 20 64 65  QLITE 2.      de
4840: 66 69 6e 65 20 53 51 4c 49 54 45 33 5f 4f 52 49  fine SQLITE3_ORI
4850: 47 49 4e 20 32 0a 20 20 20 20 20 20 69 66 20 7b  GIN 2.      if {
4860: 5b 66 69 6c 65 20 65 78 69 73 74 73 20 24 73 71  [file exists $sq
4870: 33 70 61 74 68 2f 73 68 65 6c 6c 2e 63 5d 7d 20  3path/shell.c]} 
4880: 7b 0a 20 20 20 20 20 20 20 20 64 65 66 69 6e 65  {.        define
4890: 20 53 51 4c 49 54 45 33 5f 53 48 45 4c 4c 5f 53   SQLITE3_SHELL_S
48a0: 52 43 2e 32 20 24 73 71 33 70 61 74 68 2f 73 68  RC.2 $sq3path/sh
48b0: 65 6c 6c 2e 63 0a 20 20 20 20 20 20 7d 0a 20 20  ell.c.      }.  
48c0: 20 20 20 20 64 65 66 69 6e 65 2d 61 70 70 65 6e      define-appen
48d0: 64 20 43 46 4c 41 47 53 5f 49 4e 43 4c 55 44 45  d CFLAGS_INCLUDE
48e0: 20 2d 49 24 73 71 33 70 61 74 68 0a 20 20 20 20   -I$sq3path.    
48f0: 20 20 64 65 66 69 6e 65 2d 61 70 70 65 6e 64 20    define-append 
4900: 45 58 54 52 41 5f 4c 44 46 4c 41 47 53 20 2d 6c  EXTRA_LDFLAGS -l
4910: 70 74 68 72 65 61 64 0a 20 20 20 20 20 20 23 20  pthread.      # 
4920: 5e 5e 5e 20 61 64 64 69 74 69 6f 6e 61 6c 20 2d  ^^^ additional -
4930: 6c 58 58 58 20 66 6c 61 67 73 20 61 72 65 20 63  lXXX flags are c
4940: 6f 6e 73 65 72 76 61 74 69 76 65 20 65 73 74 69  onservative esti
4950: 6d 61 74 65 73 0a 20 20 20 20 20 20 6d 73 67 2d  mates.      msg-
4960: 72 65 73 75 6c 74 20 22 55 73 69 6e 67 20 73 71  result "Using sq
4970: 6c 69 74 65 33 2e 63 20 61 6e 64 20 73 71 6c 69  lite3.c and sqli
4980: 74 65 33 2e 68 20 66 72 6f 6d 20 24 73 71 33 70  te3.h from $sq3p
4990: 61 74 68 22 0a 20 20 20 20 7d 20 65 6c 73 65 69  ath".    } elsei
49a0: 66 20 7b 5b 66 69 6c 65 20 65 78 69 73 74 73 20  f {[file exists 
49b0: 24 73 71 33 70 61 74 68 2f 73 71 6c 69 74 65 33  $sq3path/sqlite3
49c0: 2e 6f 5d 7d 20 7b 0a 20 20 20 20 20 20 23 20 55  .o]} {.      # U
49d0: 73 65 20 73 71 6c 69 74 65 33 2e 6f 20 69 66 20  se sqlite3.o if 
49e0: 66 6f 75 6e 64 2e 0a 20 20 20 20 20 20 64 65 66  found..      def
49f0: 69 6e 65 20 53 51 4c 49 54 45 33 5f 4f 42 4a 2e  ine SQLITE3_OBJ.
4a00: 32 20 24 73 71 33 70 61 74 68 2f 73 71 6c 69 74  2 $sq3path/sqlit
4a10: 65 33 2e 6f 0a 20 20 20 20 20 20 64 65 66 69 6e  e3.o.      defin
4a20: 65 2d 61 70 70 65 6e 64 20 43 46 4c 41 47 53 5f  e-append CFLAGS_
4a30: 49 4e 43 4c 55 44 45 20 2d 49 24 73 71 33 70 61  INCLUDE -I$sq3pa
4a40: 74 68 0a 20 20 20 20 20 20 64 65 66 69 6e 65 2d  th.      define-
4a50: 61 70 70 65 6e 64 20 45 58 54 52 41 5f 4c 44 46  append EXTRA_LDF
4a60: 4c 41 47 53 20 24 73 71 33 70 61 74 68 2f 73 71  LAGS $sq3path/sq
4a70: 6c 69 74 65 33 2e 6f 20 2d 6c 70 74 68 72 65 61  lite3.o -lpthrea
4a80: 64 0a 20 20 20 20 20 20 23 20 5e 5e 5e 20 61 64  d.      # ^^^ ad
4a90: 64 69 74 69 6f 6e 61 6c 20 2d 6c 58 58 58 20 66  ditional -lXXX f
4aa0: 6c 61 67 73 20 61 72 65 20 63 6f 6e 73 65 72 76  lags are conserv
4ab0: 61 74 69 76 65 20 65 73 74 69 6d 61 74 65 73 0a  ative estimates.
4ac0: 20 20 20 20 20 20 6d 73 67 2d 72 65 73 75 6c 74        msg-result
4ad0: 20 22 55 73 69 6e 67 20 73 71 6c 69 74 65 33 2e   "Using sqlite3.
4ae0: 6f 20 66 72 6f 6d 20 24 73 71 33 70 61 74 68 22  o from $sq3path"
4af0: 0a 20 20 20 20 7d 20 65 6c 73 65 69 66 20 7b 20  .    } elseif { 
4b00: 28 5b 6c 6c 65 6e 67 74 68 20 5b 67 6c 6f 62 20  ([llength [glob 
4b10: 2d 6e 6f 63 6f 6d 70 6c 61 69 6e 20 2d 64 69 72  -nocomplain -dir
4b20: 65 63 74 6f 72 79 20 24 73 71 33 70 61 74 68 2f  ectory $sq3path/
4b30: 6c 69 62 20 6c 69 62 73 71 6c 69 74 65 33 2a 5d  lib libsqlite3*]
4b40: 5d 20 21 3d 20 30 29 20 5c 0a 20 20 20 20 20 20  ] != 0) \.      
4b50: 20 20 20 20 20 20 20 20 20 20 20 26 26 20 28 5b             && ([
4b60: 66 69 6c 65 20 65 78 69 73 74 73 20 24 73 71 33  file exists $sq3
4b70: 70 61 74 68 2f 69 6e 63 6c 75 64 65 2f 73 71 6c  path/include/sql
4b80: 69 74 65 33 2e 68 5d 29 20 7d 20 7b 0a 20 20 20  ite3.h]) } {.   
4b90: 20 20 20 23 20 65 2e 67 2e 20 2d 2d 77 69 74 68     # e.g. --with
4ba0: 2d 73 71 6c 69 74 65 3d 2f 75 73 72 2f 6c 6f 63  -sqlite=/usr/loc
4bb0: 61 6c 2e 20 54 72 79 20 24 73 71 33 70 61 74 68  al. Try $sq3path
4bc0: 2f 6c 69 62 2f 6c 69 62 73 71 6c 69 74 65 33 2a  /lib/libsqlite3*
4bd0: 0a 20 20 20 20 20 20 23 20 61 6e 64 20 24 73 71  .      # and $sq
4be0: 33 70 61 74 68 2f 69 6e 63 6c 75 64 65 2f 73 71  3path/include/sq
4bf0: 6c 69 74 65 33 2e 68 0a 20 20 20 20 20 20 64 65  lite3.h.      de
4c00: 66 69 6e 65 2d 61 70 70 65 6e 64 20 43 46 4c 41  fine-append CFLA
4c10: 47 53 5f 49 4e 43 4c 55 44 45 20 2d 49 24 73 71  GS_INCLUDE -I$sq
4c20: 33 70 61 74 68 2f 69 6e 63 6c 75 64 65 0a 20 20  3path/include.  
4c30: 20 20 20 20 64 65 66 69 6e 65 2d 61 70 70 65 6e      define-appen
4c40: 64 20 45 58 54 52 41 5f 4c 44 46 4c 41 47 53 20  d EXTRA_LDFLAGS 
4c50: 2d 4c 24 73 71 33 70 61 74 68 2f 6c 69 62 20 2d  -L$sq3path/lib -
4c60: 6c 73 71 6c 69 74 65 33 20 2d 6c 70 74 68 72 65  lsqlite3 -lpthre
4c70: 61 64 0a 20 20 20 20 20 20 23 20 5e 5e 5e 20 61  ad.      # ^^^ a
4c80: 64 64 69 74 69 6f 6e 61 6c 20 2d 6c 58 58 58 20  dditional -lXXX 
4c90: 66 6c 61 67 73 20 61 72 65 20 63 6f 6e 73 65 72  flags are conser
4ca0: 76 61 74 69 76 65 20 65 73 74 69 6d 61 74 65 73  vative estimates
4cb0: 0a 20 20 20 20 20 20 6d 73 67 2d 72 65 73 75 6c  .      msg-resul
4cc0: 74 20 22 55 73 69 6e 67 20 2d 6c 73 71 6c 69 74  t "Using -lsqlit
4cd0: 65 33 20 66 72 6f 6d 20 24 73 71 33 70 61 74 68  e3 from $sq3path
4ce0: 22 0a 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 20  ".    } else {. 
4cf0: 20 20 20 20 20 23 20 41 73 73 75 6d 65 20 24 73       # Assume $s
4d00: 71 33 70 61 74 68 20 68 6f 6c 64 73 20 62 6f 74  q3path holds bot
4d10: 68 20 74 68 65 20 6c 69 62 20 61 6e 64 20 68 65  h the lib and he
4d20: 61 64 65 72 0a 20 20 20 20 20 20 63 63 2d 77 69  ader.      cc-wi
4d30: 74 68 20 5b 6c 69 73 74 20 2d 63 66 6c 61 67 73  th [list -cflags
4d40: 20 22 2d 49 24 73 71 33 70 61 74 68 20 2d 4c 24   "-I$sq3path -L$
4d50: 73 71 33 70 61 74 68 22 5d 0a 20 20 20 20 20 20  sq3path"].      
4d60: 64 65 66 69 6e 65 2d 61 70 70 65 6e 64 20 43 46  define-append CF
4d70: 4c 41 47 53 5f 49 4e 43 4c 55 44 45 20 2d 49 24  LAGS_INCLUDE -I$
4d80: 73 71 33 70 61 74 68 0a 20 20 20 20 20 20 64 65  sq3path.      de
4d90: 66 69 6e 65 2d 61 70 70 65 6e 64 20 45 58 54 52  fine-append EXTR
4da0: 41 5f 4c 44 46 4c 41 47 53 20 2d 4c 24 73 71 33  A_LDFLAGS -L$sq3
4db0: 70 61 74 68 20 2d 6c 73 71 6c 69 74 65 33 20 2d  path -lsqlite3 -
4dc0: 6c 70 74 68 72 65 61 64 0a 20 20 20 20 20 20 23  lpthread.      #
4dd0: 20 5e 5e 5e 20 61 64 64 69 74 69 6f 6e 61 6c 20   ^^^ additional 
4de0: 2d 6c 58 58 58 20 66 6c 61 67 73 20 61 72 65 20  -lXXX flags are 
4df0: 63 6f 6e 73 65 72 76 61 74 69 76 65 20 65 73 74  conservative est
4e00: 69 6d 61 74 65 73 0a 20 20 20 20 20 20 6d 73 67  imates.      msg
4e10: 2d 72 65 73 75 6c 74 20 22 55 73 69 6e 67 20 2d  -result "Using -
4e20: 6c 73 71 6c 69 74 65 33 20 66 72 6f 6d 20 24 73  lsqlite3 from $s
4e30: 71 33 70 61 74 68 22 0a 20 20 20 20 7d 0a 20 20  q3path".    }.  
4e40: 7d 20 65 6c 73 65 69 66 20 7b 21 5b 63 63 2d 63  } elseif {![cc-c
4e50: 68 65 63 6b 2d 69 6e 63 6c 75 64 65 73 20 73 71  heck-includes sq
4e60: 6c 69 74 65 33 2e 68 5d 20 7c 7c 20 21 5b 63 68  lite3.h] || ![ch
4e70: 65 63 6b 2d 66 75 6e 63 74 69 6f 6e 2d 69 6e 2d  eck-function-in-
4e80: 6c 69 62 20 73 71 6c 69 74 65 33 5f 6f 70 65 6e  lib sqlite3_open
4e90: 5f 76 32 20 73 71 6c 69 74 65 33 5d 7d 20 7b 0a  _v2 sqlite3]} {.
4ea0: 20 20 20 20 75 73 65 72 2d 65 72 72 6f 72 20 22      user-error "
4eb0: 6c 69 62 73 71 6c 69 74 65 33 20 6e 6f 74 20 66  libsqlite3 not f
4ec0: 6f 75 6e 64 20 70 6c 65 61 73 65 20 69 6e 73 74  ound please inst
4ed0: 61 6c 6c 20 69 74 20 6f 72 20 73 70 65 63 69 66  all it or specif
4ee0: 79 20 74 68 65 20 6c 6f 63 61 74 69 6f 6e 20 77  y the location w
4ef0: 69 74 68 20 2d 2d 77 69 74 68 2d 73 71 6c 69 74  ith --with-sqlit
4f00: 65 22 0a 20 20 7d 0a 7d 0a 64 65 66 69 6e 65 2d  e".  }.}.define-
4f10: 61 70 70 65 6e 64 20 43 46 4c 41 47 53 5f 49 4e  append CFLAGS_IN
4f20: 43 4c 55 44 45 20 7b 2d 49 2e 20 2d 49 24 28 53  CLUDE {-I. -I$(S
4f30: 52 43 44 49 52 29 20 2d 49 24 28 53 52 43 44 49  RCDIR) -I$(SRCDI
4f40: 52 5f 65 78 74 73 72 63 29 7d 0a 0a 73 65 74 20  R_extsrc)}..set 
4f50: 74 63 6c 70 61 74 68 20 5b 6f 70 74 2d 76 61 6c  tclpath [opt-val
4f60: 20 77 69 74 68 2d 74 63 6c 5d 0a 69 66 20 7b 24   with-tcl].if {$
4f70: 74 63 6c 70 61 74 68 20 6e 65 20 22 22 7d 20 7b  tclpath ne ""} {
4f80: 0a 20 20 20 20 73 65 74 20 74 63 6c 70 72 69 76  .    set tclpriv
4f90: 61 74 65 73 74 75 62 73 20 5b 6f 70 74 2d 62 6f  atestubs [opt-bo
4fa0: 6f 6c 20 77 69 74 68 2d 74 63 6c 2d 70 72 69 76  ol with-tcl-priv
4fb0: 61 74 65 2d 73 74 75 62 73 5d 0a 20 20 20 20 23  ate-stubs].    #
4fc0: 20 4e 6f 74 65 20 70 61 72 73 65 2d 74 63 6c 63   Note parse-tclc
4fd0: 6f 6e 66 69 67 2d 73 68 20 69 73 20 69 6e 20 61  onfig-sh is in a
4fe0: 75 74 6f 73 65 74 75 70 2f 6c 6f 63 61 6c 2e 74  utosetup/local.t
4ff0: 63 6c 0a 20 20 20 20 69 66 20 7b 24 74 63 6c 70  cl.    if {$tclp
5000: 61 74 68 20 65 71 20 22 31 22 7d 20 7b 0a 20 20  ath eq "1"} {.  
5010: 20 20 20 20 20 20 73 65 74 20 74 63 6c 64 69 72        set tcldir
5020: 20 5b 66 69 6c 65 20 64 69 72 6e 61 6d 65 20 24   [file dirname $
5030: 61 75 74 6f 73 65 74 75 70 28 64 69 72 29 5d 2f  autosetup(dir)]/
5040: 63 6f 6d 70 61 74 2f 74 63 6c 2d 38 2e 36 0a 20  compat/tcl-8.6. 
5050: 20 20 20 20 20 20 20 69 66 20 7b 24 74 63 6c 70         if {$tclp
5060: 72 69 76 61 74 65 73 74 75 62 73 7d 20 7b 0a 20  rivatestubs} {. 
5070: 20 20 20 20 20 20 20 20 20 20 20 73 65 74 20 74             set t
5080: 63 6c 63 6f 6e 66 69 67 28 54 43 4c 5f 49 4e 43  clconfig(TCL_INC
5090: 4c 55 44 45 5f 53 50 45 43 29 20 2d 49 24 74 63  LUDE_SPEC) -I$tc
50a0: 6c 64 69 72 2f 67 65 6e 65 72 69 63 0a 20 20 20  ldir/generic.   
50b0: 20 20 20 20 20 20 20 20 20 73 65 74 20 74 63 6c           set tcl
50c0: 63 6f 6e 66 69 67 28 54 43 4c 5f 56 45 52 53 49  config(TCL_VERSI
50d0: 4f 4e 29 20 7b 50 72 69 76 61 74 65 20 53 74 75  ON) {Private Stu
50e0: 62 73 7d 0a 20 20 20 20 20 20 20 20 20 20 20 20  bs}.            
50f0: 73 65 74 20 74 63 6c 63 6f 6e 66 69 67 28 54 43  set tclconfig(TC
5100: 4c 5f 50 41 54 43 48 5f 4c 45 56 45 4c 29 20 7b  L_PATCH_LEVEL) {
5110: 7d 0a 20 20 20 20 20 20 20 20 20 20 20 20 73 65  }.            se
5120: 74 20 74 63 6c 63 6f 6e 66 69 67 28 54 43 4c 5f  t tclconfig(TCL_
5130: 50 52 45 46 49 58 29 20 24 74 63 6c 64 69 72 0a  PREFIX) $tcldir.
5140: 20 20 20 20 20 20 20 20 20 20 20 20 73 65 74 20              set 
5150: 74 63 6c 63 6f 6e 66 69 67 28 54 43 4c 5f 4c 44  tclconfig(TCL_LD
5160: 5f 46 4c 41 47 53 29 20 7b 20 7d 0a 20 20 20 20  _FLAGS) { }.    
5170: 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 20 20 20      } else {.   
5180: 20 20 20 20 20 20 20 20 20 23 20 55 73 65 20 74           # Use t
5190: 68 65 20 73 79 73 74 65 6d 20 54 63 6c 2e 20 4c  he system Tcl. L
51a0: 6f 6f 6b 20 69 6e 20 73 6f 6d 65 20 6c 69 6b 65  ook in some like
51b0: 6c 79 20 70 6c 61 63 65 73 2e 0a 20 20 20 20 20  ly places..     
51c0: 20 20 20 20 20 20 20 61 72 72 61 79 20 73 65 74         array set
51d0: 20 74 63 6c 63 6f 6e 66 69 67 20 5b 70 61 72 73   tclconfig [pars
51e0: 65 2d 74 63 6c 63 6f 6e 66 69 67 2d 73 68 20 5c  e-tclconfig-sh \
51f0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
5200: 20 24 74 63 6c 64 69 72 2f 75 6e 69 78 20 24 74   $tcldir/unix $t
5210: 63 6c 64 69 72 2f 77 69 6e 20 5c 0a 20 20 20 20  cldir/win \.    
5220: 20 20 20 20 20 20 20 20 20 20 20 20 2f 75 73 72              /usr
5230: 20 2f 75 73 72 2f 6c 6f 63 61 6c 20 2f 75 73 72   /usr/local /usr
5240: 2f 73 68 61 72 65 20 2f 6f 70 74 2f 6c 6f 63 61  /share /opt/loca
5250: 6c 5d 0a 20 20 20 20 20 20 20 20 20 20 20 20 73  l].            s
5260: 65 74 20 6d 73 67 20 22 6f 6e 20 79 6f 75 72 20  et msg "on your 
5270: 73 79 73 74 65 6d 22 0a 20 20 20 20 20 20 20 20  system".        
5280: 7d 0a 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 20  }.    } else {. 
5290: 20 20 20 20 20 20 20 61 72 72 61 79 20 73 65 74         array set
52a0: 20 74 63 6c 63 6f 6e 66 69 67 20 5b 70 61 72 73   tclconfig [pars
52b0: 65 2d 74 63 6c 63 6f 6e 66 69 67 2d 73 68 20 24  e-tclconfig-sh $
52c0: 74 63 6c 70 61 74 68 5d 0a 20 20 20 20 20 20 20  tclpath].       
52d0: 20 73 65 74 20 6d 73 67 20 22 61 74 20 24 74 63   set msg "at $tc
52e0: 6c 70 61 74 68 22 0a 20 20 20 20 7d 0a 20 20 20  lpath".    }.   
52f0: 20 69 66 20 7b 5b 6f 70 74 2d 62 6f 6f 6c 20 73   if {[opt-bool s
5300: 74 61 74 69 63 5d 7d 20 7b 0a 20 20 20 20 20 20  tatic]} {.      
5310: 20 20 73 65 74 20 74 63 6c 63 6f 6e 66 69 67 28    set tclconfig(
5320: 54 43 4c 5f 4c 44 5f 46 4c 41 47 53 29 20 7b 20  TCL_LD_FLAGS) { 
5330: 7d 0a 20 20 20 20 7d 0a 20 20 20 20 69 66 20 7b  }.    }.    if {
5340: 21 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 74 63  ![info exists tc
5350: 6c 63 6f 6e 66 69 67 28 54 43 4c 5f 49 4e 43 4c  lconfig(TCL_INCL
5360: 55 44 45 5f 53 50 45 43 29 5d 7d 20 7b 0a 20 20  UDE_SPEC)]} {.  
5370: 20 20 20 20 20 20 75 73 65 72 2d 65 72 72 6f 72        user-error
5380: 20 22 43 61 6e 6e 6f 74 20 66 69 6e 64 20 54 63   "Cannot find Tc
5390: 6c 20 24 6d 73 67 22 0a 20 20 20 20 7d 0a 20 20  l $msg".    }.  
53a0: 20 20 73 65 74 20 74 63 6c 73 74 75 62 73 20 5b    set tclstubs [
53b0: 6f 70 74 2d 62 6f 6f 6c 20 77 69 74 68 2d 74 63  opt-bool with-tc
53c0: 6c 2d 73 74 75 62 73 5d 0a 20 20 20 20 69 66 20  l-stubs].    if 
53d0: 7b 24 74 63 6c 70 72 69 76 61 74 65 73 74 75 62  {$tclprivatestub
53e0: 73 7d 20 7b 0a 20 20 20 20 20 20 20 20 64 65 66  s} {.        def
53f0: 69 6e 65 20 46 4f 53 53 49 4c 5f 45 4e 41 42 4c  ine FOSSIL_ENABL
5400: 45 5f 54 43 4c 5f 50 52 49 56 41 54 45 5f 53 54  E_TCL_PRIVATE_ST
5410: 55 42 53 0a 20 20 20 20 20 20 20 20 64 65 66 69  UBS.        defi
5420: 6e 65 20 55 53 45 5f 54 43 4c 5f 53 54 55 42 53  ne USE_TCL_STUBS
5430: 0a 20 20 20 20 7d 20 65 6c 73 65 69 66 20 7b 24  .    } elseif {$
5440: 74 63 6c 73 74 75 62 73 20 26 26 20 24 74 63 6c  tclstubs && $tcl
5450: 63 6f 6e 66 69 67 28 54 43 4c 5f 53 55 50 50 4f  config(TCL_SUPPO
5460: 52 54 53 5f 53 54 55 42 53 29 7d 20 7b 0a 20 20  RTS_STUBS)} {.  
5470: 20 20 20 20 20 20 73 65 74 20 6c 69 62 73 20 22        set libs "
5480: 24 74 63 6c 63 6f 6e 66 69 67 28 54 43 4c 5f 53  $tclconfig(TCL_S
5490: 54 55 42 5f 4c 49 42 5f 53 50 45 43 29 22 0a 20  TUB_LIB_SPEC)". 
54a0: 20 20 20 20 20 20 20 64 65 66 69 6e 65 20 46 4f         define FO
54b0: 53 53 49 4c 5f 45 4e 41 42 4c 45 5f 54 43 4c 5f  SSIL_ENABLE_TCL_
54c0: 53 54 55 42 53 0a 20 20 20 20 20 20 20 20 64 65  STUBS.        de
54d0: 66 69 6e 65 20 55 53 45 5f 54 43 4c 5f 53 54 55  fine USE_TCL_STU
54e0: 42 53 0a 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a  BS.    } else {.
54f0: 20 20 20 20 20 20 20 20 73 65 74 20 6c 69 62 73          set libs
5500: 20 22 24 74 63 6c 63 6f 6e 66 69 67 28 54 43 4c   "$tclconfig(TCL
5510: 5f 4c 49 42 5f 53 50 45 43 29 20 24 74 63 6c 63  _LIB_SPEC) $tclc
5520: 6f 6e 66 69 67 28 54 43 4c 5f 4c 49 42 53 29 22  onfig(TCL_LIBS)"
5530: 0a 20 20 20 20 7d 0a 20 20 20 20 73 65 74 20 63  .    }.    set c
5540: 66 6c 61 67 73 20 24 74 63 6c 63 6f 6e 66 69 67  flags $tclconfig
5550: 28 54 43 4c 5f 49 4e 43 4c 55 44 45 5f 53 50 45  (TCL_INCLUDE_SPE
5560: 43 29 0a 20 20 20 20 69 66 20 7b 21 24 74 63 6c  C).    if {!$tcl
5570: 70 72 69 76 61 74 65 73 74 75 62 73 7d 20 7b 0a  privatestubs} {.
5580: 20 20 20 20 20 20 20 20 73 65 74 20 66 6f 75 6e          set foun
5590: 64 74 63 6c 20 30 3b 20 23 20 44 69 64 20 77 65  dtcl 0; # Did we
55a0: 20 66 69 6e 64 20 61 20 77 6f 72 6b 69 6e 67 20   find a working 
55b0: 54 63 6c 20 6c 69 62 72 61 72 79 3f 0a 20 20 20  Tcl library?.   
55c0: 20 20 20 20 20 63 63 2d 77 69 74 68 20 5b 6c 69       cc-with [li
55d0: 73 74 20 2d 63 66 6c 61 67 73 20 24 63 66 6c 61  st -cflags $cfla
55e0: 67 73 20 2d 6c 69 62 73 20 24 6c 69 62 73 5d 20  gs -libs $libs] 
55f0: 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66  {.            if
5600: 20 7b 24 74 63 6c 73 74 75 62 73 7d 20 7b 0a 20   {$tclstubs} {. 
5610: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69                 i
5620: 66 20 7b 5b 63 63 2d 63 68 65 63 6b 2d 66 75 6e  f {[cc-check-fun
5630: 63 74 69 6f 6e 73 20 54 63 6c 5f 49 6e 69 74 53  ctions Tcl_InitS
5640: 74 75 62 73 5d 7d 20 7b 0a 20 20 20 20 20 20 20  tubs]} {.       
5650: 20 20 20 20 20 20 20 20 20 20 20 20 20 73 65 74               set
5660: 20 66 6f 75 6e 64 74 63 6c 20 31 0a 20 20 20 20   foundtcl 1.    
5670: 20 20 20 20 20 20 20 20 20 20 20 20 7d 0a 20 20              }.  
5680: 20 20 20 20 20 20 20 20 20 20 7d 20 65 6c 73 65            } else
5690: 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20   {.             
56a0: 20 20 20 69 66 20 7b 5b 63 63 2d 63 68 65 63 6b     if {[cc-check
56b0: 2d 66 75 6e 63 74 69 6f 6e 73 20 54 63 6c 5f 43  -functions Tcl_C
56c0: 72 65 61 74 65 49 6e 74 65 72 70 5d 7d 20 7b 0a  reateInterp]} {.
56d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
56e0: 20 20 20 20 73 65 74 20 66 6f 75 6e 64 74 63 6c      set foundtcl
56f0: 20 31 0a 20 20 20 20 20 20 20 20 20 20 20 20 20   1.             
5700: 20 20 20 7d 0a 20 20 20 20 20 20 20 20 20 20 20     }.           
5710: 20 7d 0a 20 20 20 20 20 20 20 20 7d 0a 20 20 20   }.        }.   
5720: 20 20 20 20 20 69 66 20 7b 21 24 66 6f 75 6e 64       if {!$found
5730: 74 63 6c 20 26 26 20 5b 73 74 72 69 6e 67 20 6d  tcl && [string m
5740: 61 74 63 68 20 2a 2d 6c 69 65 65 65 2a 20 24 6c  atch *-lieee* $l
5750: 69 62 73 5d 7d 20 7b 0a 20 20 20 20 20 20 20 20  ibs]} {.        
5760: 20 20 20 20 23 20 4f 6e 20 73 6f 6d 65 20 73 79      # On some sy
5770: 73 74 65 6d 73 2c 20 75 73 69 6e 67 20 22 2d 6c  stems, using "-l
5780: 69 65 65 65 22 20 66 72 6f 6d 20 54 43 4c 5f 4c  ieee" from TCL_L
5790: 49 42 5f 53 50 45 43 20 61 70 70 65 61 72 73 0a  IB_SPEC appears.
57a0: 20 20 20 20 20 20 20 20 20 20 20 20 23 20 74 6f              # to
57b0: 20 63 61 75 73 65 20 69 73 73 75 65 73 2e 0a 20   cause issues.. 
57c0: 20 20 20 20 20 20 20 20 20 20 20 6d 73 67 2d 72             msg-r
57d0: 65 73 75 6c 74 20 22 52 65 6d 6f 76 69 6e 67 20  esult "Removing 
57e0: 5c 22 2d 6c 69 65 65 65 5c 22 20 61 6e 64 20 72  \"-lieee\" and r
57f0: 65 74 72 79 69 6e 67 20 66 6f 72 20 54 63 6c 2e  etrying for Tcl.
5800: 2e 2e 22 0a 20 20 20 20 20 20 20 20 20 20 20 20  ..".            
5810: 73 65 74 20 6c 69 62 73 20 5b 73 74 72 69 6e 67  set libs [string
5820: 20 6d 61 70 20 5b 6c 69 73 74 20 2d 6c 69 65 65   map [list -liee
5830: 65 20 22 22 5d 20 24 6c 69 62 73 5d 0a 20 20 20  e ""] $libs].   
5840: 20 20 20 20 20 20 20 20 20 63 63 2d 77 69 74 68           cc-with
5850: 20 5b 6c 69 73 74 20 2d 63 66 6c 61 67 73 20 24   [list -cflags $
5860: 63 66 6c 61 67 73 20 2d 6c 69 62 73 20 24 6c 69  cflags -libs $li
5870: 62 73 5d 20 7b 0a 20 20 20 20 20 20 20 20 20 20  bs] {.          
5880: 20 20 20 20 20 20 69 66 20 7b 24 74 63 6c 73 74        if {$tclst
5890: 75 62 73 7d 20 7b 0a 20 20 20 20 20 20 20 20 20  ubs} {.         
58a0: 20 20 20 20 20 20 20 20 20 20 20 69 66 20 7b 5b             if {[
58b0: 63 63 2d 63 68 65 63 6b 2d 66 75 6e 63 74 69 6f  cc-check-functio
58c0: 6e 73 20 54 63 6c 5f 49 6e 69 74 53 74 75 62 73  ns Tcl_InitStubs
58d0: 5d 7d 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20  ]} {.           
58e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 73 65 74               set
58f0: 20 66 6f 75 6e 64 74 63 6c 20 31 0a 20 20 20 20   foundtcl 1.    
5900: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
5910: 7d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  }.              
5920: 20 20 7d 20 65 6c 73 65 20 7b 0a 20 20 20 20 20    } else {.     
5930: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69                 i
5940: 66 20 7b 5b 63 63 2d 63 68 65 63 6b 2d 66 75 6e  f {[cc-check-fun
5950: 63 74 69 6f 6e 73 20 54 63 6c 5f 43 72 65 61 74  ctions Tcl_Creat
5960: 65 49 6e 74 65 72 70 5d 7d 20 7b 0a 20 20 20 20  eInterp]} {.    
5970: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
5980: 20 20 20 20 73 65 74 20 66 6f 75 6e 64 74 63 6c      set foundtcl
5990: 20 31 0a 20 20 20 20 20 20 20 20 20 20 20 20 20   1.             
59a0: 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20         }.       
59b0: 20 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20           }.     
59c0: 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20         }.       
59d0: 20 7d 0a 20 20 20 20 20 20 20 20 69 66 20 7b 21   }.        if {!
59e0: 24 66 6f 75 6e 64 74 63 6c 20 26 26 20 21 5b 73  $foundtcl && ![s
59f0: 74 72 69 6e 67 20 6d 61 74 63 68 20 2a 2d 6c 70  tring match *-lp
5a00: 74 68 72 65 61 64 2a 20 24 6c 69 62 73 5d 7d 20  thread* $libs]} 
5a10: 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 20  {.            # 
5a20: 4f 6e 20 73 6f 6d 65 20 73 79 73 74 65 6d 73 2c  On some systems,
5a30: 20 54 43 4c 5f 4c 49 42 5f 53 50 45 43 20 61 70   TCL_LIB_SPEC ap
5a40: 70 65 61 72 73 20 74 6f 20 62 65 20 6d 69 73 73  pears to be miss
5a50: 69 6e 67 0a 20 20 20 20 20 20 20 20 20 20 20 20  ing.            
5a60: 23 20 22 2d 6c 70 74 68 72 65 61 64 22 2e 20 20  # "-lpthread".  
5a70: 54 72 79 20 61 64 64 69 6e 67 20 69 74 2e 0a 20  Try adding it.. 
5a80: 20 20 20 20 20 20 20 20 20 20 20 6d 73 67 2d 72             msg-r
5a90: 65 73 75 6c 74 20 22 41 64 64 69 6e 67 20 5c 22  esult "Adding \"
5aa0: 2d 6c 70 74 68 72 65 61 64 5c 22 20 61 6e 64 20  -lpthread\" and 
5ab0: 72 65 74 72 79 69 6e 67 20 66 6f 72 20 54 63 6c  retrying for Tcl
5ac0: 2e 2e 2e 22 0a 20 20 20 20 20 20 20 20 20 20 20  ...".           
5ad0: 20 73 65 74 20 6c 69 62 73 20 22 24 6c 69 62 73   set libs "$libs
5ae0: 20 2d 6c 70 74 68 72 65 61 64 22 0a 20 20 20 20   -lpthread".    
5af0: 20 20 20 20 20 20 20 20 63 63 2d 77 69 74 68 20          cc-with 
5b00: 5b 6c 69 73 74 20 2d 63 66 6c 61 67 73 20 24 63  [list -cflags $c
5b10: 66 6c 61 67 73 20 2d 6c 69 62 73 20 24 6c 69 62  flags -libs $lib
5b20: 73 5d 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20  s] {.           
5b30: 20 20 20 20 20 69 66 20 7b 24 74 63 6c 73 74 75       if {$tclstu
5b40: 62 73 7d 20 7b 0a 20 20 20 20 20 20 20 20 20 20  bs} {.          
5b50: 20 20 20 20 20 20 20 20 20 20 69 66 20 7b 5b 63            if {[c
5b60: 63 2d 63 68 65 63 6b 2d 66 75 6e 63 74 69 6f 6e  c-check-function
5b70: 73 20 54 63 6c 5f 49 6e 69 74 53 74 75 62 73 5d  s Tcl_InitStubs]
5b80: 7d 20 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20  } {.            
5b90: 20 20 20 20 20 20 20 20 20 20 20 20 73 65 74 20              set 
5ba0: 66 6f 75 6e 64 74 63 6c 20 31 0a 20 20 20 20 20  foundtcl 1.     
5bb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d                 }
5bc0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
5bd0: 20 7d 20 65 6c 73 65 20 7b 0a 20 20 20 20 20 20   } else {.      
5be0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66                if
5bf0: 20 7b 5b 63 63 2d 63 68 65 63 6b 2d 66 75 6e 63   {[cc-check-func
5c00: 74 69 6f 6e 73 20 54 63 6c 5f 43 72 65 61 74 65  tions Tcl_Create
5c10: 49 6e 74 65 72 70 5d 7d 20 7b 0a 20 20 20 20 20  Interp]} {.     
5c20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
5c30: 20 20 20 73 65 74 20 66 6f 75 6e 64 74 63 6c 20     set foundtcl 
5c40: 31 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  1.              
5c50: 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20        }.        
5c60: 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20          }.      
5c70: 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20        }.        
5c80: 7d 0a 20 20 20 20 20 20 20 20 69 66 20 7b 21 24  }.        if {!$
5c90: 66 6f 75 6e 64 74 63 6c 7d 20 7b 0a 20 20 20 20  foundtcl} {.    
5ca0: 20 20 20 20 20 20 20 20 69 66 20 7b 24 74 63 6c          if {$tcl
5cb0: 73 74 75 62 73 7d 20 7b 0a 20 20 20 20 20 20 20  stubs} {.       
5cc0: 20 20 20 20 20 20 20 20 20 75 73 65 72 2d 65 72           user-er
5cd0: 72 6f 72 20 22 43 61 6e 6e 6f 74 20 66 69 6e 64  ror "Cannot find
5ce0: 20 61 20 75 73 61 62 6c 65 20 54 63 6c 20 73 74   a usable Tcl st
5cf0: 75 62 73 20 6c 69 62 72 61 72 79 20 24 6d 73 67  ubs library $msg
5d00: 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 20  ".            } 
5d10: 65 6c 73 65 20 7b 0a 20 20 20 20 20 20 20 20 20  else {.         
5d20: 20 20 20 20 20 20 20 75 73 65 72 2d 65 72 72 6f         user-erro
5d30: 72 20 22 43 61 6e 6e 6f 74 20 66 69 6e 64 20 61  r "Cannot find a
5d40: 20 75 73 61 62 6c 65 20 54 63 6c 20 6c 69 62 72   usable Tcl libr
5d50: 61 72 79 20 24 6d 73 67 22 0a 20 20 20 20 20 20  ary $msg".      
5d60: 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20        }.        
5d70: 7d 0a 20 20 20 20 7d 0a 20 20 20 20 73 65 74 20  }.    }.    set 
5d80: 76 65 72 73 69 6f 6e 20 24 74 63 6c 63 6f 6e 66  version $tclconf
5d90: 69 67 28 54 43 4c 5f 56 45 52 53 49 4f 4e 29 24  ig(TCL_VERSION)$
5da0: 74 63 6c 63 6f 6e 66 69 67 28 54 43 4c 5f 50 41  tclconfig(TCL_PA
5db0: 54 43 48 5f 4c 45 56 45 4c 29 0a 20 20 20 20 6d  TCH_LEVEL).    m
5dc0: 73 67 2d 72 65 73 75 6c 74 20 22 46 6f 75 6e 64  sg-result "Found
5dd0: 20 54 63 6c 20 24 76 65 72 73 69 6f 6e 20 61 74   Tcl $version at
5de0: 20 24 74 63 6c 63 6f 6e 66 69 67 28 54 43 4c 5f   $tclconfig(TCL_
5df0: 50 52 45 46 49 58 29 22 0a 20 20 20 20 69 66 20  PREFIX)".    if 
5e00: 7b 21 24 74 63 6c 70 72 69 76 61 74 65 73 74 75  {!$tclprivatestu
5e10: 62 73 7d 20 7b 0a 20 20 20 20 20 20 20 20 64 65  bs} {.        de
5e20: 66 69 6e 65 2d 61 70 70 65 6e 64 20 4c 49 42 53  fine-append LIBS
5e30: 20 24 6c 69 62 73 0a 20 20 20 20 7d 0a 20 20 20   $libs.    }.   
5e40: 20 64 65 66 69 6e 65 2d 61 70 70 65 6e 64 20 45   define-append E
5e50: 58 54 52 41 5f 43 46 4c 41 47 53 20 24 63 66 6c  XTRA_CFLAGS $cfl
5e60: 61 67 73 0a 20 20 20 20 64 65 66 69 6e 65 2d 61  ags.    define-a
5e70: 70 70 65 6e 64 20 43 46 4c 41 47 53 20 24 63 66  ppend CFLAGS $cf
5e80: 6c 61 67 73 0a 20 20 20 20 69 66 20 7b 5b 69 6e  lags.    if {[in
5e90: 66 6f 20 65 78 69 73 74 73 20 7a 6c 69 62 70 61  fo exists zlibpa
5ea0: 74 68 5d 20 26 26 20 24 7a 6c 69 62 70 61 74 68  th] && $zlibpath
5eb0: 20 65 71 20 22 74 72 65 65 22 7d 20 7b 0a 20 20   eq "tree"} {.  
5ec0: 20 20 20 20 23 0a 20 20 20 20 20 20 23 20 4e 4f      #.      # NO
5ed0: 54 45 3a 20 57 68 65 6e 20 75 73 69 6e 67 20 7a  TE: When using z
5ee0: 6c 69 62 20 69 6e 20 74 68 65 20 73 6f 75 72 63  lib in the sourc
5ef0: 65 20 74 72 65 65 2c 20 70 72 65 76 65 6e 74 20  e tree, prevent 
5f00: 54 63 6c 20 66 72 6f 6d 0a 20 20 20 20 20 20 23  Tcl from.      #
5f10: 20 20 20 20 20 20 20 70 75 6c 6c 69 6e 67 20 69         pulling i
5f20: 6e 20 74 68 65 20 73 79 73 74 65 6d 20 6f 6e 65  n the system one
5f30: 2e 0a 20 20 20 20 20 20 23 0a 20 20 20 20 20 20  ..      #.      
5f40: 73 65 74 20 74 63 6c 63 6f 6e 66 69 67 28 54 43  set tclconfig(TC
5f50: 4c 5f 4c 44 5f 46 4c 41 47 53 29 20 5b 73 74 72  L_LD_FLAGS) [str
5f60: 69 6e 67 20 6d 61 70 20 5b 6c 69 73 74 20 2d 6c  ing map [list -l
5f70: 7a 20 22 22 5d 20 5c 0a 20 20 20 20 20 20 20 20  z ""] \.        
5f80: 20 20 24 74 63 6c 63 6f 6e 66 69 67 28 54 43 4c    $tclconfig(TCL
5f90: 5f 4c 44 5f 46 4c 41 47 53 29 5d 0a 20 20 20 20  _LD_FLAGS)].    
5fa0: 7d 0a 20 20 20 20 23 0a 20 20 20 20 23 20 4e 4f  }.    #.    # NO
5fb0: 54 45 3a 20 52 65 6d 6f 76 65 20 22 2d 6c 64 6c  TE: Remove "-ldl
5fc0: 22 20 66 72 6f 6d 20 74 68 65 20 54 43 4c 5f 4c  " from the TCL_L
5fd0: 44 5f 46 4c 41 47 53 20 62 65 63 61 75 73 65 20  D_FLAGS because 
5fe0: 69 74 20 77 69 6c 6c 20 62 65 0a 20 20 20 20 23  it will be.    #
5ff0: 20 20 20 20 20 20 20 62 65 20 63 68 65 63 6b 65         be checke
6000: 64 20 66 6f 72 20 6e 65 61 72 20 74 68 65 20 62  d for near the b
6010: 6f 74 74 6f 6d 20 6f 66 20 74 68 69 73 20 66 69  ottom of this fi
6020: 6c 65 2e 0a 20 20 20 20 23 0a 20 20 20 20 73 65  le..    #.    se
6030: 74 20 74 63 6c 63 6f 6e 66 69 67 28 54 43 4c 5f  t tclconfig(TCL_
6040: 4c 44 5f 46 4c 41 47 53 29 20 5b 73 74 72 69 6e  LD_FLAGS) [strin
6050: 67 20 6d 61 70 20 5b 6c 69 73 74 20 2d 6c 64 6c  g map [list -ldl
6060: 20 22 22 5d 20 5c 0a 20 20 20 20 20 20 20 20 24   ""] \.        $
6070: 74 63 6c 63 6f 6e 66 69 67 28 54 43 4c 5f 4c 44  tclconfig(TCL_LD
6080: 5f 46 4c 41 47 53 29 5d 0a 20 20 20 20 64 65 66  _FLAGS)].    def
6090: 69 6e 65 2d 61 70 70 65 6e 64 20 45 58 54 52 41  ine-append EXTRA
60a0: 5f 4c 44 46 4c 41 47 53 20 24 74 63 6c 63 6f 6e  _LDFLAGS $tclcon
60b0: 66 69 67 28 54 43 4c 5f 4c 44 5f 46 4c 41 47 53  fig(TCL_LD_FLAGS
60c0: 29 0a 20 20 20 20 64 65 66 69 6e 65 20 46 4f 53  ).    define FOS
60d0: 53 49 4c 5f 45 4e 41 42 4c 45 5f 54 43 4c 0a 7d  SIL_ENABLE_TCL.}
60e0: 0a 0a 23 20 45 6d 73 63 72 69 70 74 65 6e 20 69  ..# Emscripten i
60f0: 73 20 61 20 70 75 72 65 6c 79 20 6f 70 74 69 6f  s a purely optio
6100: 6e 61 6c 20 63 6f 6d 70 6f 6e 65 6e 74 20 75 73  nal component us
6110: 65 64 20 6f 6e 6c 79 20 66 6f 72 20 64 6f 69 6e  ed only for doin
6120: 67 0a 23 20 69 6e 2d 74 72 65 65 20 62 75 69 6c  g.# in-tree buil
6130: 64 73 20 6f 66 20 57 41 53 4d 20 73 74 75 66 66  ds of WASM stuff
6140: 2c 20 61 73 20 6f 70 70 6f 73 65 64 20 74 6f 20  , as opposed to 
6150: 57 41 53 4d 20 62 69 6e 61 72 69 65 73 20 77 65  WASM binaries we
6160: 20 69 6d 70 6f 72 74 0a 23 20 66 72 6f 6d 20 6f   import.# from o
6170: 74 68 65 72 20 70 6c 61 63 65 73 2e 20 54 68 69  ther places. Thi
6180: 73 20 69 73 20 6f 6e 6c 79 20 73 65 74 20 75 70  s is only set up
6190: 20 66 6f 72 20 55 6e 69 78 2d 73 74 79 6c 65 20   for Unix-style 
61a0: 4f 53 65 73 20 61 6e 64 20 69 73 0a 23 20 75 6e  OSes and is.# un
61b0: 74 65 73 74 65 64 20 61 6e 79 77 68 65 72 65 20  tested anywhere 
61c0: 62 75 74 20 4c 69 6e 75 78 2e 0a 73 65 74 20 65  but Linux..set e
61d0: 6d 73 64 6b 48 6f 6d 65 20 5b 6f 70 74 2d 76 61  msdkHome [opt-va
61e0: 6c 20 77 69 74 68 2d 65 6d 73 64 6b 5d 0a 64 65  l with-emsdk].de
61f0: 66 69 6e 65 20 45 4d 53 44 4b 5f 48 4f 4d 45 20  fine EMSDK_HOME 
6200: 22 22 0a 64 65 66 69 6e 65 20 45 4d 53 44 4b 5f  "".define EMSDK_
6210: 45 4e 56 20 22 22 0a 64 65 66 69 6e 65 20 45 4d  ENV "".define EM
6220: 43 43 5f 4f 50 54 20 22 2d 4f 7a 22 0a 69 66 20  CC_OPT "-Oz".if 
6230: 7b 24 65 6d 73 64 6b 48 6f 6d 65 20 65 71 20 22  {$emsdkHome eq "
6240: 22 20 26 26 20 5b 69 6e 66 6f 20 65 78 69 73 74  " && [info exist
6250: 73 20 3a 3a 65 6e 76 28 45 4d 53 44 4b 29 5d 7d  s ::env(EMSDK)]}
6260: 20 7b 0a 20 20 23 20 46 61 6c 6c 20 62 61 63 6b   {.  # Fall back
6270: 20 74 6f 20 63 68 65 63 6b 69 6e 67 20 74 68 65   to checking the
6280: 20 65 6e 76 69 72 6f 6e 6d 65 6e 74 2e 20 24 45   environment. $E
6290: 4d 53 44 4b 20 67 65 74 73 20 73 65 74 0a 20 20  MSDK gets set.  
62a0: 23 20 62 79 20 73 6f 75 72 63 69 6e 67 20 65 6d  # by sourcing em
62b0: 73 64 6b 5f 65 6e 76 2e 73 68 2e 0a 20 20 73 65  sdk_env.sh..  se
62c0: 74 20 65 6d 73 64 6b 48 6f 6d 65 20 24 3a 3a 65  t emsdkHome $::e
62d0: 6e 76 28 45 4d 53 44 4b 29 0a 7d 0a 69 66 20 7b  nv(EMSDK).}.if {
62e0: 24 65 6d 73 64 6b 48 6f 6d 65 20 6e 65 20 22 22  $emsdkHome ne ""
62f0: 7d 20 7b 0a 20 20 64 65 66 69 6e 65 20 45 4d 53  } {.  define EMS
6300: 44 4b 5f 48 4f 4d 45 20 24 65 6d 73 64 6b 48 6f  DK_HOME $emsdkHo
6310: 6d 65 0a 20 20 73 65 74 20 65 6d 73 64 6b 45 6e  me.  set emsdkEn
6320: 76 20 22 24 65 6d 73 64 6b 48 6f 6d 65 2f 65 6d  v "$emsdkHome/em
6330: 73 64 6b 5f 65 6e 76 2e 73 68 22 0a 20 20 69 66  sdk_env.sh".  if
6340: 20 7b 5b 66 69 6c 65 20 65 78 69 73 74 73 20 24   {[file exists $
6350: 65 6d 73 64 6b 45 6e 76 5d 7d 20 7b 0a 20 20 20  emsdkEnv]} {.   
6360: 20 70 75 74 73 20 22 55 73 69 6e 67 20 45 6d 73   puts "Using Ems
6370: 63 72 69 70 74 65 6e 20 53 44 4b 20 65 6e 76 69  cripten SDK envi
6380: 72 6f 6e 6d 65 6e 74 20 66 72 6f 6d 20 24 65 6d  ronment from $em
6390: 73 64 6b 45 6e 76 2e 22 0a 20 20 20 20 64 65 66  sdkEnv.".    def
63a0: 69 6e 65 20 45 4d 53 44 4b 5f 45 4e 56 20 24 65  ine EMSDK_ENV $e
63b0: 6d 73 64 6b 45 6e 76 0a 20 20 20 20 69 66 20 7b  msdkEnv.    if {
63c0: 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 3a 3a 65  [info exists ::e
63d0: 6e 76 28 45 4d 43 43 5f 4f 50 54 29 5d 7d 20 7b  nv(EMCC_OPT)]} {
63e0: 0a 20 20 20 20 20 20 64 65 66 69 6e 65 20 45 4d  .      define EM
63f0: 43 43 5f 4f 50 54 20 24 3a 3a 65 6e 76 28 45 4d  CC_OPT $::env(EM
6400: 43 43 5f 4f 50 54 29 0a 20 20 20 20 7d 0a 20 20  CC_OPT).    }.  
6410: 7d 20 65 6c 73 65 20 7b 0a 20 20 20 20 70 75 74  } else {.    put
6420: 73 20 22 65 6d 73 64 6b 5f 65 6e 76 2e 73 68 20  s "emsdk_env.sh 
6430: 6e 6f 74 20 66 6f 75 6e 64 2e 20 41 73 73 75 6d  not found. Assum
6440: 69 6e 67 20 65 6d 63 63 20 69 73 20 69 6e 20 74  ing emcc is in t
6450: 68 65 20 50 41 54 48 2e 22 0a 20 20 7d 0a 7d 0a  he PATH.".  }.}.
6460: 0a 23 20 4e 65 74 77 6f 72 6b 20 66 75 6e 63 74  .# Network funct
6470: 69 6f 6e 73 20 72 65 71 75 69 72 65 20 6c 69 62  ions require lib
6480: 72 61 72 69 65 73 20 6f 6e 20 73 6f 6d 65 20 73  raries on some s
6490: 79 73 74 65 6d 73 0a 63 63 2d 63 68 65 63 6b 2d  ystems.cc-check-
64a0: 66 75 6e 63 74 69 6f 6e 2d 69 6e 2d 6c 69 62 20  function-in-lib 
64b0: 67 65 74 68 6f 73 74 62 79 6e 61 6d 65 20 6e 73  gethostbyname ns
64c0: 6c 0a 69 66 20 7b 21 5b 63 63 2d 63 68 65 63 6b  l.if {![cc-check
64d0: 2d 66 75 6e 63 74 69 6f 6e 2d 69 6e 2d 6c 69 62  -function-in-lib
64e0: 20 73 6f 63 6b 65 74 20 7b 73 6f 63 6b 65 74 20   socket {socket 
64f0: 6e 65 74 77 6f 72 6b 7d 5d 7d 20 7b 0a 20 20 20  network}]} {.   
6500: 20 23 20 4c 61 73 74 20 72 65 73 6f 72 74 2c 20   # Last resort, 
6510: 6d 61 79 20 62 65 20 57 69 6e 64 6f 77 73 0a 20  may be Windows. 
6520: 20 20 20 69 66 20 7b 5b 69 73 5f 6d 69 6e 67 77     if {[is_mingw
6530: 5d 7d 20 7b 0a 20 20 20 20 20 20 20 20 64 65 66  ]} {.        def
6540: 69 6e 65 2d 61 70 70 65 6e 64 20 4c 49 42 53 20  ine-append LIBS 
6550: 2d 6c 77 73 6f 63 6b 33 32 0a 20 20 20 20 7d 0a  -lwsock32.    }.
6560: 7d 0a 0a 23 20 54 68 65 20 53 4d 54 50 20 6d 6f  }..# The SMTP mo
6570: 64 75 6c 65 20 72 65 71 75 69 72 65 73 20 73 70  dule requires sp
6580: 65 63 69 61 6c 20 6c 69 62 72 61 72 69 65 73 20  ecial libraries 
6590: 61 6e 64 20 68 65 61 64 65 72 73 20 66 6f 72 20  and headers for 
65a0: 4d 58 20 44 4e 53 0a 23 20 72 65 63 6f 72 64 20  MX DNS.# record 
65b0: 6c 6f 6f 6b 75 70 73 20 61 6e 64 20 73 75 63 68  lookups and such
65c0: 2e 0a 63 63 2d 63 68 65 63 6b 2d 69 6e 63 6c 75  ..cc-check-inclu
65d0: 64 65 73 20 61 72 70 61 2f 6e 61 6d 65 73 65 72  des arpa/nameser
65e0: 2e 68 0a 63 63 2d 69 6e 63 6c 75 64 65 2d 6e 65  .h.cc-include-ne
65f0: 65 64 73 20 62 69 6e 64 2f 72 65 73 6f 6c 76 2e  eds bind/resolv.
6600: 68 20 6e 65 74 69 6e 65 74 2f 69 6e 2e 68 0a 63  h netinet/in.h.c
6610: 63 2d 63 68 65 63 6b 2d 69 6e 63 6c 75 64 65 73  c-check-includes
6620: 20 62 69 6e 64 2f 72 65 73 6f 6c 76 2e 68 0a 63   bind/resolv.h.c
6630: 63 2d 63 68 65 63 6b 2d 69 6e 63 6c 75 64 65 73  c-check-includes
6640: 20 72 65 73 6f 6c 76 2e 68 0a 69 66 20 7b 20 20   resolv.h.if {  
6650: 20 20 21 28 28 5b 63 63 2d 63 68 65 63 6b 2d 66    !(([cc-check-f
6660: 75 6e 63 74 69 6f 6e 2d 69 6e 2d 6c 69 62 20 64  unction-in-lib d
6670: 6e 5f 65 78 70 61 6e 64 20 72 65 73 6f 6c 76 5d  n_expand resolv]
6680: 20 7c 7c 0a 20 20 20 20 20 20 20 20 20 20 20 5b   ||.           [
6690: 63 63 2d 63 68 65 63 6b 2d 66 75 6e 63 74 69 6f  cc-check-functio
66a0: 6e 2d 69 6e 2d 6c 69 62 20 20 20 6e 73 5f 6e 61  n-in-lib   ns_na
66b0: 6d 65 5f 75 6e 63 6f 6d 70 72 65 73 73 20 7b 62  me_uncompress {b
66c0: 69 6e 64 20 72 65 73 6f 6c 76 7d 5d 20 7c 7c 0a  ind resolv}] ||.
66d0: 20 20 20 20 20 20 20 20 20 20 20 5b 63 63 2d 63             [cc-c
66e0: 68 65 63 6b 2d 66 75 6e 63 74 69 6f 6e 2d 69 6e  heck-function-in
66f0: 2d 6c 69 62 20 5f 5f 6e 73 5f 6e 61 6d 65 5f 75  -lib __ns_name_u
6700: 6e 63 6f 6d 70 72 65 73 73 20 7b 62 69 6e 64 20  ncompress {bind 
6710: 72 65 73 6f 6c 76 7d 5d 29 20 26 26 0a 20 20 20  resolv}]) &&.   
6720: 20 20 20 20 20 20 20 28 5b 63 63 2d 63 68 65 63         ([cc-chec
6730: 6b 2d 66 75 6e 63 74 69 6f 6e 2d 69 6e 2d 6c 69  k-function-in-li
6740: 62 20 20 20 6e 73 5f 70 61 72 73 65 72 72 20 7b  b   ns_parserr {
6750: 62 69 6e 64 20 72 65 73 6f 6c 76 7d 5d 20 7c 7c  bind resolv}] ||
6760: 0a 20 20 20 20 20 20 20 20 20 20 20 5b 63 63 2d  .           [cc-
6770: 63 68 65 63 6b 2d 66 75 6e 63 74 69 6f 6e 2d 69  check-function-i
6780: 6e 2d 6c 69 62 20 5f 5f 6e 73 5f 70 61 72 73 65  n-lib __ns_parse
6790: 72 72 20 7b 62 69 6e 64 20 72 65 73 6f 6c 76 7d  rr {bind resolv}
67a0: 5d 29 20 26 26 0a 20 20 20 20 20 20 20 20 20 20  ]) &&.          
67b0: 28 5b 63 63 2d 63 68 65 63 6b 2d 66 75 6e 63 74  ([cc-check-funct
67c0: 69 6f 6e 2d 69 6e 2d 6c 69 62 20 20 20 72 65 73  ion-in-lib   res
67d0: 5f 71 75 65 72 79 20 7b 62 69 6e 64 20 72 65 73  _query {bind res
67e0: 6f 6c 76 7d 5d 20 7c 7c 0a 20 20 20 20 20 20 20  olv}] ||.       
67f0: 20 20 20 20 5b 63 63 2d 63 68 65 63 6b 2d 66 75      [cc-check-fu
6800: 6e 63 74 69 6f 6e 2d 69 6e 2d 6c 69 62 20 5f 5f  nction-in-lib __
6810: 72 65 73 5f 71 75 65 72 79 20 7b 62 69 6e 64 20  res_query {bind 
6820: 72 65 73 6f 6c 76 7d 5d 29 29 7d 20 7b 0a 20 20  resolv}]))} {.  
6830: 20 20 6d 73 67 2d 72 65 73 75 6c 74 20 22 57 41    msg-result "WA
6840: 52 4e 49 4e 47 3a 20 53 4d 54 50 20 66 65 61 74  RNING: SMTP feat
6850: 75 72 65 20 77 69 6c 6c 20 6e 6f 74 20 62 65 20  ure will not be 
6860: 61 62 6c 65 20 74 6f 20 6c 6f 6f 6b 20 75 70 20  able to look up 
6870: 6c 6f 63 61 6c 20 4d 58 2e 22 0a 7d 0a 63 63 2d  local MX.".}.cc-
6880: 63 68 65 63 6b 2d 66 75 6e 63 74 69 6f 6e 2d 69  check-function-i
6890: 6e 2d 6c 69 62 20 72 65 73 5f 39 5f 6e 73 5f 69  n-lib res_9_ns_i
68a0: 6e 69 74 70 61 72 73 65 20 72 65 73 6f 6c 76 0a  nitparse resolv.
68b0: 0a 23 20 4f 74 68 65 72 20 6e 6f 6e 73 74 61 6e  .# Other nonstan
68c0: 64 61 72 64 20 66 75 6e 63 74 69 6f 6e 20 63 68  dard function ch
68d0: 65 63 6b 73 0a 63 63 2d 63 68 65 63 6b 2d 66 75  ecks.cc-check-fu
68e0: 6e 63 74 69 6f 6e 73 20 75 74 69 6d 65 0a 63 63  nctions utime.cc
68f0: 2d 63 68 65 63 6b 2d 66 75 6e 63 74 69 6f 6e 73  -check-functions
6900: 20 75 73 6c 65 65 70 0a 63 63 2d 63 68 65 63 6b   usleep.cc-check
6910: 2d 66 75 6e 63 74 69 6f 6e 73 20 73 74 72 63 68  -functions strch
6920: 72 6e 75 6c 0a 63 63 2d 63 68 65 63 6b 2d 66 75  rnul.cc-check-fu
6930: 6e 63 74 69 6f 6e 73 20 70 6c 65 64 67 65 0a 63  nctions pledge.c
6940: 63 2d 63 68 65 63 6b 2d 66 75 6e 63 74 69 6f 6e  c-check-function
6950: 73 20 62 61 63 6b 74 72 61 63 65 0a 0a 23 20 54  s backtrace..# T
6960: 65 72 6d 75 78 20 6f 6e 20 41 6e 64 72 6f 69 64  ermux on Android
6970: 20 61 64 64 73 20 22 67 65 74 70 61 73 73 28 63   adds "getpass(c
6980: 68 61 72 20 2a 29 22 20 74 6f 20 75 6e 69 73 74  har *)" to unist
6990: 64 2e 68 2c 20 73 6f 20 63 68 65 63 6b 20 74 68  d.h, so check th
69a0: 69 73 20 73 6f 20 77 65 0a 23 20 67 75 61 72 64  is so we.# guard
69b0: 20 61 67 61 69 6e 73 74 20 69 6e 63 6c 75 64 69   against includi
69c0: 6e 67 20 69 74 20 61 67 61 69 6e 3b 20 75 73 65  ng it again; use
69d0: 20 63 63 74 65 73 74 20 61 73 20 63 63 2d 63 68   cctest as cc-ch
69e0: 65 63 6b 2d 66 75 6e 63 74 69 6f 6e 73 20 61 6e  eck-functions an
69f0: 64 20 0a 23 20 63 63 74 65 73 74 5f 66 75 6e 63  d .# cctest_func
6a00: 74 69 6f 6e 20 63 68 65 63 6b 20 66 6f 72 20 22  tion check for "
6a10: 67 65 74 70 61 73 73 28 29 22 20 77 69 74 68 20  getpass()" with 
6a20: 6e 6f 20 61 72 67 73 20 61 6e 64 20 66 61 69 6c  no args and fail
6a30: 0a 69 66 20 7b 5b 63 63 74 65 73 74 20 2d 6c 69  .if {[cctest -li
6a40: 6e 6b 20 31 20 2d 69 6e 63 6c 75 64 65 73 20 7b  nk 1 -includes {
6a50: 75 6e 69 73 74 64 2e 68 7d 20 2d 63 6f 64 65 20  unistd.h} -code 
6a60: 22 67 65 74 70 61 73 73 28 30 29 3b 22 5d 7d 20  "getpass(0);"]} 
6a70: 7b 0a 20 20 20 20 64 65 66 69 6e 65 20 46 4f 53  {.    define FOS
6a80: 53 49 4c 5f 48 41 56 45 5f 47 45 54 50 41 53 53  SIL_HAVE_GETPASS
6a90: 20 31 0a 20 20 20 20 6d 73 67 2d 72 65 73 75 6c   1.    msg-resul
6aa0: 74 20 22 46 6f 75 6e 64 20 67 65 74 70 61 73 73  t "Found getpass
6ab0: 28 29 20 77 69 74 68 20 75 6e 69 73 74 64 2e 68  () with unistd.h
6ac0: 22 0a 7d 0a 0a 23 20 43 68 65 63 6b 20 66 6f 72  ".}..# Check for
6ad0: 20 67 65 74 6c 6f 61 64 61 76 67 28 29 2c 20 61   getloadavg(), a
6ae0: 6e 64 20 69 66 20 69 74 20 64 6f 65 73 6e 27 74  nd if it doesn't
6af0: 20 65 78 69 73 74 2c 20 64 65 66 69 6e 65 20 46   exist, define F
6b00: 4f 53 53 49 4c 5f 4f 4d 49 54 5f 4c 4f 41 44 5f  OSSIL_OMIT_LOAD_
6b10: 41 56 45 52 41 47 45 0a 69 66 20 7b 21 5b 63 63  AVERAGE.if {![cc
6b20: 2d 63 68 65 63 6b 2d 66 75 6e 63 74 69 6f 6e 73  -check-functions
6b30: 20 67 65 74 6c 6f 61 64 61 76 67 5d 20 7c 7c 0a   getloadavg] ||.
6b40: 20 20 20 20 21 5b 63 63 74 65 73 74 20 2d 6c 69      ![cctest -li
6b50: 6e 6b 20 31 20 2d 69 6e 63 6c 75 64 65 73 20 7b  nk 1 -includes {
6b60: 75 6e 69 73 74 64 2e 68 7d 20 2d 63 6f 64 65 20  unistd.h} -code 
6b70: 22 64 6f 75 62 6c 65 20 61 5c 5b 33 5c 5d 3b 20  "double a\[3\]; 
6b80: 67 65 74 6c 6f 61 64 61 76 67 28 61 2c 33 29 3b  getloadavg(a,3);
6b90: 22 5d 7d 20 7b 0a 20 20 64 65 66 69 6e 65 20 46  "]} {.  define F
6ba0: 4f 53 53 49 4c 5f 4f 4d 49 54 5f 4c 4f 41 44 5f  OSSIL_OMIT_LOAD_
6bb0: 41 56 45 52 41 47 45 20 31 0a 20 20 6d 73 67 2d  AVERAGE 1.  msg-
6bc0: 72 65 73 75 6c 74 20 22 4c 6f 61 64 20 61 76 65  result "Load ave
6bd0: 72 61 67 65 20 73 75 70 70 6f 72 74 20 75 6e 61  rage support una
6be0: 76 61 69 6c 61 62 6c 65 22 0a 7d 0a 0a 23 20 43  vailable".}..# C
6bf0: 68 65 63 6b 20 66 6f 72 20 67 65 74 70 61 73 73  heck for getpass
6c00: 70 68 72 61 73 65 28 29 20 66 6f 72 20 53 6f 6c  phrase() for Sol
6c10: 61 72 69 73 20 31 30 20 77 68 65 72 65 20 67 65  aris 10 where ge
6c20: 74 70 61 73 73 28 29 20 74 72 75 6e 63 61 74 65  tpass() truncate
6c30: 73 20 74 6f 20 31 30 20 63 68 61 72 73 0a 69 66  s to 10 chars.if
6c40: 20 7b 21 5b 63 63 2d 63 68 65 63 6b 2d 66 75 6e   {![cc-check-fun
6c50: 63 74 69 6f 6e 73 20 67 65 74 70 61 73 73 70 68  ctions getpassph
6c60: 72 61 73 65 5d 7d 20 7b 0a 20 20 20 20 23 20 48  rase]} {.    # H
6c70: 61 69 6b 75 20 6e 65 65 64 73 20 74 68 69 73 0a  aiku needs this.
6c80: 20 20 20 20 63 63 2d 63 68 65 63 6b 2d 66 75 6e      cc-check-fun
6c90: 63 74 69 6f 6e 2d 69 6e 2d 6c 69 62 20 67 65 74  ction-in-lib get
6ca0: 70 61 73 73 20 62 73 64 0a 7d 0a 63 63 2d 63 68  pass bsd.}.cc-ch
6cb0: 65 63 6b 2d 66 75 6e 63 74 69 6f 6e 2d 69 6e 2d  eck-function-in-
6cc0: 6c 69 62 20 73 69 6e 20 6d 0a 0a 23 20 43 68 65  lib sin m..# Che
6cd0: 63 6b 20 66 6f 72 20 74 68 65 20 46 75 73 65 46  ck for the FuseF
6ce0: 53 20 6c 69 62 72 61 72 79 0a 69 66 20 7b 5b 6f  S library.if {[o
6cf0: 70 74 2d 62 6f 6f 6c 20 66 75 73 65 66 73 5d 7d  pt-bool fusefs]}
6d00: 20 7b 0a 20 20 69 66 20 7b 5b 6f 70 74 2d 62 6f   {.  if {[opt-bo
6d10: 6f 6c 20 73 74 61 74 69 63 5d 7d 20 7b 0a 20 20  ol static]} {.  
6d20: 20 20 20 6d 73 67 2d 72 65 73 75 6c 74 20 22 46     msg-result "F
6d30: 75 73 65 46 53 20 73 75 70 70 6f 72 74 20 64 69  useFS support di
6d40: 73 61 62 6c 65 64 20 64 75 65 20 74 6f 20 2d 73  sabled due to -s
6d50: 74 61 74 69 63 22 0a 20 20 7d 20 65 6c 73 65 69  tatic".  } elsei
6d60: 66 20 7b 5b 63 63 2d 63 68 65 63 6b 2d 66 75 6e  f {[cc-check-fun
6d70: 63 74 69 6f 6e 2d 69 6e 2d 6c 69 62 20 66 75 73  ction-in-lib fus
6d80: 65 5f 6d 6f 75 6e 74 20 66 75 73 65 5d 7d 20 7b  e_mount fuse]} {
6d90: 0a 20 20 20 20 20 64 65 66 69 6e 65 2d 61 70 70  .     define-app
6da0: 65 6e 64 20 45 58 54 52 41 5f 43 46 4c 41 47 53  end EXTRA_CFLAGS
6db0: 20 2d 44 46 4f 53 53 49 4c 5f 48 41 56 45 5f 46   -DFOSSIL_HAVE_F
6dc0: 55 53 45 46 53 0a 20 20 20 20 20 64 65 66 69 6e  USEFS.     defin
6dd0: 65 20 46 4f 53 53 49 4c 5f 48 41 56 45 5f 46 55  e FOSSIL_HAVE_FU
6de0: 53 45 46 53 20 31 0a 20 20 20 20 20 6d 73 67 2d  SEFS 1.     msg-
6df0: 72 65 73 75 6c 74 20 22 46 75 73 65 46 53 20 73  result "FuseFS s
6e00: 75 70 70 6f 72 74 20 65 6e 61 62 6c 65 64 22 0a  upport enabled".
6e10: 20 20 7d 0a 7d 0a 0a 23 23 23 23 23 23 23 23 23    }.}..#########
6e20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
6e30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
6e40: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
6e50: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  ###############.
6e60: 23 20 43 68 65 63 6b 73 20 74 68 65 20 63 6f 6d  # Checks the com
6e70: 70 69 6c 65 72 20 66 6f 72 20 63 6f 6d 70 69 6c  piler for compil
6e80: 65 5f 63 6f 6d 6d 61 6e 64 73 2e 6a 73 6f 6e 20  e_commands.json 
6e90: 73 75 70 70 6f 72 74 2e 0a 23 0a 23 20 52 65 74  support..#.# Ret
6ea0: 75 72 6e 73 20 31 20 69 66 20 73 75 70 70 6f 72  urns 1 if suppor
6eb0: 74 65 64 2c 20 65 6c 73 65 20 30 2e 20 44 65 66  ted, else 0. Def
6ec0: 69 6e 65 73 20 4d 41 4b 45 5f 43 4f 4d 50 49 4c  ines MAKE_COMPIL
6ed0: 41 54 49 4f 4e 5f 44 42 20 74 6f 20 22 79 65 73  ATION_DB to "yes
6ee0: 22 0a 23 20 69 66 20 73 75 70 70 6f 72 74 65 64  ".# if supported
6ef0: 2c 20 22 6e 6f 22 20 69 66 20 6e 6f 74 2e 0a 70  , "no" if not..p
6f00: 72 6f 63 20 63 68 65 63 6b 2d 63 6f 6d 70 69 6c  roc check-compil
6f10: 65 2d 63 6f 6d 6d 61 6e 64 73 20 7b 7d 20 7b 0a  e-commands {} {.
6f20: 20 20 20 20 6d 73 67 2d 63 68 65 63 6b 69 6e 67      msg-checking
6f30: 20 22 63 6f 6d 70 69 6c 65 5f 63 6f 6d 6d 61 6e   "compile_comman
6f40: 64 73 2e 6a 73 6f 6e 20 73 75 70 70 6f 72 74 2e  ds.json support.
6f50: 2e 2e 20 22 0a 20 20 20 20 69 66 20 7b 5b 63 63  .. ".    if {[cc
6f60: 74 65 73 74 20 2d 6c 61 6e 67 20 63 20 2d 63 66  test -lang c -cf
6f70: 6c 61 67 73 20 7b 2f 64 65 76 2f 6e 75 6c 6c 20  lags {/dev/null 
6f80: 2d 4d 4a 7d 20 2d 73 6f 75 72 63 65 20 7b 7d 5d  -MJ} -source {}]
6f90: 7d 20 7b 0a 20 20 20 20 20 20 20 20 23 20 54 68  } {.        # Th
6fa0: 69 73 20 74 65 73 74 20 72 65 70 6f 72 74 65 64  is test reported
6fb0: 6c 79 20 69 6e 63 6f 72 72 65 63 74 6c 79 20 73  ly incorrectly s
6fc0: 75 63 63 65 65 64 73 20 6f 6e 20 6f 6e 65 20 6f  ucceeds on one o
6fd0: 66 0a 20 20 20 20 20 20 20 20 23 20 4d 61 72 74  f.        # Mart
6fe0: 69 6e 20 47 2e 27 73 20 6f 6c 64 65 72 20 73 79  in G.'s older sy
6ff0: 73 74 65 6d 73 2e 0a 20 20 20 20 20 20 20 20 6d  stems..        m
7000: 73 67 2d 72 65 73 75 6c 74 20 22 63 6f 6d 70 69  sg-result "compi
7010: 6c 65 72 20 73 75 70 70 6f 72 74 73 20 63 6f 6d  ler supports com
7020: 70 69 6c 65 5f 63 6f 6d 6d 61 6e 64 73 2e 6a 73  pile_commands.js
7030: 6f 6e 22 0a 20 20 20 20 20 20 20 20 64 65 66 69  on".        defi
7040: 6e 65 20 4d 41 4b 45 5f 43 4f 4d 50 49 4c 41 54  ne MAKE_COMPILAT
7050: 49 4f 4e 5f 44 42 20 79 65 73 0a 20 20 20 20 20  ION_DB yes.     
7060: 20 20 20 72 65 74 75 72 6e 20 31 0a 20 20 20 20     return 1.    
7070: 7d 20 65 6c 73 65 20 7b 0a 20 20 20 20 20 20 20  } else {.       
7080: 20 6d 73 67 2d 72 65 73 75 6c 74 20 22 63 6f 6d   msg-result "com
7090: 70 69 6c 65 72 20 64 6f 65 73 20 6e 6f 74 20 73  piler does not s
70a0: 75 70 70 6f 72 74 20 63 6f 6d 70 69 6c 65 5f 63  upport compile_c
70b0: 6f 6d 6d 61 6e 64 73 2e 6a 73 6f 6e 22 0a 20 20  ommands.json".  
70c0: 20 20 20 20 20 20 64 65 66 69 6e 65 20 4d 41 4b        define MAK
70d0: 45 5f 43 4f 4d 50 49 4c 41 54 49 4f 4e 5f 44 42  E_COMPILATION_DB
70e0: 20 6e 6f 0a 20 20 20 20 20 20 20 20 72 65 74 75   no.        retu
70f0: 72 6e 20 30 0a 20 20 20 20 7d 0a 7d 0a 0a 64 65  rn 0.    }.}..de
7100: 66 69 6e 65 20 4d 41 4b 45 5f 43 4f 4d 50 49 4c  fine MAKE_COMPIL
7110: 41 54 49 4f 4e 5f 44 42 20 6e 6f 0a 69 66 20 7b  ATION_DB no.if {
7120: 21 24 6f 75 74 4f 66 54 72 65 65 42 75 69 6c 64  !$outOfTreeBuild
7130: 7d 20 7b 0a 20 20 69 66 20 7b 5b 6f 70 74 2d 62  } {.  if {[opt-b
7140: 6f 6f 6c 20 63 6f 6d 70 69 6c 65 2d 63 6f 6d 6d  ool compile-comm
7150: 61 6e 64 73 5d 7d 20 7b 0a 20 20 20 20 63 68 65  ands]} {.    che
7160: 63 6b 2d 63 6f 6d 70 69 6c 65 2d 63 6f 6d 6d 61  ck-compile-comma
7170: 6e 64 73 0a 20 20 7d 20 65 6c 73 65 20 7b 0a 20  nds.  } else {. 
7180: 20 20 20 70 75 74 73 20 22 55 73 65 20 2d 2d 63     puts "Use --c
7190: 6f 6d 70 69 6c 65 2d 63 6f 6d 6d 61 6e 64 73 20  ompile-commands 
71a0: 74 6f 20 65 6e 61 62 6c 65 20 63 68 65 63 6b 20  to enable check 
71b0: 66 6f 72 20 63 6f 6d 70 69 6c 65 2d 63 6f 6d 6d  for compile-comm
71c0: 61 6e 64 73 2d 63 61 70 61 62 6c 65 20 63 6f 6d  ands-capable com
71d0: 70 69 6c 65 72 2e 22 0a 20 20 7d 0a 7d 20 65 6c  piler.".  }.} el
71e0: 73 65 20 7b 0a 20 20 70 75 74 73 20 22 44 69 73  se {.  puts "Dis
71f0: 61 62 6c 69 6e 67 20 63 6f 6d 70 69 6c 65 5f 63  abling compile_c
7200: 6f 6d 6d 61 6e 64 73 2e 6a 73 6f 6e 20 63 68 65  ommands.json che
7210: 63 6b 20 66 6f 72 20 6f 75 74 2d 6f 66 2d 74 72  ck for out-of-tr
7220: 65 65 20 62 75 69 6c 64 2e 22 0a 20 20 23 20 54  ee build.".  # T
7230: 68 69 73 20 69 73 20 61 6e 20 61 74 74 65 6d 70  his is an attemp
7240: 74 20 74 6f 20 72 65 73 6f 6c 76 65 20 74 68 65  t to resolve the
7250: 20 70 72 6f 62 6c 65 6d 20 72 65 70 6f 72 74 65   problem reporte
7260: 64 20 61 74 0a 20 20 23 20 68 74 74 70 73 3a 2f  d at.  # https:/
7270: 2f 66 6f 73 73 69 6c 2d 73 63 6d 2e 6f 72 67 2f  /fossil-scm.org/
7280: 66 6f 72 75 6d 2f 66 6f 72 75 6d 70 6f 73 74 2f  forum/forumpost/
7290: 64 31 39 30 36 31 64 30 39 61 38 31 37 39 64 30  d19061d09a8179d0
72a0: 0a 7d 0a 0a 23 20 41 64 64 20 2d 66 73 61 6e 69  .}..# Add -fsani
72b0: 74 69 7a 65 20 63 6f 6d 70 69 6c 65 20 61 6e 64  tize compile and
72c0: 20 6c 69 6e 6b 20 6f 70 74 69 6f 6e 73 20 6c 61   link options la
72d0: 74 65 3a 20 77 65 20 64 6f 6e 27 74 20 77 61 6e  te: we don't wan
72e0: 74 20 74 68 65 20 43 0a 23 20 63 68 65 63 6b 73  t the C.# checks
72f0: 20 61 62 6f 76 65 20 74 6f 20 72 75 6e 20 77 69   above to run wi
7300: 74 68 20 74 68 6f 73 65 20 73 61 6e 69 74 69 7a  th those sanitiz
7310: 65 72 73 20 65 6e 61 62 6c 65 64 2e 20 20 49 74  ers enabled.  It
7320: 20 63 61 6e 20 6e 6f 74 20 6f 6e 6c 79 0a 23 20   can not only.# 
7330: 62 65 20 70 6f 69 6e 74 6c 65 73 73 2c 20 69 74  be pointless, it
7340: 20 63 61 6e 20 61 63 74 75 61 6c 6c 79 20 62 72   can actually br
7350: 65 61 6b 20 63 6f 72 72 65 63 74 20 74 65 73 74  eak correct test
7360: 73 2e 0a 73 65 74 20 66 73 61 6e 20 5b 6f 70 74  s..set fsan [opt
7370: 2d 76 61 6c 20 77 69 74 68 2d 73 61 6e 69 74 69  -val with-saniti
7380: 7a 65 72 5d 0a 69 66 20 7b 5b 73 74 72 69 6e 67  zer].if {[string
7390: 20 6c 65 6e 67 74 68 20 24 66 73 61 6e 5d 7d 20   length $fsan]} 
73a0: 7b 0a 20 20 20 20 64 65 66 69 6e 65 2d 61 70 70  {.    define-app
73b0: 65 6e 64 20 20 45 58 54 52 41 5f 43 46 4c 41 47  end  EXTRA_CFLAG
73c0: 53 20 2d 66 73 61 6e 69 74 69 7a 65 3d 24 66 73  S -fsanitize=$fs
73d0: 61 6e 0a 20 20 20 20 64 65 66 69 6e 65 2d 61 70  an.    define-ap
73e0: 70 65 6e 64 20 45 58 54 52 41 5f 4c 44 46 4c 41  pend EXTRA_LDFLA
73f0: 47 53 20 2d 66 73 61 6e 69 74 69 7a 65 3d 24 66  GS -fsanitize=$f
7400: 73 61 6e 0a 20 20 20 20 69 66 20 7b 5b 73 74 72  san.    if {[str
7410: 69 6e 67 20 66 69 72 73 74 20 22 75 6e 64 65 66  ing first "undef
7420: 69 6e 65 64 22 20 24 66 73 61 6e 5d 20 21 3d 20  ined" $fsan] != 
7430: 2d 31 7d 20 7b 0a 20 20 20 20 20 20 20 20 23 20  -1} {.        # 
7440: 57 65 20 6e 65 65 64 20 74 6f 20 6c 69 6e 6b 20  We need to link 
7450: 77 69 74 68 20 6c 69 62 75 62 73 61 6e 20 69 66  with libubsan if
7460: 20 77 65 27 72 65 20 63 6f 6d 70 69 6c 69 6e 67   we're compiling
7470: 20 75 6e 64 65 72 0a 20 20 20 20 20 20 20 20 23   under.        #
7480: 20 47 43 43 20 77 69 74 68 20 2d 66 73 61 6e 69   GCC with -fsani
7490: 74 69 7a 65 3d 75 6e 64 65 66 69 6e 65 64 2e 0a  tize=undefined..
74a0: 20 20 20 20 20 20 20 20 63 63 2d 63 68 65 63 6b          cc-check
74b0: 2d 66 75 6e 63 74 69 6f 6e 2d 69 6e 2d 6c 69 62  -function-in-lib
74c0: 20 5f 5f 75 62 73 61 6e 5f 68 61 6e 64 6c 65 5f   __ubsan_handle_
74d0: 61 64 64 5f 6f 76 65 72 66 6c 6f 77 20 75 62 73  add_overflow ubs
74e0: 61 6e 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 46 69  an.    }.}..# Fi
74f0: 6e 61 6c 6c 79 2c 20 61 70 70 65 6e 64 20 6c 69  nally, append li
7500: 62 72 61 72 69 65 73 20 74 68 61 74 20 6d 75 73  braries that mus
7510: 74 20 62 65 20 6c 61 73 74 2e 20 54 68 69 73 20  t be last. This 
7520: 6d 61 74 74 65 72 73 20 6d 6f 72 65 20 6f 6e 20  matters more on 
7530: 73 6f 6d 65 0a 23 20 4f 53 65 73 20 74 68 61 6e  some.# OSes than
7540: 20 6f 74 68 65 72 73 2c 20 62 75 74 20 69 73 20   others, but is 
7550: 6d 6f 73 74 20 62 72 6f 61 64 6c 79 20 72 65 71  most broadly req
7560: 75 69 72 65 64 20 66 6f 72 20 73 74 61 74 69 63  uired for static
7570: 20 6c 69 6e 6b 69 6e 67 2e 0a 69 66 20 7b 5b 63   linking..if {[c
7580: 68 65 63 6b 2d 66 75 6e 63 74 69 6f 6e 2d 69 6e  heck-function-in
7590: 2d 6c 69 62 20 64 6c 6f 70 65 6e 20 64 6c 5d 7d  -lib dlopen dl]}
75a0: 20 7b 0a 20 20 20 20 23 20 53 6f 6d 65 20 70 6c   {.    # Some pl
75b0: 61 74 66 6f 72 6d 73 20 28 2a 42 53 44 29 20 68  atforms (*BSD) h
75c0: 61 76 65 20 74 68 65 20 64 6c 20 66 75 6e 63 74  ave the dl funct
75d0: 69 6f 6e 73 20 61 6c 72 65 61 64 79 20 69 6e 20  ions already in 
75e0: 6c 69 62 63 20 61 6e 64 20 6e 6f 20 6c 69 62 64  libc and no libd
75f0: 6c 2e 0a 20 20 20 20 23 20 49 6e 20 73 75 63 68  l..    # In such
7600: 20 63 61 73 65 20 77 65 20 63 61 6e 20 6c 69 6e   case we can lin
7610: 6b 20 64 69 72 65 63 74 6c 79 20 77 69 74 68 6f  k directly witho
7620: 75 74 20 2d 6c 64 6c 2e 0a 20 20 20 20 64 65 66  ut -ldl..    def
7630: 69 6e 65 2d 61 70 70 65 6e 64 20 4c 49 42 53 20  ine-append LIBS 
7640: 5b 67 65 74 2d 64 65 66 69 6e 65 20 6c 69 62 5f  [get-define lib_
7650: 64 6c 6f 70 65 6e 5d 0a 7d 0a 69 66 20 7b 5b 6f  dlopen].}.if {[o
7660: 70 74 2d 62 6f 6f 6c 20 73 74 61 74 69 63 5d 7d  pt-bool static]}
7670: 20 7b 0a 20 20 20 20 23 20 4c 69 6e 75 78 20 63   {.    # Linux c
7680: 61 6e 20 6f 6e 6c 79 20 69 6e 66 65 72 20 74 68  an only infer th
7690: 65 20 64 65 70 65 6e 64 65 6e 63 79 20 6f 6e 20  e dependency on 
76a0: 70 74 68 72 65 61 64 20 66 72 6f 6d 20 4f 70 65  pthread from Ope
76b0: 6e 53 53 4c 20 77 68 65 6e 0a 20 20 20 20 23 20  nSSL when.    # 
76c0: 64 6f 69 6e 67 20 64 79 6e 61 6d 69 63 20 6c 69  doing dynamic li
76d0: 6e 6b 61 67 65 2e 0a 20 20 20 20 64 65 66 69 6e  nkage..    defin
76e0: 65 2d 61 70 70 65 6e 64 20 4c 49 42 53 20 2d 6c  e-append LIBS -l
76f0: 70 74 68 72 65 61 64 0a 7d 0a 0a 69 66 20 7b 5b  pthread.}..if {[
7700: 67 65 74 2d 64 65 66 69 6e 65 20 45 4d 53 44 4b  get-define EMSDK
7710: 5f 48 4f 4d 45 5d 20 6e 65 20 22 22 7d 20 7b 0a  _HOME] ne ""} {.
7720: 20 20 64 65 66 69 6e 65 20 45 4d 43 43 5f 57 52    define EMCC_WR
7730: 41 50 50 45 52 20 24 3a 3a 61 75 74 6f 73 65 74  APPER $::autoset
7740: 75 70 28 64 69 72 29 2f 2e 2e 2f 74 6f 6f 6c 73  up(dir)/../tools
7750: 2f 65 6d 63 63 2e 73 68 0a 20 20 6d 61 6b 65 2d  /emcc.sh.  make-
7760: 74 65 6d 70 6c 61 74 65 20 74 6f 6f 6c 73 2f 65  template tools/e
7770: 6d 63 63 2e 73 68 2e 69 6e 0a 20 20 63 61 74 63  mcc.sh.in.  catc
7780: 68 20 7b 65 78 65 63 20 63 68 6d 6f 64 20 75 2b  h {exec chmod u+
7790: 78 20 74 6f 6f 6c 73 2f 65 6d 63 63 2e 73 68 7d  x tools/emcc.sh}
77a0: 0a 7d 20 65 6c 73 65 20 7b 0a 20 20 64 65 66 69  .} else {.  defi
77b0: 6e 65 20 45 4d 43 43 5f 57 52 41 50 50 45 52 20  ne EMCC_WRAPPER 
77c0: 22 22 0a 20 20 63 61 74 63 68 20 7b 65 78 65 63  "".  catch {exec
77d0: 20 72 6d 20 2d 66 20 74 6f 6f 6c 73 2f 65 6d 63   rm -f tools/emc
77e0: 63 2e 73 68 7d 0a 7d 0a 0a 23 20 54 61 67 20 63  c.sh}.}..# Tag c
77f0: 6f 6e 74 61 69 6e 65 72 20 62 75 69 6c 64 73 20  ontainer builds 
7800: 77 69 74 68 20 61 20 70 72 65 66 69 78 20 6f 66  with a prefix of
7810: 20 74 68 65 20 63 68 65 63 6b 69 6e 20 49 44 20   the checkin ID 
7820: 6f 66 20 74 68 65 20 76 65 72 73 69 6f 6e 0a 23  of the version.#
7830: 20 6f 66 20 46 6f 73 73 69 6c 20 65 61 63 68 20   of Fossil each 
7840: 6f 6e 65 20 63 6f 6e 74 61 69 6e 73 2e 20 20 54  one contains.  T
7850: 68 69 73 20 6e 6f 74 20 6f 6e 6c 79 20 61 6c 6c  his not only all
7860: 6f 77 73 20 6d 75 6c 74 69 70 6c 65 20 69 6d 61  ows multiple ima
7870: 67 65 73 0a 23 20 74 6f 20 63 6f 65 78 69 73 74  ges.# to coexist
7880: 20 61 6e 64 20 6d 75 6c 74 69 70 6c 65 20 63 6f   and multiple co
7890: 6e 74 61 69 6e 65 72 73 20 74 6f 20 62 65 20 63  ntainers to be c
78a0: 72 65 61 74 65 64 20 75 6e 61 6d 67 69 67 75 6f  reated unamgiguo
78b0: 73 6c 79 20 66 72 6f 6d 0a 23 20 74 68 65 6d 2c  sly from.# them,
78c0: 20 69 74 20 61 6c 73 6f 20 63 68 61 6e 67 65 73   it also changes
78d0: 20 74 68 65 20 55 52 4c 20 77 65 20 66 65 74 63   the URL we fetc
78e0: 68 20 74 68 65 20 73 6f 75 72 63 65 20 74 61 72  h the source tar
78f0: 62 61 6c 6c 20 66 72 6f 6d 2c 20 73 6f 0a 23 20  ball from, so.# 
7900: 72 65 70 65 61 74 65 64 20 62 75 69 6c 64 73 20  repeated builds 
7910: 6f 66 20 61 20 67 69 76 65 6e 20 76 65 72 73 69  of a given versi
7920: 6f 6e 20 67 65 6e 65 72 61 74 65 20 61 6e 64 20  on generate and 
7930: 66 65 74 63 68 20 74 68 65 20 73 6f 75 72 63 65  fetch the source
7940: 0a 23 20 74 61 72 62 61 6c 6c 20 6f 6e 63 65 20  .# tarball once 
7950: 6f 6e 6c 79 2c 20 6b 65 65 70 69 6e 67 20 69 74  only, keeping it
7960: 20 69 6e 20 74 68 65 20 6c 6f 63 61 6c 20 44 6f   in the local Do
7970: 63 6b 65 72 2f 50 6f 64 6d 61 6e 20 63 61 63 68  cker/Podman cach
7980: 65 2e 0a 73 65 74 20 63 69 20 5b 72 65 61 64 66  e..set ci [readf
7990: 69 6c 65 20 22 24 3a 3a 61 75 74 6f 73 65 74 75  ile "$::autosetu
79a0: 70 28 73 72 63 64 69 72 29 2f 6d 61 6e 69 66 65  p(srcdir)/manife
79b0: 73 74 2e 75 75 69 64 22 5d 0a 64 65 66 69 6e 65  st.uuid"].define
79c0: 20 46 4f 53 53 49 4c 5f 43 49 5f 50 46 58 20 5b   FOSSIL_CI_PFX [
79d0: 73 74 72 69 6e 67 20 72 61 6e 67 65 20 24 63 69  string range $ci
79e0: 20 30 20 31 31 5d 0a 0a 6d 61 6b 65 2d 74 65 6d   0 11]..make-tem
79f0: 70 6c 61 74 65 20 4d 61 6b 65 66 69 6c 65 2e 69  plate Makefile.i
7a00: 6e 0a 6d 61 6b 65 2d 63 6f 6e 66 69 67 2d 68 65  n.make-config-he
7a10: 61 64 65 72 20 61 75 74 6f 63 6f 6e 66 69 67 2e  ader autoconfig.
7a20: 68 20 2d 61 75 74 6f 20 7b 55 53 45 5f 2a 20 46  h -auto {USE_* F
7a30: 4f 53 53 49 4c 5f 2a 7d 0a                       OSSIL_*}.