Fossil

Check-in [b41f4284]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make configure more robust when using the in-tree zlib and OpenSSL.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b41f42841f029b88a2fce1a7f8cc5c0ae7eb6719
User & Date: mistachkin 2016-01-30 01:28:31
Context
2016-01-30
04:29
Improve auto-detection of Tcl on systems where -lpthread is missing from TCL_LIB_SPEC. check-in: 352e2ef9 user: mistachkin tags: trunk
01:28
Make configure more robust when using the in-tree zlib and OpenSSL. check-in: b41f4284 user: mistachkin tags: trunk
2016-01-29
22:57
Tweak for 'internal-sqlite=0'. Closed-Leaf check-in: 98881d89 user: mistachkin tags: configInTree
21:06
Require the 'read' permission to view the 'test-version' web page. check-in: 83b2acb7 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to auto.def.

    35     35   # Find tclsh for the test suite. Can't yet use jimsh for this.
    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     41   define USE_LINENOISE 0
           42  +
           43  +# This procedure is a customized version of "cc-check-function-in-lib",
           44  +# that does not modify the LIBS variable.  Its use prevents prematurely
           45  +# pulling in libraries that will be added later anyhow (e.g. "-ldl").
           46  +proc check-function-in-lib {function libs {otherlibs {}}} {
           47  +    if {[string length $otherlibs]} {
           48  +        msg-checking "Checking for $function in $libs with $otherlibs..."
           49  +    } else {
           50  +        msg-checking "Checking for $function in $libs..."
           51  +    }
           52  +    set found 0
           53  +    cc-with [list -libs $otherlibs] {
           54  +        if {[cctest_function $function]} {
           55  +            msg-result "none needed"
           56  +            define lib_$function ""
           57  +            incr found
           58  +        } else {
           59  +            foreach lib $libs {
           60  +                cc-with [list -libs -l$lib] {
           61  +                    if {[cctest_function $function]} {
           62  +                        msg-result -l$lib
           63  +                        define lib_$function -l$lib
           64  +                        incr found
           65  +                        break
           66  +                    }
           67  +                }
           68  +            }
           69  +        }
           70  +    }
           71  +    if {$found} {
           72  +        define [feature-define-name $function]
           73  +    } else {
           74  +        msg-result "no"
           75  +    }
           76  +    return $found
           77  +}
    42     78   
    43     79   if {![opt-bool internal-sqlite]} {
    44     80     proc find_internal_sqlite {} {
    45     81   
    46     82       # On some systems (slackware), libsqlite3 requires -ldl to link. So
    47     83       # search for the system SQLite once with -ldl, and once without. If
    48     84       # the library can only be found with $extralibs set to -ldl, then
................................................................................
    51     87       foreach extralibs {{} {-ldl}} {
    52     88   
    53     89         # Locate the system SQLite by searching for sqlite3_open(). Then check
    54     90         # if sqlite3_strglob() can be found as well. If we can find open() but
    55     91         # not strglob(), then the system SQLite is too old to link against
    56     92         # fossil.
    57     93         #
    58         -      if {[cc-check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
    59         -        if {![cc-check-function-in-lib sqlite3_malloc64 sqlite3 $extralibs]} {
           94  +      if {[check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
           95  +        if {![check-function-in-lib sqlite3_malloc64 sqlite3 $extralibs]} {
    60     96             user-error "system sqlite3 too old (require >= 3.8.7)"
    61     97           }
    62     98   
    63     99           # Success. Update symbols and return.
    64    100           #
    65    101           define USE_SYSTEM_SQLITE 1
          102  +        define-append LIBS -lsqlite3
    66    103           define-append LIBS $extralibs
    67    104           return
    68    105         }
    69    106       }
    70    107       user-error "system sqlite3 not found"
    71    108     }
    72    109   
................................................................................
   140    177       # XXX: This will not work on all systems.
   141    178       define-append EXTRA_LDFLAGS -static
   142    179       msg-result "Trying to link statically"
   143    180   } else {
   144    181       define-append EXTRA_CFLAGS -DFOSSIL_DYNAMIC_BUILD=1
   145    182       define FOSSIL_DYNAMIC_BUILD
   146    183   }
          184  +
          185  +# Helper for OpenSSL checking
          186  +proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
          187  +    msg-checking "Checking for $msg..."
          188  +    set rc 0
          189  +    if {[is_mingw]} {
          190  +        lappend libs -lgdi32 -lwsock32
          191  +    }
          192  +    if {[info exists ::zlib_for_ssl]} {
          193  +        lappend libs $::zlib_for_ssl
          194  +    }
          195  +    msg-quiet cc-with [list -cflags $cflags -libs $libs] {
          196  +        if {[cc-check-includes openssl/ssl.h] && \
          197  +                [cc-check-functions SSL_new]} {
          198  +            incr rc
          199  +        }
          200  +    }
          201  +    if {!$rc && ![is_mingw]} {
          202  +        # On some systems, OpenSSL appears to require -ldl to link.
          203  +        lappend libs -ldl
          204  +        msg-quiet cc-with [list -cflags $cflags -libs $libs] {
          205  +            if {[cc-check-includes openssl/ssl.h] && \
          206  +                    [cc-check-functions SSL_new]} {
          207  +                incr rc
          208  +            }
          209  +        }
          210  +    }
          211  +    if {$rc} {
          212  +        msg-result "ok"
          213  +        return 1
          214  +    } else {
          215  +        msg-result "no"
          216  +        return 0
          217  +    }
          218  +}
          219  +
          220  +if {[opt-bool with-miniz]} {
          221  +    define FOSSIL_ENABLE_MINIZ 1
          222  +    msg-result "Using miniz for compression"
          223  +} else {
          224  +    # Check for zlib, using the given location if specified
          225  +    set zlibpath [opt-val with-zlib]
          226  +    if {$zlibpath eq "tree"} {
          227  +        set zlibdir [file dirname $autosetup(dir)]/compat/zlib
          228  +        if {![file isdirectory $zlibdir]} {
          229  +            user-error "The zlib in source tree directory does not exist"
          230  +        }
          231  +        cc-with [list -cflags "-I$zlibdir -L$zlibdir"]
          232  +        define-append EXTRA_CFLAGS -I$zlibdir
          233  +        define-append LIBS $zlibdir/libz.a
          234  +        set ::zlib_for_ssl $zlibdir/libz.a
          235  +        msg-result "Using zlib in source tree"
          236  +    } else {
          237  +        if {$zlibpath ni {auto ""}} {
          238  +            cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
          239  +            define-append EXTRA_CFLAGS -I$zlibpath
          240  +            define-append EXTRA_LDFLAGS -L$zlibpath
          241  +            msg-result "Using zlib from $zlibpath"
          242  +        }
          243  +        if {![cc-check-includes zlib.h] || ![check-function-in-lib inflateEnd z]} {
          244  +            user-error "zlib not found please install it or specify the location with --with-zlib"
          245  +        }
          246  +        set ::zlib_for_ssl -lz
          247  +    }
          248  +}
          249  +
          250  +set ssldirs [opt-val with-openssl]
          251  +if {$ssldirs ne "none"} {
          252  +    if {[opt-bool with-miniz]} {
          253  +        user-error "The --with-miniz option is incompatible with OpenSSL"
          254  +    }
          255  +    set found 0
          256  +    if {$ssldirs eq "tree"} {
          257  +        set ssldir [file dirname $autosetup(dir)]/compat/openssl
          258  +        if {![file isdirectory $ssldir]} {
          259  +            user-error "The OpenSSL in source tree directory does not exist"
          260  +        }
          261  +        set msg "ssl in $ssldir"
          262  +        set cflags "-I$ssldir/include"
          263  +        set ldflags "-L$ssldir"
          264  +        set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a"
          265  +        set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs]
          266  +    } else {
          267  +        if {$ssldirs in {auto ""}} {
          268  +            catch {
          269  +                set cflags [exec pkg-config openssl --cflags-only-I]
          270  +                set ldflags [exec pkg-config openssl --libs-only-L]
          271  +                set found [check-for-openssl "ssl via pkg-config" "$cflags $ldflags"]
          272  +            } msg
          273  +            if {!$found} {
          274  +                set ssldirs "{} /usr/sfw /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
          275  +            }
          276  +        }
          277  +        if {!$found} {
          278  +            foreach dir $ssldirs {
          279  +                if {$dir eq ""} {
          280  +                    set msg "system ssl"
          281  +                    set cflags ""
          282  +                    set ldflags ""
          283  +                } else {
          284  +                    set msg "ssl in $dir"
          285  +                    set cflags "-I$dir/include"
          286  +                    set ldflags "-L$dir/lib"
          287  +                }
          288  +                if {[check-for-openssl $msg "$cflags $ldflags"]} {
          289  +                    incr found
          290  +                    break
          291  +                }
          292  +            }
          293  +        }
          294  +    }
          295  +    if {$found} {
          296  +        define FOSSIL_ENABLE_SSL
          297  +        define-append EXTRA_CFLAGS $cflags
          298  +        define-append EXTRA_LDFLAGS $ldflags
          299  +        if {[info exists ssllibs]} {
          300  +            define-append LIBS $ssllibs
          301  +        } else {
          302  +            define-append LIBS -lssl -lcrypto
          303  +        }
          304  +        if {[is_mingw]} {
          305  +            define-append LIBS -lgdi32 -lwsock32
          306  +        }
          307  +        msg-result "HTTPS support enabled"
          308  +
          309  +        # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
          310  +        if {[string match *-darwin* [get-define host]]} {
          311  +            if {[cctest -cflags {-Wdeprecated-declarations}]} {
          312  +                define-append EXTRA_CFLAGS -Wdeprecated-declarations
          313  +            }
          314  +        }
          315  +    } else {
          316  +        user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
          317  +    }
          318  +}
   147    319   
   148    320   set tclpath [opt-val with-tcl]
   149    321   if {$tclpath ne ""} {
   150    322       set tclprivatestubs [opt-bool with-tcl-private-stubs]
   151    323       # Note parse-tclconfig-sh is in autosetup/local.tcl
   152    324       if {$tclpath eq "1"} {
   153    325           set tcldir [file dirname $autosetup(dir)]/compat/tcl-8.6
................................................................................
   223    395       }
   224    396       set version $tclconfig(TCL_VERSION)$tclconfig(TCL_PATCH_LEVEL)
   225    397       msg-result "Found Tcl $version at $tclconfig(TCL_PREFIX)"
   226    398       if {!$tclprivatestubs} {
   227    399           define-append LIBS $libs
   228    400       }
   229    401       define-append EXTRA_CFLAGS $cflags
          402  +    if {[info exists zlibpath] && $zlibpath eq "tree"} {
          403  +      #
          404  +      # NOTE: When using zlib in the source tree, prevent Tcl from
          405  +      #       pulling in the system one.
          406  +      #
          407  +      set tclconfig(TCL_LD_FLAGS) [string map [list -lz ""] \
          408  +          $tclconfig(TCL_LD_FLAGS)]
          409  +    }
          410  +    #
          411  +    # NOTE: Remove "-ldl" from the TCL_LD_FLAGS because it will be
          412  +    #       be checked for near the bottom of this file.
          413  +    #
          414  +    set tclconfig(TCL_LD_FLAGS) [string map [list -ldl ""] \
          415  +        $tclconfig(TCL_LD_FLAGS)]
   230    416       define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
   231    417       define FOSSIL_ENABLE_TCL
   232    418   }
   233    419   
   234         -# Helper for OpenSSL checking
   235         -proc check-for-openssl {msg {cflags {}} {libs {-lssl -lcrypto}}} {
   236         -    msg-checking "Checking for $msg..."
   237         -    set rc 0
   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]} {
   247         -            incr rc
   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         -        }
   259         -    }
   260         -    if {$rc} {
   261         -        msg-result "ok"
   262         -        return 1
   263         -    } else {
   264         -        msg-result "no"
   265         -        return 0
   266         -    }
   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         -}
   298         -
   299         -set ssldirs [opt-val with-openssl]
   300         -if {$ssldirs ne "none"} {
   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         -                }
   341         -            }
   342         -        }
   343         -    }
   344         -    if {$found} {
   345         -        define FOSSIL_ENABLE_SSL
   346         -        define-append EXTRA_CFLAGS $cflags
   347         -        define-append EXTRA_LDFLAGS $ldflags
   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         -        }
   356         -        msg-result "HTTPS support enabled"
   357         -
   358         -        # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
   359         -        if {[string match *-darwin* [get-define host]]} {
   360         -            if {[cctest -cflags {-Wdeprecated-declarations}]} {
   361         -                define-append EXTRA_CFLAGS -Wdeprecated-declarations
   362         -            }
   363         -        }
   364         -    } else {
   365         -        user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
   366         -    }
   367         -}
   368         -
   369    420   # Network functions require libraries on some systems
   370    421   cc-check-function-in-lib gethostbyname nsl
   371    422   if {![cc-check-function-in-lib socket {socket network}]} {
   372    423       # Last resort, may be Windows
   373    424       if {[is_mingw]} {
   374    425           define-append LIBS -lwsock32
   375    426       }