[CalendarServer-changes] [12013] CalendarServer/trunk/support/build.sh
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:19:13 PDT 2014
Revision: 12013
http://trac.calendarserver.org//changeset/12013
Author: dre at apple.com
Date: 2013-11-24 15:30:02 -0800 (Sun, 24 Nov 2013)
Log Message:
-----------
The verison of Python-LDAP we now use requires a more strict checking of the
installed version of OpenLDAP. It's not enough to just check for the presence
of ldap.h as we had been doing (LDAP_CONTROL_RELAX). This change expands the
check_header function to also allow specifying a second and third argument,
which are a version number and a #define that's expected to yield a version
number from within a C preprocessor that has included the specified header.
These values are compared by py.sh:cmp_version, which returns yea or nay.
Modified Paths:
--------------
CalendarServer/trunk/support/build.sh
Modified: CalendarServer/trunk/support/build.sh
===================================================================
--- CalendarServer/trunk/support/build.sh 2013-11-24 12:34:47 UTC (rev 12012)
+++ CalendarServer/trunk/support/build.sh 2013-11-24 23:30:02 UTC (rev 12013)
@@ -40,11 +40,67 @@
fi;
}
+# Checks for presence of a C header, optionally with a version comparison.
+# With only a header file name, try to include it, returning nonzero if absent.
+# With 3 params, also attempt a version check, returning nonzero if too old.
+# Param 2 is a minimum acceptable version number
+# Param 3 is a #define from the source that holds the installed version number
+# Examples:
+# Assert that ldap.h is present
+# find_header "ldap.h"
+# Assert that ldap.h is present with a version >= 20344
+# find_header "ldap.h" 20344 "LDAP_VENDOR_VERSION"
find_header () {
- local sysheader="$1"; shift;
- echo "#include <${sysheader}>" | cc -x c -c - -o /dev/null 2> /dev/null;
- return "$?";
-}
+ ARGS="$@";
+ ret=1; # default to a failed check, forcing a fetch of the depencency
+ i=0;
+ for a in $ARGS; do
+ [ $i -eq 0 ] && local sysheader="$1";
+ [ $i -eq 1 ] && local minver="$2";
+ [ $i -eq 2 ] && local def="$3";
+ i=$(($i+1));
+ done;
+ [ ! $sysheader ] && return 1;
+ # Check for presence of a header. We use the "-c" cc option because we don't
+ # need to emit a file; cc exits nonzero if it can't find the header
+ if [ $# -lt 2 ]; then
+ echo "#include <${sysheader}>" | cc -x c -c - -o /dev/null 2> /dev/null;
+ return "$?";
+ # Check for presence of a header of specified version
+ else
+ found='';
+ local aout=$(mktemp -t ccXXXXXX); # compiled executable file path
+ local prog=$(mktemp -t ccXXXXXX); # C source file path
+ cat <<DOC > ${prog}
+#include <${sysheader}>
+#include <stdio.h>
+#define STR(x) #x
+#define SHOW_DEFINE(x) printf("%s", STR(x))
+int main()
+{
+ if (${def})
+ {
+ SHOW_DEFINE(${def});
+ return 0;
+ };
+ return 1;
+};
+DOC
+ cc -x c -o ${aout} ${prog} &> /dev/null;
+ if [ $? -eq 0 ] && [ -e ${aout} ] ; then
+ found=$(${aout});
+ fi;
+ if [ $? -eq 0 ] && [ ! -z ${found} ] ; then
+ cmp_version $minver $found;
+ ret=$?;
+ else
+ ret=1; #cc exited nonzero or didn't emit a file
+ fi;
+ rm -f "${aout}";
+ rm -f "${prog}";
+ fi;
+ return $ret;
+};
# Initialize all the global state required to use this library.
init_build () {
@@ -703,7 +759,7 @@
:;
fi;
- if find_header ldap.h; then
+ if find_header ldap.h 20428 LDAP_VENDOR_VERSION; then
using_system "OpenLDAP";
else
local v="2.4.38";
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/b2afdd07/attachment.html>
More information about the calendarserver-changes
mailing list