<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[13432] CalendarServer/trunk/bin/_build.sh</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/13432">13432</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2014-05-04 08:03:10 -0700 (Sun, 04 May 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Clean up OpenSSL handling.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkbin_buildsh">CalendarServer/trunk/bin/_build.sh</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkbin_buildsh"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/bin/_build.sh (13431 => 13432)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/bin/_build.sh        2014-05-03 23:01:42 UTC (rev 13431)
+++ CalendarServer/trunk/bin/_build.sh        2014-05-04 15:03:10 UTC (rev 13432)
</span><span class="lines">@@ -29,6 +29,21 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><ins>+c_macro () {
+ local sys_header="$1"; shift;
+ local version_macro="$1"; shift;
+
+ local value="$(printf "#include <${sys_header}>\n${version_macro}\n" | cc -x c -E - 2>/dev/null | tail -1)";
+
+ if [ "${value}" = "${version_macro}" ]; then
+ # Macro was not replaced
+ return 1;
+ fi;
+
+ echo "${value}";
+}
+
+
</ins><span class="cx"> # Checks for presence of a C header, optionally with a version comparison.
</span><span class="cx"> # With only a header file name, try to include it, returning nonzero if absent.
</span><span class="cx"> # With 3 params, also attempt a version check, returning nonzero if too old.
</span><span class="lines">@@ -55,53 +70,15 @@
</span><span class="cx"> fi;
</span><span class="cx">
</span><span class="cx"> # Check for presence of a header of specified version
</span><del>- local found_version="$(printf "#include <${sys_header}>\n${version_macro}\n" | cc -x c -E - | tail -1)";
</del><ins>+ local found_version="$(c_macro "${sys_header}" "${version_macro}")";
</ins><span class="cx">
</span><del>- if [ "${found_version}" = "${version_macro}" ]; then
- # Macro was not replaced
- return 1;
- fi;
-
- if cmp_version "${min_version}" "${found_version}"; then
</del><ins>+ if [ -n "${found_version}" ] && cmp_version "${min_version}" "${found_version}"; then
</ins><span class="cx"> return 0;
</span><span class="cx"> else
</span><span class="cx"> return 1;
</span><span class="cx"> fi;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-# openssl/opensslv.h defines its version number as something like 0x0090819fL.
-# Emit an integer representation of this value and return 0, or fail and
-# return 1
-find_openssl_version () {
- # A small C program to print the hex version as an int.
- # 'read' exits non-zero on EOF, which is required for heredoc input.
- # However, bin/develop sets -e, so disable -e temporarily to prevent exit.
- set +e
- read -d '' PROG <<EOF
- #include <stdio.h>
- #include <openssl/ssl.h>
- int main(void)
- {
- if(printf("%lu",OPENSSL_VERSION_NUMBER)) {return 0;}
- return 1;
- }
-EOF
- set -e
- error=0
- # Make an output file for cc, or bail
- OUT=$(mktemp -t vcheck.XXXX) || return 1
- # Compile the program, squelching stderr
- echo "$PROG" | cc -x c -o $OUT - 2> /dev/null
- if [ $? -eq 0 ] ; then
- # build succeeded; run the program. If it exits non-zero, set error status
- ${OUT} || error=1
- else
- # build failed
- error=1
- fi
- rm ${OUT} || echo "Couldn't remove tmp file: ${OUT}"
- return ${error}
-}
</del><span class="cx">
</span><span class="cx"> # Initialize all the global state required to use this library.
</span><span class="cx"> init_build () {
</span><span class="lines">@@ -367,20 +344,14 @@
</span><span class="cx"> # By default, do: ./configure --prefix ... ; jmake ; make install
</span><span class="cx"> c_dependency () {
</span><span class="cx"> local f_hash="";
</span><del>- local config_cmd="configure";
- local prebuild_cmd="";
- local build_cmd="jmake";
- local install_cmd="make install";
</del><ins>+ local configure="configure";
</ins><span class="cx">
</span><span class="cx"> OPTIND=1;
</span><del>- while getopts "m:s:c:p:b:i:" option; do
</del><ins>+ while getopts "m:s:c:" option; do
</ins><span class="cx"> case "${option}" in
</span><span class="cx"> 'm') f_hash="-m ${OPTARG}"; ;;
</span><span class="cx"> 's') f_hash="-s ${OPTARG}"; ;;
</span><del>- 'c') config_cmd="${OPTARG}"; ;;
- 'p') prebuild_cmd="${OPTARG}"; ;;
- 'b') build_cmd="${OPTARG}"; ;;
- 'i') install_cmd="${OPTARG}"; ;;
</del><ins>+ 'c') configure="${OPTARG}"; ;;
</ins><span class="cx"> esac;
</span><span class="cx"> done;
</span><span class="cx"> shift $((${OPTIND} - 1));
</span><span class="lines">@@ -389,7 +360,7 @@
</span><span class="cx"> local path="$1"; shift;
</span><span class="cx"> local uri="$1"; shift;
</span><span class="cx">
</span><del>- # Extra arguments are processed below, as arguments to config_cmd.
</del><ins>+ # Extra arguments are processed below, as arguments to configure.
</ins><span class="cx">
</span><span class="cx"> mkdir -p "${dep_sources}";
</span><span class="cx">
</span><span class="lines">@@ -414,10 +385,9 @@
</span><span class="cx"> if [ ! -d "${dstroot}" ]; then
</span><span class="cx"> echo "Building ${name}...";
</span><span class="cx"> cd "${srcdir}";
</span><del>- ./${config_cmd} --prefix="${dstroot}" "$@";
- [ "${prebuild_cmd}" ] && eval ${prebuild_cmd};
- [ "${build_cmd}" ] && eval ${build_cmd};
- [ "${install_cmd}" ] && eval ${install_cmd};
</del><ins>+ "./${configure}" --prefix="${dstroot}" "$@";
+ jmake;
+ jmake install;
</ins><span class="cx"> cd "${wd}";
</span><span class="cx"> else
</span><span class="cx"> echo "Using built ${name}.";
</span><span class="lines">@@ -452,41 +422,35 @@
</span><span class="cx"> # Build C dependencies
</span><span class="cx"> #
</span><span class="cx"> c_dependencies () {
</span><del>- c_glue_root="${dev_roots}/c_glue";
- c_glue_include="${c_glue_root}/include";
</del><ins>+ local c_glue_root="${dev_roots}/c_glue";
+ local c_glue_include="${c_glue_root}/include";
</ins><span class="cx">
</span><span class="cx"> export C_INCLUDE_PATH="${c_glue_include}:${C_INCLUDE_PATH:-}";
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> # The OpenSSL version number is special. Our strategy is to get the integer
</span><span class="cx"> # value of OPENSSL_VERSION_NUBMER for use in inequality comparison.
</span><span class="cx"> ruler;
</span><del>- buildOpenSSL=1;
- minSSLVersion=9470367; # OpenSSL 0.9.8y
- if find_header openssl/ssl.h; then
- VER=$(find_openssl_version)
- if [ ! -z ${VER} ]; then
- if [ ${VER} -ge ${minSSLVersion} ]; then
- if "${do_setup}"; then
- using_system "OpenSSL";
- fi;
- buildOpenSSL=0
- fi;
- fi;
- fi;
- if [ ${buildOpenSSL} -eq 1 ]; then
</del><ins>+
+ local min_ssl_version="9470367000"; # OpenSSL 0.9.8y
+
+ local ssl_version="$(c_macro openssl/ssl.h OPENSSL_VERSION_NUMBER)";
+ if [ -z "${ssl_version}" ]; then ssl_version="0x0"; fi;
+ ssl_version="$("${bootstrap_python}" -c "print ${ssl_version}")";
+
+ if [ "${ssl_version}" -lt "${min_ssl_version}" ]; then
</ins><span class="cx"> local v="0.9.8y";
</span><span class="cx"> local n="openssl";
</span><span class="cx"> local p="${n}-${v}";
</span><span class="cx">
</span><span class="cx"> # use 'config' instead of 'configure'; 'make' instead of 'jmake'.
</span><span class="cx"> # also pass 'shared' to config to build shared libs.
</span><del>- c_dependency -m "47c7fb37f78c970f1d30aa2f9e9e26d8" \
- -c "config" \
- -b "make" \
</del><ins>+ c_dependency -c "config" -m "47c7fb37f78c970f1d30aa2f9e9e26d8" \
</ins><span class="cx"> "openssl" "${p}" \
</span><del>- "http://www.openssl.org/source/${p}.tar.gz" "shared"
</del><ins>+ "http://www.openssl.org/source/${p}.tar.gz";
</ins><span class="cx"> fi;
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> ruler;
</span><span class="cx"> if find_header ffi.h; then
</span><span class="cx"> using_system "libffi";
</span><span class="lines">@@ -506,6 +470,7 @@
</span><span class="cx"> "ftp://sourceware.org/pub/libffi/${p}.tar.gz"
</span><span class="cx"> fi;
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> ruler;
</span><span class="cx"> if find_header ldap.h 20428 LDAP_VENDOR_VERSION; then
</span><span class="cx"> using_system "OpenLDAP";
</span><span class="lines">@@ -524,6 +489,7 @@
</span><span class="cx"> --disable-bdb --disable-hdb --with-tls=openssl;
</span><span class="cx"> fi;
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> ruler;
</span><span class="cx"> if find_header sasl.h; then
</span><span class="cx"> using_system "SASL";
</span><span class="lines">@@ -544,6 +510,7 @@
</span><span class="cx"> --disable-macos-framework;
</span><span class="cx"> fi;
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> ruler;
</span><span class="cx"> if type -P memcached > /dev/null; then
</span><span class="cx"> using_system "memcached";
</span><span class="lines">@@ -565,6 +532,7 @@
</span><span class="cx"> "http://www.memcached.org/files/${p}.tar.gz";
</span><span class="cx"> fi;
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> ruler;
</span><span class="cx"> if type -P postgres > /dev/null; then
</span><span class="cx"> using_system "Postgres";
</span></span></pre>
</div>
</div>
</body>
</html>