| | @@ -1,15 +1,15 @@ |
| 1 | 1 | # System autoconfiguration. Try: ./configure --help |
| 2 | 2 | |
| 3 | 3 | use cc cc-lib |
| 4 | 4 | |
| 5 | 5 | options { |
| 6 | | - with-openssl:path|auto|none |
| 7 | | - => {Look for OpenSSL in the given path, or auto or none} |
| 6 | + with-openssl:path|auto|tree|none |
| 7 | + => {Look for OpenSSL in the given path, automatically, in the source tree, or none} |
| 8 | 8 | with-miniz=0 => {Use miniz from the source tree} |
| 9 | 9 | with-zlib:path|auto|tree |
| 10 | | - => {Look for zlib in the given path, or auto or in the source tree} |
| 10 | + => {Look for zlib in the given path, automatically, or in the source tree} |
| 11 | 11 | with-exec-rel-paths=0 |
| 12 | 12 | => {Enable relative paths for external diff/gdiff} |
| 13 | 13 | with-legacy-mv-rm=0 => {Enable legacy behavior for mv/rm (skip checkout files)} |
| 14 | 14 | with-th1-docs=0 => {Enable TH1 for embedded documentation pages} |
| 15 | 15 | with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages} |
| | @@ -36,10 +36,11 @@ |
| 36 | 36 | cc-check-progs tclsh |
| 37 | 37 | |
| 38 | 38 | define EXTRA_CFLAGS "" |
| 39 | 39 | define EXTRA_LDFLAGS "" |
| 40 | 40 | define USE_SYSTEM_SQLITE 0 |
| 41 | +define USE_LINENOISE 0 |
| 41 | 42 | |
| 42 | 43 | if {![opt-bool internal-sqlite]} { |
| 43 | 44 | proc find_internal_sqlite {} { |
| 44 | 45 | |
| 45 | 46 | # On some systems (slackware), libsqlite3 requires -ldl to link. So |
| | @@ -69,10 +70,25 @@ |
| 69 | 70 | user-error "system sqlite3 not found" |
| 70 | 71 | } |
| 71 | 72 | |
| 72 | 73 | find_internal_sqlite |
| 73 | 74 | } |
| 75 | + |
| 76 | +proc is_mingw {} { |
| 77 | + return [string match *mingw* [get-define host]] |
| 78 | +} |
| 79 | + |
| 80 | +if {[is_mingw]} { |
| 81 | + define-append EXTRA_CFLAGS -DBROKEN_MINGW_CMDLINE |
| 82 | + define-append LIBS -lkernel32 -lws2_32 -lmingw32 |
| 83 | +} else { |
| 84 | + # |
| 85 | + # NOTE: All platforms except MinGW should use the linenoise |
| 86 | + # package. It is currently unsupported on Win32. |
| 87 | + # |
| 88 | + define USE_LINENOISE 1 |
| 89 | +} |
| 74 | 90 | |
| 75 | 91 | if {[string match *-solaris* [get-define host]]} { |
| 76 | 92 | define-append EXTRA_CFLAGS {-D_XOPEN_SOURCE=500 -D__EXTENSIONS__} |
| 77 | 93 | } |
| 78 | 94 | |
| | @@ -214,63 +230,131 @@ |
| 214 | 230 | define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS) |
| 215 | 231 | define FOSSIL_ENABLE_TCL |
| 216 | 232 | } |
| 217 | 233 | |
| 218 | 234 | # Helper for OpenSSL checking |
| 219 | | -proc check-for-openssl {msg {cflags {}}} { |
| 235 | +proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} { |
| 220 | 236 | msg-checking "Checking for $msg..." |
| 221 | 237 | set rc 0 |
| 222 | | - msg-quiet cc-with [list -cflags $cflags -libs {-lssl -lcrypto}] { |
| 223 | | - if {[cc-check-includes openssl/ssl.h] && [cc-check-functions SSL_new]} { |
| 238 | + if {[is_mingw]} { |
| 239 | + lappend libs -lgdi32 -lwsock32 |
| 240 | + } |
| 241 | + if {[info exists ::zlib_for_ssl]} { |
| 242 | + lappend libs $::zlib_for_ssl |
| 243 | + } |
| 244 | + msg-quiet cc-with [list -cflags $cflags -libs $libs] { |
| 245 | + if {[cc-check-includes openssl/ssl.h] && \ |
| 246 | + [cc-check-functions SSL_new]} { |
| 224 | 247 | incr rc |
| 225 | 248 | } |
| 249 | + } |
| 250 | + if {!$rc && ![is_mingw]} { |
| 251 | + # On some systems, OpenSSL appears to require -ldl to link. |
| 252 | + lappend libs -ldl |
| 253 | + msg-quiet cc-with [list -cflags $cflags -libs $libs] { |
| 254 | + if {[cc-check-includes openssl/ssl.h] && \ |
| 255 | + [cc-check-functions SSL_new]} { |
| 256 | + incr rc |
| 257 | + } |
| 258 | + } |
| 226 | 259 | } |
| 227 | 260 | if {$rc} { |
| 228 | 261 | msg-result "ok" |
| 229 | 262 | return 1 |
| 230 | 263 | } else { |
| 231 | 264 | msg-result "no" |
| 232 | 265 | return 0 |
| 233 | 266 | } |
| 234 | 267 | } |
| 268 | + |
| 269 | +if {[opt-bool with-miniz]} { |
| 270 | + define FOSSIL_ENABLE_MINIZ 1 |
| 271 | + msg-result "Using miniz for compression" |
| 272 | +} else { |
| 273 | + # Check for zlib, using the given location if specified |
| 274 | + set zlibpath [opt-val with-zlib] |
| 275 | + if {$zlibpath eq "tree"} { |
| 276 | + set zlibdir [file dirname $autosetup(dir)]/compat/zlib |
| 277 | + if {![file isdirectory $zlibdir]} { |
| 278 | + user-error "The zlib in source tree directory does not exist" |
| 279 | + } |
| 280 | + cc-with [list -cflags "-I$zlibdir -L$zlibdir"] |
| 281 | + define-append EXTRA_CFLAGS -I$zlibdir |
| 282 | + define-append LIBS $zlibdir/libz.a |
| 283 | + set ::zlib_for_ssl $zlibdir/libz.a |
| 284 | + msg-result "Using zlib in source tree" |
| 285 | + } else { |
| 286 | + if {$zlibpath ni {auto ""}} { |
| 287 | + cc-with [list -cflags "-I$zlibpath -L$zlibpath"] |
| 288 | + define-append EXTRA_CFLAGS -I$zlibpath |
| 289 | + define-append EXTRA_LDFLAGS -L$zlibpath |
| 290 | + msg-result "Using zlib from $zlibpath" |
| 291 | + } |
| 292 | + if {![cc-check-includes zlib.h] || ![cc-check-function-in-lib inflateEnd z]} { |
| 293 | + user-error "zlib not found please install it or specify the location with --with-zlib" |
| 294 | + } |
| 295 | + set ::zlib_for_ssl -lz |
| 296 | + } |
| 297 | +} |
| 235 | 298 | |
| 236 | 299 | set ssldirs [opt-val with-openssl] |
| 237 | 300 | if {$ssldirs ne "none"} { |
| 238 | | - set found 0 |
| 239 | | - if {$ssldirs in {auto ""}} { |
| 240 | | - catch { |
| 241 | | - set cflags [exec pkg-config openssl --cflags-only-I] |
| 242 | | - set ldflags [exec pkg-config openssl --libs-only-L] |
| 243 | | - |
| 244 | | - set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"] |
| 245 | | - } msg |
| 246 | | - if {!$found} { |
| 247 | | - set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr" |
| 248 | | - } |
| 249 | | - } |
| 250 | | - if {!$found} { |
| 251 | | - foreach dir $ssldirs { |
| 252 | | - if {$dir eq ""} { |
| 253 | | - set msg "system ssl" |
| 254 | | - set cflags "" |
| 255 | | - set ldflags "" |
| 256 | | - } else { |
| 257 | | - set msg "ssl in $dir" |
| 258 | | - set cflags "-I$dir/include" |
| 259 | | - set ldflags "-L$dir/lib" |
| 260 | | - } |
| 261 | | - if {[check-for-openssl $msg "$cflags $ldflags"]} { |
| 262 | | - incr found |
| 263 | | - break |
| 301 | + if {[opt-bool with-miniz]} { |
| 302 | + user-error "The --with-miniz option is incompatible with OpenSSL" |
| 303 | + } |
| 304 | + set found 0 |
| 305 | + if {$ssldirs eq "tree"} { |
| 306 | + set ssldir [file dirname $autosetup(dir)]/compat/openssl |
| 307 | + if {![file isdirectory $ssldir]} { |
| 308 | + user-error "The OpenSSL in source tree directory does not exist" |
| 309 | + } |
| 310 | + set msg "ssl in $ssldir" |
| 311 | + set cflags "-I$ssldir/include" |
| 312 | + set ldflags "-L$ssldir" |
| 313 | + set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a" |
| 314 | + set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs] |
| 315 | + } else { |
| 316 | + if {$ssldirs in {auto ""}} { |
| 317 | + catch { |
| 318 | + set cflags [exec pkg-config openssl --cflags-only-I] |
| 319 | + set ldflags [exec pkg-config openssl --libs-only-L] |
| 320 | + set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"] |
| 321 | + } msg |
| 322 | + if {!$found} { |
| 323 | + set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr" |
| 324 | + } |
| 325 | + } |
| 326 | + if {!$found} { |
| 327 | + foreach dir $ssldirs { |
| 328 | + if {$dir eq ""} { |
| 329 | + set msg "system ssl" |
| 330 | + set cflags "" |
| 331 | + set ldflags "" |
| 332 | + } else { |
| 333 | + set msg "ssl in $dir" |
| 334 | + set cflags "-I$dir/include" |
| 335 | + set ldflags "-L$dir/lib" |
| 336 | + } |
| 337 | + if {[check-for-openssl $msg "$cflags $ldflags"]} { |
| 338 | + incr found |
| 339 | + break |
| 340 | + } |
| 264 | 341 | } |
| 265 | 342 | } |
| 266 | 343 | } |
| 267 | 344 | if {$found} { |
| 268 | 345 | define FOSSIL_ENABLE_SSL |
| 269 | 346 | define-append EXTRA_CFLAGS $cflags |
| 270 | 347 | define-append EXTRA_LDFLAGS $ldflags |
| 271 | | - define-append LIBS -lssl -lcrypto |
| 348 | + if {[info exists ssllibs]} { |
| 349 | + define-append LIBS $ssllibs |
| 350 | + } else { |
| 351 | + define-append LIBS -lssl -lcrypto |
| 352 | + } |
| 353 | + if {[is_mingw]} { |
| 354 | + define-append LIBS -lgdi32 -lwsock32 |
| 355 | + } |
| 272 | 356 | msg-result "HTTPS support enabled" |
| 273 | 357 | |
| 274 | 358 | # Silence OpenSSL deprecation warnings on Mac OS X 10.7. |
| 275 | 359 | if {[string match *-darwin* [get-define host]]} { |
| 276 | 360 | if {[cctest -cflags {-Wdeprecated-declarations}]} { |
| | @@ -280,40 +364,15 @@ |
| 280 | 364 | } else { |
| 281 | 365 | user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support" |
| 282 | 366 | } |
| 283 | 367 | } |
| 284 | 368 | |
| 285 | | -if {[opt-bool with-miniz]} { |
| 286 | | - define FOSSIL_ENABLE_MINIZ 1 |
| 287 | | - msg-result "Using miniz for compression" |
| 288 | | -} else { |
| 289 | | - # Check for zlib, using the given location if specified |
| 290 | | - set zlibpath [opt-val with-zlib] |
| 291 | | - if {$zlibpath eq "tree"} { |
| 292 | | - set zlibdir [file dirname $autosetup(dir)]/compat/zlib |
| 293 | | - cc-with [list -cflags "-I$zlibdir"] |
| 294 | | - define-append EXTRA_CFLAGS -I$zlibdir |
| 295 | | - define-append LIBS $zlibdir/libz.a |
| 296 | | - msg-result "Using zlib in source tree" |
| 297 | | - } else { |
| 298 | | - if {$zlibpath ni {auto ""}} { |
| 299 | | - cc-with [list -cflags "-I$zlibpath -L$zlibpath"] |
| 300 | | - define-append EXTRA_CFLAGS -I$zlibpath |
| 301 | | - define-append EXTRA_LDFLAGS -L$zlibpath |
| 302 | | - msg-result "Using zlib from $zlibpath" |
| 303 | | - } |
| 304 | | - if {![cc-check-includes zlib.h] || ![cc-check-function-in-lib inflateEnd z]} { |
| 305 | | - user-error "zlib not found please install it or specify the location with --with-zlib" |
| 306 | | - } |
| 307 | | - } |
| 308 | | -} |
| 309 | | - |
| 310 | 369 | # Network functions require libraries on some systems |
| 311 | 370 | cc-check-function-in-lib gethostbyname nsl |
| 312 | 371 | if {![cc-check-function-in-lib socket {socket network}]} { |
| 313 | 372 | # Last resort, may be Windows |
| 314 | | - if {[string match *mingw* [get-define host]]} { |
| 373 | + if {[is_mingw]} { |
| 315 | 374 | define-append LIBS -lwsock32 |
| 316 | 375 | } |
| 317 | 376 | } |
| 318 | 377 | cc-check-function-in-lib iconv iconv |
| 319 | 378 | cc-check-functions utime |
| 320 | 379 | |