title: Errors when cross-compiling OpenSSL on OS X for iOS with Clang instead of gcc
body: <p>I would like to cross-compile OpenSSL 1.0.1h for iOS on OS X without gcc installed by following instructions in the WWDC 2014 session 305 video and from the OpenSSL web site.</p>
  
  <p>I unzip/untar and the switch from <code>gcc</code> to <code>clang</code> (almost) as suggested <a href="http://wiki.openssl.org/index.php/Compilation_and_Installation#Modifying_Build_Settings" rel="nofollow">here</a>.</p>
  
  <pre><code>OLD_LANG=$LANG
  unset LANG
  
  sed -i "" 's|\"iphoneos-cross\"\,\"llvm-gcc\:-O3|\"iphoneos-cross\"\,\"clang\:-Os|g' Configure
  sed -i "" 's/CC= cc/CC= clang/g' Makefile.org
  sed -i "" 's/CFLAG= -O/CFLAG= -Os/g' Makefile.org
  
  export LANG=$OLD_LANG
  </code></pre>
  
  <p>Notice that I had to stick with the <code>makedepend</code> tool for otherwise already the <code>make depend</code> step will fail (as was also mentioned <a href="http://openssl.6102.n7.nabble.com/FIPS-iOS-7-Xcode-5-td48921.html" rel="nofollow">elsewhere</a>). Installing that tool with <code>brew install makedepend</code> is not an issue for me (but installing gcc next to  Clang would be). Now</p>
  
  <pre><code>./Configure iphoneos-cross
  make depend
  make
  </code></pre>
  
  <p>leads to warnings (during <code>make depend</code>) and errors (during <code>make</code>) about missing include files (such as <code>stdlib.h</code>). The typical include path passed to <code>clang</code> is apparently <code>-I. -I.. -I../include</code>.</p>
  
  <p>I assume this is to <a href="http://clang.llvm.org/docs/FAQ.html" rel="nofollow">related</a> to <code>clang</code> not receiving specific C options by default, but if so, what is the most sensible way for making the compilation work e.g. by fixing the <code>sed</code> edits or by setting environment variables. (Currently I don't have any <code>CC*</code> environment variables set. There is e.g. <code>/usr/include/stdlib.h</code> on my system.)</p>
  
  <p>I rarely use OS X C compilers on the command line and the solution is therefore not obvious to me.</p>
  
  <p><strong>UPDATE</strong> Here is the question in a more specific for whose valid answer will be awarded with a bounty: What specific edits (similar to the first code snippet above) have to be performed on the files in latest version of OpenSSL source code (e.g. <code>openssl-1.0.1h.tar.gz</code>) so that one can cross-compiles it by issuing commands similar to the second code snippet above for iOS 7 (soon iOS 8) architectures on OS X 10.9 with Xcode 5.1.1 (soon Xcode 6) installed, without gcc installed and with <code>makedepend</code> optionally installed?</p>