<!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=&quot;$1&quot;; shift;
+  local version_macro=&quot;$1&quot;; shift;
+
+  local value=&quot;$(printf &quot;#include &lt;${sys_header}&gt;\n${version_macro}\n&quot; | cc -x c -E - 2&gt;/dev/null | tail -1)&quot;;
+
+  if [ &quot;${value}&quot; = &quot;${version_macro}&quot; ]; then
+    # Macro was not replaced
+    return 1;
+  fi;
+
+  echo &quot;${value}&quot;;
+}
+
+
</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=&quot;$(printf &quot;#include &lt;${sys_header}&gt;\n${version_macro}\n&quot; | cc -x c -E - | tail -1)&quot;;
</del><ins>+  local found_version=&quot;$(c_macro &quot;${sys_header}&quot; &quot;${version_macro}&quot;)&quot;;
</ins><span class="cx"> 
</span><del>-  if [ &quot;${found_version}&quot; = &quot;${version_macro}&quot; ]; then
-    # Macro was not replaced
-    return 1;
-  fi;
-
-  if cmp_version &quot;${min_version}&quot; &quot;${found_version}&quot;; then
</del><ins>+  if [ -n &quot;${found_version}&quot; ] &amp;&amp; cmp_version &quot;${min_version}&quot; &quot;${found_version}&quot;; 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 &lt;&lt;EOF
-  #include &lt;stdio.h&gt;
-  #include &lt;openssl/ssl.h&gt;
-  int main(void)
-  {
-    if(printf(&quot;%lu&quot;,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 &quot;$PROG&quot; | cc -x c -o $OUT - 2&gt; /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 &quot;Couldn't remove tmp file: ${OUT}&quot;
-  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=&quot;&quot;;
</span><del>-  local config_cmd=&quot;configure&quot;;
-  local prebuild_cmd=&quot;&quot;;
-  local build_cmd=&quot;jmake&quot;;
-  local install_cmd=&quot;make install&quot;;
</del><ins>+  local configure=&quot;configure&quot;;
</ins><span class="cx"> 
</span><span class="cx">   OPTIND=1;
</span><del>-  while getopts &quot;m:s:c:p:b:i:&quot; option; do
</del><ins>+  while getopts &quot;m:s:c:&quot; option; do
</ins><span class="cx">     case &quot;${option}&quot; in
</span><span class="cx">       'm') f_hash=&quot;-m ${OPTARG}&quot;; ;;
</span><span class="cx">       's') f_hash=&quot;-s ${OPTARG}&quot;; ;;
</span><del>-      'c') config_cmd=&quot;${OPTARG}&quot;; ;;
-      'p') prebuild_cmd=&quot;${OPTARG}&quot;; ;;
-      'b') build_cmd=&quot;${OPTARG}&quot;; ;;
-      'i') install_cmd=&quot;${OPTARG}&quot;; ;;
</del><ins>+      'c') configure=&quot;${OPTARG}&quot;; ;;
</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=&quot;$1&quot;; shift;
</span><span class="cx">   local  uri=&quot;$1&quot;; 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 &quot;${dep_sources}&quot;;
</span><span class="cx"> 
</span><span class="lines">@@ -414,10 +385,9 @@
</span><span class="cx">     if [ ! -d &quot;${dstroot}&quot; ]; then
</span><span class="cx">       echo &quot;Building ${name}...&quot;;
</span><span class="cx">       cd &quot;${srcdir}&quot;;
</span><del>-      ./${config_cmd} --prefix=&quot;${dstroot}&quot; &quot;$@&quot;;
-      [ &quot;${prebuild_cmd}&quot; ] &amp;&amp; eval ${prebuild_cmd};
-      [ &quot;${build_cmd}&quot; ] &amp;&amp; eval ${build_cmd};
-      [ &quot;${install_cmd}&quot; ] &amp;&amp; eval ${install_cmd};
</del><ins>+      &quot;./${configure}&quot; --prefix=&quot;${dstroot}&quot; &quot;$@&quot;;
+      jmake;
+      jmake install;
</ins><span class="cx">       cd &quot;${wd}&quot;;
</span><span class="cx">     else
</span><span class="cx">       echo &quot;Using built ${name}.&quot;;
</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=&quot;${dev_roots}/c_glue&quot;;
-  c_glue_include=&quot;${c_glue_root}/include&quot;;
</del><ins>+  local    c_glue_root=&quot;${dev_roots}/c_glue&quot;;
+  local c_glue_include=&quot;${c_glue_root}/include&quot;;
</ins><span class="cx"> 
</span><span class="cx">   export C_INCLUDE_PATH=&quot;${c_glue_include}:${C_INCLUDE_PATH:-}&quot;;
</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 &quot;${do_setup}&quot;; then
-          using_system &quot;OpenSSL&quot;;
-        fi;
-        buildOpenSSL=0
-      fi;
-    fi;
-  fi;
-  if [ ${buildOpenSSL} -eq 1 ]; then
</del><ins>+
+  local min_ssl_version=&quot;9470367000&quot;;  # OpenSSL 0.9.8y
+
+  local ssl_version=&quot;$(c_macro openssl/ssl.h OPENSSL_VERSION_NUMBER)&quot;;
+  if [ -z &quot;${ssl_version}&quot; ]; then ssl_version=&quot;0x0&quot;; fi;
+  ssl_version=&quot;$(&quot;${bootstrap_python}&quot; -c &quot;print ${ssl_version}&quot;)&quot;;
+
+  if [ &quot;${ssl_version}&quot; -lt &quot;${min_ssl_version}&quot; ]; then
</ins><span class="cx">     local v=&quot;0.9.8y&quot;;
</span><span class="cx">     local n=&quot;openssl&quot;;
</span><span class="cx">     local p=&quot;${n}-${v}&quot;;
</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 &quot;47c7fb37f78c970f1d30aa2f9e9e26d8&quot; \
-      -c &quot;config&quot; \
-      -b &quot;make&quot; \
</del><ins>+    c_dependency -c &quot;config&quot; -m &quot;47c7fb37f78c970f1d30aa2f9e9e26d8&quot; \
</ins><span class="cx">       &quot;openssl&quot; &quot;${p}&quot; \
</span><del>-      &quot;http://www.openssl.org/source/${p}.tar.gz&quot; &quot;shared&quot;
</del><ins>+      &quot;http://www.openssl.org/source/${p}.tar.gz&quot;;
</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 &quot;libffi&quot;;
</span><span class="lines">@@ -506,6 +470,7 @@
</span><span class="cx">       &quot;ftp://sourceware.org/pub/libffi/${p}.tar.gz&quot;
</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 &quot;OpenLDAP&quot;;
</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 &quot;SASL&quot;;
</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 &gt; /dev/null; then
</span><span class="cx">     using_system &quot;memcached&quot;;
</span><span class="lines">@@ -565,6 +532,7 @@
</span><span class="cx">       &quot;http://www.memcached.org/files/${p}.tar.gz&quot;;
</span><span class="cx">   fi;
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx">   ruler;
</span><span class="cx">   if type -P postgres &gt; /dev/null; then
</span><span class="cx">     using_system &quot;Postgres&quot;;
</span></span></pre>
</div>
</div>

</body>
</html>