This is clearly only a code segment, but here's a basic analysis of what it's apparently trying to do. It would be easier if the output of the script were given - this script has a lot of debug information in it which will really help you. This script segment is carrying out a three-part if-statement as follows:
A)
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
This section is actioning the $ac_compile command, defined elsewhere in the script. This section creates the error file 'conftest.err' which it displays to output redirection channel 5 and returns the exit code of the $ac_compile command IE if the compile succeeds return TRUE - we'll call this answer A.
&& (This is a perhaps best considered a connective AND in the overall 'if' statement.)
B)
{ ac_try='test -z "$ac_cxx_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }
This section checks to see if the string $ac_cxx_werror_flag is zero length OR if the file conftest.err (created in section A) does not exist or is empty. This section returns the result of the two tests within this section IE if the flag variable is zero length or the file either doesn't exist or it is empty, return TRUE. This is answer B
&& (Again we have an 'AND' statement in the main three-part IF statement.)
C)
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }
This segment tests to see if the file conftest.$ac_objext exists and is non-zero in size. We'll call this answer C.
So - at this point we have three possible failure points. The script is using the following logic:
If (answer A=TRUE) AND (answer B=TRUE) AND (answer C=TRUE) then (carry on) else (display error messages)
The output from your script should show pretty clearly what it's trying to do and the point at which it failed. Check for the destination of output redirection on channel 5 (the >&5), as that's where the debug information is going.
Anyway, that's my two cents worth - take it for what it's worth, it's late on a Friday.

Good luck!