1# System autoconfiguration. Try: ./configure --help 2 3# This must be above "options" below because it implicitly brings in the 4# default Autosetup options, things like --prefix. 5use cc cc-lib 6 7options { 8 with-openssl:path|auto|tree|none 9 => {Look for OpenSSL in the given path, automatically, in the source tree, or none} 10 with-miniz=0 => {Use miniz from the source tree} 11 with-zlib:path|auto|tree 12 => {Look for zlib in the given path, automatically, or in the source tree} 13 with-exec-rel-paths=0 14 => {Enable relative paths for external diff/gdiff} 15 with-sanitizer: => {Build with C compiler's -fsanitize=LIST; e.g. address,enum,null,undefined} 16 with-th1-docs=0 => {Enable TH1 for embedded documentation pages} 17 with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages} 18 with-tcl:path => {Enable Tcl integration, with Tcl in the specified path} 19 with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism} 20 with-tcl-private-stubs=0 21 => {Enable Tcl integration via private stubs mechanism} 22 with-mman=0 => {Enable use of POSIX memory APIs from "sys/mman.h"} 23 with-see=0 => {Enable the SQLite Encryption Extension (SEE)} 24 print-minimum-sqlite-version=0 25 => {print the minimum SQLite version number required, and exit} 26 internal-sqlite=1 => {Don't use the internal SQLite, use the system one} 27 static=0 => {Link a static executable} 28 fusefs=1 => {Disable the Fuse Filesystem} 29 fossil-debug=0 => {Build with fossil debugging enabled} 30 no-opt=0 => {Build without optimization} 31 json=0 => {Build with fossil JSON API enabled} 32} 33 34# Update the minimum required SQLite version number here, and also 35# in src/main.c near the sqlite3_libversion_number() call. Take care 36# that both places agree! 37define MINIMUM_SQLITE_VERSION "3.35.0" 38 39# This is useful for people wanting Fossil to use an external SQLite library 40# to compare the one they have against the minimum required 41if {[opt-bool print-minimum-sqlite-version]} { 42 puts [get-define MINIMUM_SQLITE_VERSION] 43 exit 0 44} 45 46# sqlite wants these types if possible 47cc-with {-includes {stdint.h inttypes.h}} { 48 cc-check-types uint32_t uint16_t int16_t uint8_t 49} 50 51# Use pread/pwrite system calls in place of seek + read/write if possible 52define USE_PREAD [cc-check-functions pread] 53 54# If we have cscope here, we'll use it in the "tags" target 55if {[cc-check-progs cscope]} { 56 define COLLECT_CSCOPE_DATA "cscope -bR $::autosetup(srcdir)/src/*.\[ch\]" 57} else { 58 define COLLECT_CSCOPE_DATA "" 59} 60 61# Find tclsh for the test suite. 62# 63# We can't use jimsh for this: the test suite uses features of Tcl that 64# Jim doesn't support, either statically or due to the way it's built by 65# autosetup. For example, Jim supports `file normalize`, but only if 66# you build it with HAVE_REALPATH, which won't ever be defined in this 67# context because autosetup doesn't try to discover platform-specific 68# details like that before it decides to build jimsh0. Besides which, 69# autosetup won't build jimsh0 at all if it can find tclsh itself. 70# Ironically, this means we may right now be running under either jimsh0 71# or a version of tclsh that we find unsuitable below! 72cc-check-progs tclsh 73set hbtd /usr/local/Cellar/tcl-tk 74if {[string equal false [get-define TCLSH]]} { 75 msg-result "WARNING: 'make test' will not run here." 76} else { 77 set v [exec /bin/sh -c "echo 'puts \$tcl_version' | tclsh"] 78 if {[expr {$v >= 8.6}]} { 79 msg-result "Found Tclsh version $v in the PATH." 80 define TCLSH tclsh 81 } elseif {[file isdirectory $hbtd]} { 82 # This is a macOS system with the Homebrew version of Tcl/Tk 83 # installed. Select the newest version. It won't normally be 84 # in the PATH to avoid shadowing /usr/bin/tclsh, and even if it 85 # were in the PATH, it's bad practice to put /usr/local/bin (the 86 # Homebrew default) ahead of /usr/bin, especially given that 87 # it's user-writeable by default with Homebrew. Thus, we can be 88 # pretty sure the only way to call it is with an absolute path. 89 set v [exec ls -tr $hbtd | tail -1] 90 set path "$hbtd/$v/bin/tclsh" 91 define TCLSH $path 92 msg-result "Using Homebrew Tcl/Tk version $path." 93 } else { 94 msg-result "WARNING: tclsh $v found; need >= 8.6 for 'make test'." 95 define TCLSH false ;# force "make test" failure via /usr/bin/false 96 } 97} 98 99define EXTRA_CFLAGS "-Wall" 100define EXTRA_LDFLAGS "" 101define USE_SYSTEM_SQLITE 0 102define USE_LINENOISE 0 103define FOSSIL_ENABLE_MINIZ 0 104define USE_MMAN_H 0 105define USE_SEE 0 106 107 108# Maintain the C89/C90-style order of variable declarations before statements. 109# Check if the compiler supports the respective warning flag. 110if {[cctest -cflags -Wdeclaration-after-statement]} { 111 define-append EXTRA_CFLAGS -Wdeclaration-after-statement 112} 113 114 115# This procedure is a customized version of "cc-check-function-in-lib", 116# that does not modify the LIBS variable. Its use prevents prematurely 117# pulling in libraries that will be added later anyhow (e.g. "-ldl"). 118proc check-function-in-lib {function libs {otherlibs {}}} { 119 if {[string length $otherlibs]} { 120 msg-checking "Checking for $function in $libs with $otherlibs..." 121 } else { 122 msg-checking "Checking for $function in $libs..." 123 } 124 set found 0 125 cc-with [list -libs $otherlibs] { 126 if {[cctest_function $function]} { 127 msg-result "none needed" 128 define lib_$function "" 129 incr found 130 } else { 131 foreach lib $libs { 132 cc-with [list -libs -l$lib] { 133 if {[cctest_function $function]} { 134 msg-result -l$lib 135 define lib_$function -l$lib 136 incr found 137 break 138 } 139 } 140 } 141 } 142 } 143 if {$found} { 144 define [feature-define-name $function] 145 } else { 146 msg-result "no" 147 } 148 return $found 149} 150 151if {![opt-bool internal-sqlite]} { 152 proc find_system_sqlite {} { 153 154 # On some systems (slackware), libsqlite3 requires -ldl to link. So 155 # search for the system SQLite once with -ldl, and once without. If 156 # the library can only be found with $extralibs set to -ldl, then 157 # the code below will append -ldl to LIBS. 158 # 159 foreach extralibs {{} {-ldl}} { 160 161 # Locate the system SQLite by searching for sqlite3_open(). Then check 162 # if sqlite3_stmt_isexplain can be found as well. If we can find open() but 163 # not stmt_isexplain(), then the system SQLite is too old to link against 164 # fossil. 165 # 166 if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} { 167 # Success. Update symbols and return. 168 # 169 define USE_SYSTEM_SQLITE 1 170 define-append LIBS -lsqlite3 171 define-append LIBS $extralibs 172 return 173 } 174 } 175 user-error "system sqlite3 not found" 176 } 177 178 find_system_sqlite 179 180 proc test_system_sqlite {} { 181 # Check compatibility of the system SQLite library by running the sqlcompttest.c 182 # program in the source tree 183 # passes MINIMUM_SQLITE_VERSION set at the top of this file to sqlcompttest.c 184 # 185 set cmdline {} 186 lappend cmdline {*}[get-define CCACHE] 187 lappend cmdline {*}[get-define CC] {*}[get-define CFLAGS] 188 lappend cmdline $::autosetup(dir)/../src/sqlcompattest.c -o conftest__ 189 lappend cmdline {*}[get-define LDFLAGS] 190 lappend cmdline {*}[get-define LIBS] 191 set sqlite-version [string cat "-D MINIMUM_SQLITE_VERSION=" [get-define MINIMUM_SQLITE_VERSION]] 192 lappend cmdline {*}[set sqlite-version] 193 set ok 1 194 set err [catch {exec-with-stderr {*}$cmdline} result errinfo] 195 if {$err} { 196 configlog "Failed: [join $cmdline]" 197 if {[string length $result]>0} {configlog $result} 198 configlog "============" 199 set ok 0 200 } elseif {$::autosetup(debug)} { 201 configlog "Compiled OK: [join $cmdline]" 202 configlog "============" 203 } 204 if {!$ok} { 205 user-error "unable to compile SQLite compatibility test program" 206 } 207 set err [catch {exec-with-stderr ./conftest__} result errinfo] 208 if {[get-define build] eq [get-define host]} { 209 set err [catch {exec-with-stderr ./conftest__} result errinfo] 210 if {$err} { 211 user-error $result 212 } 213 } 214 file delete ./conftest__ 215 } 216 test_system_sqlite 217 218} 219 220proc is_mingw {} { 221 return [string match *mingw* [get-define host]] 222} 223 224if {[is_mingw]} { 225 define-append EXTRA_CFLAGS -DBROKEN_MINGW_CMDLINE 226 define-append LIBS -lkernel32 -lws2_32 227} else { 228 # 229 # NOTE: All platforms except MinGW should use the linenoise 230 # package. It is currently unsupported on Win32. 231 # 232 define USE_LINENOISE 1 233} 234 235if {[string match *-solaris* [get-define host]]} { 236 define-append EXTRA_CFLAGS {-D_XOPEN_SOURCE=500 -D__EXTENSIONS__} 237} 238 239if {[opt-bool fossil-debug]} { 240 define CFLAGS {-g -O0 -Wall} 241 define-append CFLAGS -DFOSSIL_DEBUG 242 msg-result "Debugging support enabled" 243} 244 245if {[opt-bool no-opt]} { 246 define CFLAGS {-g -O0 -Wall} 247 msg-result "Builting without compiler optimization" 248 if {[opt-bool fossil-debug]} { 249 define-append CFLAGS -DFOSSIL_DEBUG 250 } 251} 252 253if {[opt-bool with-mman]} { 254 define-append EXTRA_CFLAGS -DUSE_MMAN_H 255 define USE_MMAN_H 1 256 msg-result "Enabling \"sys/mman.h\" support" 257} 258 259if {[opt-bool with-see]} { 260 define-append EXTRA_CFLAGS -DUSE_SEE 261 define USE_SEE 1 262 msg-result "Enabling encryption support" 263} 264 265if {[opt-bool json]} { 266 # Reminder/FIXME (stephan): FOSSIL_ENABLE_JSON 267 # is required in the CFLAGS because json*.c 268 # have #ifdef guards around the whole file without 269 # reading config.h first. 270 define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_JSON 271 define FOSSIL_ENABLE_JSON 272 msg-result "JSON support enabled" 273} 274 275if {[opt-bool with-exec-rel-paths]} { 276 define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_EXEC_REL_PATHS 277 define FOSSIL_ENABLE_EXEC_REL_PATHS 278 msg-result "Relative paths in external diff/gdiff enabled" 279} 280 281if {[opt-bool with-th1-docs]} { 282 define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_DOCS 283 define FOSSIL_ENABLE_TH1_DOCS 284 msg-result "TH1 embedded documentation support enabled" 285} 286 287if {[opt-bool with-th1-hooks]} { 288 define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_HOOKS 289 define FOSSIL_ENABLE_TH1_HOOKS 290 msg-result "TH1 hooks support enabled" 291} 292 293#if {[opt-bool markdown]} { 294# # no-op. Markdown is now enabled by default. 295# msg-result "Markdown support enabled" 296#} 297 298if {[opt-bool static]} { 299 # XXX: This will not work on all systems. 300 define-append EXTRA_LDFLAGS -static 301 msg-result "Trying to link statically" 302} else { 303 define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1 304 define FOSSIL_DYNAMIC_BUILD 305} 306 307# Check for libraries that need to be sorted out early 308cc-check-function-in-lib iconv iconv 309 310# Helper for OpenSSL checking 311proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto -lpthread}}} { 312 msg-checking "Checking for $msg..." 313 set rc 0 314 if {[is_mingw]} { 315 lappend libs -lgdi32 -lwsock32 -lcrypt32 316 } 317 if {[info exists ::zlib_lib]} { 318 lappend libs $::zlib_lib 319 } 320 msg-quiet cc-with [list -cflags $cflags -libs $libs] { 321 if {[cc-check-includes openssl/ssl.h] && \ 322 [cc-check-functions SSL_new]} { 323 incr rc 324 } 325 } 326 if {!$rc && ![is_mingw]} { 327 # On some systems, OpenSSL appears to require -ldl to link. 328 lappend libs -ldl 329 msg-quiet cc-with [list -cflags $cflags -libs $libs] { 330 if {[cc-check-includes openssl/ssl.h] && \ 331 [cc-check-functions SSL_new]} { 332 incr rc 333 } 334 } 335 } 336 if {$rc} { 337 msg-result "ok" 338 return 1 339 } else { 340 msg-result "no" 341 return 0 342 } 343} 344 345if {[opt-bool with-miniz]} { 346 define FOSSIL_ENABLE_MINIZ 1 347 msg-result "Using miniz for compression" 348} else { 349 # Check for zlib, using the given location if specified 350 set zlibpath [opt-val with-zlib] 351 if {$zlibpath eq "tree"} { 352 set zlibdir [file dirname $autosetup(dir)]/compat/zlib 353 if {![file isdirectory $zlibdir]} { 354 user-error "The zlib in source tree directory does not exist" 355 } 356 cc-with [list -cflags "-I$zlibdir -L$zlibdir"] 357 define-append EXTRA_CFLAGS -I$zlibdir 358 define-append LIBS $zlibdir/libz.a 359 set ::zlib_lib $zlibdir/libz.a 360 msg-result "Using zlib in source tree" 361 } else { 362 if {$zlibpath ni {auto ""}} { 363 cc-with [list -cflags "-I$zlibpath -L$zlibpath"] 364 define-append EXTRA_CFLAGS -I$zlibpath 365 define-append EXTRA_LDFLAGS -L$zlibpath 366 msg-result "Using zlib from $zlibpath" 367 } 368 if {![cc-check-includes zlib.h] || ![check-function-in-lib inflateEnd z]} { 369 user-error "zlib not found please install it or specify the location with --with-zlib" 370 } 371 set ::zlib_lib -lz 372 } 373} 374 375set ssldirs [opt-val with-openssl] 376if {$ssldirs ne "none"} { 377 if {[opt-bool with-miniz]} { 378 user-error "The --with-miniz option is incompatible with OpenSSL" 379 } 380 set found 0 381 if {$ssldirs eq "tree"} { 382 set ssldir [file dirname $autosetup(dir)]/compat/openssl 383 if {![file isdirectory $ssldir]} { 384 user-error "The OpenSSL in source tree directory does not exist" 385 } 386 set msg "ssl in $ssldir" 387 set cflags "-I$ssldir/include" 388 set ldflags "-L$ssldir" 389 set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a -lpthread" 390 set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs] 391 } else { 392 if {$ssldirs in {auto ""}} { 393 catch { 394 set cflags [exec pkg-config openssl --cflags-only-I] 395 set ldflags [exec pkg-config openssl --libs-only-L] 396 set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"] 397 } msg 398 if {!$found} { 399 set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl \ 400 /usr/pkg /usr/local /usr /usr/local/opt/openssl \ 401 /opt/homebrew/opt/openssl" 402 } 403 } 404 if {!$found} { 405 foreach dir $ssldirs { 406 if {$dir eq ""} { 407 set msg "system ssl" 408 set cflags "" 409 set ldflags "" 410 } else { 411 set msg "ssl in $dir" 412 set cflags "-I$dir/include" 413 set ldflags "-L$dir/lib" 414 } 415 if {[check-for-openssl $msg "$cflags $ldflags"]} { 416 incr found 417 break 418 } 419 } 420 } 421 } 422 if {$found} { 423 define FOSSIL_ENABLE_SSL 424 define-append EXTRA_CFLAGS $cflags 425 define-append EXTRA_LDFLAGS $ldflags 426 if {[info exists ssllibs]} { 427 define-append LIBS $ssllibs 428 } else { 429 define-append LIBS -lssl -lcrypto 430 } 431 if {[info exists ::zlib_lib]} { 432 define-append LIBS $::zlib_lib 433 } 434 if {[is_mingw]} { 435 define-append LIBS -lgdi32 -lwsock32 -lcrypt32 436 } 437 msg-result "HTTPS support enabled" 438 439 # Silence OpenSSL deprecation warnings on Mac OS X 10.7. 440 if {[string match *-darwin* [get-define host]]} { 441 if {[cctest -cflags {-Wdeprecated-declarations}]} { 442 define-append EXTRA_CFLAGS -Wdeprecated-declarations 443 } 444 } 445 } else { 446 user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support" 447 } 448} else { 449 if {[info exists ::zlib_lib]} { 450 define-append LIBS $::zlib_lib 451 } 452} 453 454set tclpath [opt-val with-tcl] 455if {$tclpath ne ""} { 456 set tclprivatestubs [opt-bool with-tcl-private-stubs] 457 # Note parse-tclconfig-sh is in autosetup/local.tcl 458 if {$tclpath eq "1"} { 459 set tcldir [file dirname $autosetup(dir)]/compat/tcl-8.6 460 if {$tclprivatestubs} { 461 set tclconfig(TCL_INCLUDE_SPEC) -I$tcldir/generic 462 set tclconfig(TCL_VERSION) {Private Stubs} 463 set tclconfig(TCL_PATCH_LEVEL) {} 464 set tclconfig(TCL_PREFIX) $tcldir 465 set tclconfig(TCL_LD_FLAGS) { } 466 } else { 467 # Use the system Tcl. Look in some likely places. 468 array set tclconfig [parse-tclconfig-sh \ 469 $tcldir/unix $tcldir/win \ 470 /usr /usr/local /usr/share /opt/local] 471 set msg "on your system" 472 } 473 } else { 474 array set tclconfig [parse-tclconfig-sh $tclpath] 475 set msg "at $tclpath" 476 } 477 if {[opt-bool static]} { 478 set tclconfig(TCL_LD_FLAGS) { } 479 } 480 if {![info exists tclconfig(TCL_INCLUDE_SPEC)]} { 481 user-error "Cannot find Tcl $msg" 482 } 483 set tclstubs [opt-bool with-tcl-stubs] 484 if {$tclprivatestubs} { 485 define FOSSIL_ENABLE_TCL_PRIVATE_STUBS 486 define USE_TCL_STUBS 487 } elseif {$tclstubs && $tclconfig(TCL_SUPPORTS_STUBS)} { 488 set libs "$tclconfig(TCL_STUB_LIB_SPEC)" 489 define FOSSIL_ENABLE_TCL_STUBS 490 define USE_TCL_STUBS 491 } else { 492 set libs "$tclconfig(TCL_LIB_SPEC) $tclconfig(TCL_LIBS)" 493 } 494 set cflags $tclconfig(TCL_INCLUDE_SPEC) 495 if {!$tclprivatestubs} { 496 set foundtcl 0; # Did we find a working Tcl library? 497 cc-with [list -cflags $cflags -libs $libs] { 498 if {$tclstubs} { 499 if {[cc-check-functions Tcl_InitStubs]} { 500 set foundtcl 1 501 } 502 } else { 503 if {[cc-check-functions Tcl_CreateInterp]} { 504 set foundtcl 1 505 } 506 } 507 } 508 if {!$foundtcl && [string match *-lieee* $libs]} { 509 # On some systems, using "-lieee" from TCL_LIB_SPEC appears 510 # to cause issues. 511 msg-result "Removing \"-lieee\" and retrying for Tcl..." 512 set libs [string map [list -lieee ""] $libs] 513 cc-with [list -cflags $cflags -libs $libs] { 514 if {$tclstubs} { 515 if {[cc-check-functions Tcl_InitStubs]} { 516 set foundtcl 1 517 } 518 } else { 519 if {[cc-check-functions Tcl_CreateInterp]} { 520 set foundtcl 1 521 } 522 } 523 } 524 } 525 if {!$foundtcl && ![string match *-lpthread* $libs]} { 526 # On some systems, TCL_LIB_SPEC appears to be missing 527 # "-lpthread". Try adding it. 528 msg-result "Adding \"-lpthread\" and retrying for Tcl..." 529 set libs "$libs -lpthread" 530 cc-with [list -cflags $cflags -libs $libs] { 531 if {$tclstubs} { 532 if {[cc-check-functions Tcl_InitStubs]} { 533 set foundtcl 1 534 } 535 } else { 536 if {[cc-check-functions Tcl_CreateInterp]} { 537 set foundtcl 1 538 } 539 } 540 } 541 } 542 if {!$foundtcl} { 543 if {$tclstubs} { 544 user-error "Cannot find a usable Tcl stubs library $msg" 545 } else { 546 user-error "Cannot find a usable Tcl library $msg" 547 } 548 } 549 } 550 set version $tclconfig(TCL_VERSION)$tclconfig(TCL_PATCH_LEVEL) 551 msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)" 552 if {!$tclprivatestubs} { 553 define-append LIBS $libs 554 } 555 define-append EXTRA_CFLAGS $cflags 556 if {[info exists zlibpath] && $zlibpath eq "tree"} { 557 # 558 # NOTE: When using zlib in the source tree, prevent Tcl from 559 # pulling in the system one. 560 # 561 set tclconfig(TCL_LD_FLAGS) [string map [list -lz ""] \ 562 $tclconfig(TCL_LD_FLAGS)] 563 } 564 # 565 # NOTE: Remove "-ldl" from the TCL_LD_FLAGS because it will be 566 # be checked for near the bottom of this file. 567 # 568 set tclconfig(TCL_LD_FLAGS) [string map [list -ldl ""] \ 569 $tclconfig(TCL_LD_FLAGS)] 570 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS) 571 define FOSSIL_ENABLE_TCL 572} 573 574# Network functions require libraries on some systems 575cc-check-function-in-lib gethostbyname nsl 576if {![cc-check-function-in-lib socket {socket network}]} { 577 # Last resort, may be Windows 578 if {[is_mingw]} { 579 define-append LIBS -lwsock32 580 } 581} 582 583# The SMTP module requires special libraries and headers for MX DNS 584# record lookups and such. 585cc-check-includes arpa/nameser.h 586cc-include-needs bind/resolv.h netinet/in.h 587cc-check-includes bind/resolv.h 588cc-check-includes resolv.h 589if { !(([cc-check-function-in-lib dn_expand resolv] || 590 [cc-check-function-in-lib ns_name_uncompress {bind resolv}] || 591 [cc-check-function-in-lib __ns_name_uncompress {bind resolv}]) && 592 ([cc-check-function-in-lib ns_parserr {bind resolv}] || 593 [cc-check-function-in-lib __ns_parserr {bind resolv}]) && 594 ([cc-check-function-in-lib res_query {bind resolv}] || 595 [cc-check-function-in-lib __res_query {bind resolv}]))} { 596 msg-result "WARNING: SMTP feature will not be able to look up local MX." 597} 598cc-check-function-in-lib res_9_ns_initparse resolv 599 600# Other nonstandard function checks 601cc-check-functions utime 602cc-check-functions usleep 603cc-check-functions strchrnul 604cc-check-functions pledge 605cc-check-functions backtrace 606 607# Termux on Android adds "getpass(char *)" to unistd.h, so check this so we 608# guard against including it again; use cctest as cc-check-functions and 609# cctest_function check for "getpass()" with no args and fail 610if {[cctest -link 1 -includes {unistd.h} -code "getpass(0);"]} { 611 define FOSSIL_HAVE_GETPASS 1 612 msg-result "Found getpass() with unistd.h" 613} 614 615# Check for getloadavg(), and if it doesn't exist, define FOSSIL_OMIT_LOAD_AVERAGE 616if {![cc-check-functions getloadavg]} { 617 define FOSSIL_OMIT_LOAD_AVERAGE 1 618 msg-result "Load average support unavailable" 619} 620 621# Check for getpassphrase() for Solaris 10 where getpass() truncates to 10 chars 622if {![cc-check-functions getpassphrase]} { 623 # Haiku needs this 624 cc-check-function-in-lib getpass bsd 625} 626cc-check-function-in-lib sin m 627 628# Check for the FuseFS library 629if {[opt-bool fusefs]} { 630 if {[opt-bool static]} { 631 msg-result "FuseFS support disabled due to -static" 632 } elseif {[cc-check-function-in-lib fuse_mount fuse]} { 633 define-append EXTRA_CFLAGS -DFOSSIL_HAVE_FUSEFS 634 define FOSSIL_HAVE_FUSEFS 1 635 define-append LIBS -lfuse 636 msg-result "FuseFS support enabled" 637 } 638} 639 640# Add -fsanitize compile and link options late: we don't want the C 641# checks above to run with those sanitizers enabled. It can not only 642# be pointless, it can actually break correct tests. 643set fsan [opt-val with-sanitizer] 644if {[string length $fsan]} { 645 define-append EXTRA_CFLAGS -fsanitize=$fsan 646 define-append EXTRA_LDFLAGS -fsanitize=$fsan 647 if {[string first "undefined" $fsan] != -1} { 648 # We need to link with libubsan if we're compiling under 649 # GCC with -fsanitize=undefined. 650 cc-check-function-in-lib __ubsan_handle_add_overflow ubsan 651 } 652} 653 654# Finally, append libraries that must be last. This matters more on some 655# OSes than others, but is most broadly required for static linking. 656if {[check-function-in-lib dlopen dl]} { 657 # Some platforms (*BSD) have the dl functions already in libc and no libdl. 658 # In such case we can link directly without -ldl. 659 define-append LIBS [get-define lib_dlopen] 660} 661if {[opt-bool static]} { 662 # Linux can only infer the dependency on pthread from OpenSSL when 663 # doing dynamic linkage. 664 define-append LIBS -lpthread 665} 666 667 668make-template Makefile.in 669make-config-header autoconfig.h -auto {USE_* FOSSIL_*} 670